Accessing properties file in a JSF application programmatically

The Class#getResourceAsStream() can take a path which is relative to the location of the Class which you’re using there as starting point. So, for example, if the class is located in the com.example package and you request the path foo/filename.properties, then it will actually load the com/example/foo/filename.properties file. But if you use /foo/filename.properties, then it … Read more

You must supply a resource ID for a TextView android error

I’m pretty sure the problem lies in your conversation_item layout. The docs state that you must provide a resource with a single TextView. What does that layout look like? As an example, this is what the simple_list_item_1 layout looks like, yours should be pretty similar. <?xml version=”1.0″ encoding=”utf-8″?> <TextView xmlns:android=”http://schemas.android.com/apk/res/android” android:id=”@android:id/text1″ android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:textAppearance=”?android:attr/textAppearanceLarge” android:gravity=”center_vertical” … Read more

Combining Assetic Resources across inherited templates

You can actually do the following: In layout.html.twig (or whatever your layout is) {% block stylesheets %} {% stylesheets ‘your_assets_here’ %} <link rel=”stylesheet” href=”https://stackoverflow.com/questions/6958970/{{ asset_url }}” /> {% endstylesheets %} {% endblock %} And in any template that extends that layout: {% block stylesheets %} {{ parent() }} {% stylesheets ‘additional_assets_here’ %} <link rel=”stylesheet” href=”https://stackoverflow.com/questions/6958970/{{ … Read more

Create a control in Resources and reuse it in XAML WPF

When you define a arbitrary Control in Resources, you can use it in the future in Control which have property Content and derived from Control class. These are the followings: ContentControl, Label, ContentPresenter, etc. Also you must set x:Shared=”False” for resource if you want to use this resource in many Controls, because x:Shared=”True” by default … Read more

Class.getResource and ClassLoader.getSystemResource: is there a reason to prefer one to another?

There are several ways to load resources, each with a slightly different meaning – ClassLoader::getSystemResource() uses the system classloader. This uses the classpath that was used to start the program. If you are in a web container such as tomcat, this will NOT pick up resources from your WAR file. Class<T>#getResource() prepends the package name … Read more

App.xaml file does not get parsed if my app does not set a StartupUri?

Rather than overriding OnStartup, try using an event instead: <Application x:Class=”My.App” xmlns=”…” Startup=”Application_Startup” ShutdownMode=”OnExplicitShutdown”> <Application.Resources> <app:ServiceLocator x:Key=”serviceLocator” /> </Application.Resources> </Application> Code behind: public partial class App : Application { public App() { } private void Application_Startup(object sender, StartupEventArgs e) { // TODO: Parse commandline arguments and other startup work new MainWindow().Show(); } }

Spring Boot access static resources missing scr/main/resources

Just use Spring type ClassPathResource. File file = new ClassPathResource(“countries.xml”).getFile(); As long as this file is somewhere on classpath Spring will find it. This can be src/main/resources during development and testing. In production, it can be current running directory. EDIT: This approach doesn’t work if file is in fat JAR. In such case you need … Read more