jhirzel
|
Posted: June 03, 2011 15:18 by jhirzel
|
|
Hello I started using the BSAF and think it is useful for small projects and I like the fact that the framework jar file is small and thus the final jar files are small as well. I would like to access the application global resources. I took from example SingleFrameExample4 the following snippet
String defaultText = getContext().getResourceMap().getString("defaultText");
and put it into the startup method of MyApp (extending SingleFrameApplication) In MyApp.properties I have added defaultText = "ABC" However defaultText is null. What am I missing? Maybe something obvious for somebody who has used BSAF for some time? (I use Netbeans 7.0) Thank you for the answer in advance. Johannes |
Accessing Application global resources
Replies: 5 - Last Post: June 04, 2011 09:25
by: jhirzel
by: jhirzel
showing 1 - 6 of 6
jhirzel
|
Posted: June 03, 2011 15:36 by jhirzel
|
|
I realized that I do not see that 'Application.title' is set either. I have the MyApp.properties in a subpackage 'resources'. So the question is probably more about how to debug this kind of problem in Netbeans 7.0 And it turned out that I had to do a clean build (including the manual deletion of the built jar files). So what is described in the previous post works as advertised.... J. |
etf
|
Posted: June 03, 2011 18:05 by etf
|
|
Here is a working example: Source of main\java\org\etf\poligon2\App.java
package org.etf.poligon2;
...
public class App extends SingleFrameApplication {
...
@Override
protected void startup() {
String string = getContext().getResourceMap().getString("message.hello", "World");
JPanel panel = new JPanel() ;
panel.add(new JLabel(string));
show(panel);
}
...
}
Source of main\resources\org\etf\poligon2\resources\App.properties message.hello = Hello %s! Please pay attention that NB in "compile on save" mode doesn't monitor changes in properties files, so you need to clean/build entire project. I hope it was helpful. |
jhirzel
|
Posted: June 04, 2011 05:53 by jhirzel
|
|
Thank you for the confirmation. Actually it started working with my second post . So the application code is fine. But it is a problem of the IDE it seems. As of now it has again stopped working. Actually even the application title is not set. So the properties file is not considered at all. I unchecked 'compile on save' and do 'clean and build main project' in Netbeans 7.0 and the problem still persists. Maybe it is a .0 (zero) version problem and I should have waited for Netbeans 7.0.1 I will try it in Eclipse. Thank you for maintaining BSAF. In the past two years I had developed my own little framework. BSAF is much more worked out and no need for me to maintain it. The singleton pattern is fine for me. My own did the same. BSAF is good for people who do not want to go for a heavy-weight (e.g. Eclipse or Netbeans RCP). bsaf-1.9.jar is just 187kB. My app will be around 500...1000kB (easy to download over weak internet connections). Everything included, just the JRE is a necessary prerequisite. Johannes |
jhirzel
|
Posted: June 04, 2011 09:25 by jhirzel
|
|
Yes, the generated jar files contain the property file. I set the project up in Netbeans 7.0 so I assume it uses ant. Thank you for the hints to look into the build process. I set the debug level up (Netbeans / menu tools / 'ant' tab / drop down list 'Verbosity level' to 'Verbose'. This helped me to identify the problem which was that it could not delete the 'dist' folder. It was locked. --------------------------------------------------------------------- SUMMARY: Accessing Application global resources works as advertised in the BSAF examples. --------------------------------------------------------------------- NOTE: Maybe I should develop the Connexions module (OER, http://cnx.org/content/m38454/latest/) I have started into a full walkthrough of a fully worked out example setup. Suggestions and ideas are welcome. Cnx has the advantage that you can come up with 'modules' of anything (like use cases) and then combine them to a more complete thing (in cnx terminology called 'collection'). So one can "factor" out issued as the one discussed in this thread. BTW under what license are the instructions on the wiki here? Cnx uses http://creativecommons.org/licenses/by/3.0/ . |
showing 1 - 6 of 6
Replies: 5 - Last Post: June 04, 2011 09:25
by: jhirzel
by: jhirzel







