JSF RI 1.2_x configuration parameters
The JSF 1.2_x reference implementation is using a couple of configuration parameters that are not easy to find. So I did a source code search and found them in the
com.sun.faces.config.WebConfiguration class.
eclipse the memory hog
Occasionally I have to help people with this painful java.lang.OutOfMemoryError: PermGen space because it is running out of PermGen space. Here I have found a good article explaining the necessary setting – in future I can just direct them to my posting and they can help themselfes
Whats coming up in Java SE 7
In the past I have been a bit lazy on staying up-to-date with latest JDK developments, at least last year I have been to JavaPolis 2006 and listened to some interesting talks of Sun engineers about the future of the Java platform and especially the language itself.
Development for Java SE7 is under full steam and as of writing this post installable previews of the JDK 7 Project are available. I have put together a list of the major enhancements (all driven by JSR communities) of the platform.
Modularity: JSR 294 specifies so called superpackages (there will be a new keyword superpackage). Now packages are more than a means for hierarchically organizing your classes. More semantics are added as it will be possible to put visibility attributes on packages.
JSR 277 defines new deployment mechanisms through deployment modules that will be packaged with a new distribution format (JAM Java Module). So in future a build process may also be called ‘JAM session’
If you want to bruh up your knowledge on this I recommend a presentation published at parleys.com.
Swing: rich client technologies have been pushed a lot in the last 2-3 years. The Java API for Rich Client development lacks support for typical development task (this is where the eclipse platform competes successfully and is unbeaten). So now the JSR 296 (Swing Application Framework), JSR 295 (Bean Binding Framework) and JSR 303 (Bean Validation Framework) try to fill some of the gaps. I haven’t had the time to look at JSR 295 but this looks similar to what JBoss is doing with Hibernate Validator ( see one of my previous posts).
Reified Generics: Weren’t we excited as we heard about Java5 would offer generics/type templating didn’t we get really disappointed when we experienced type erasure. Now it seems that type information will be made available at runtime for templated types. I had a few occasions where this would have been useful to me.
Short Instance Creation: Isn’t it a pain to type Map<String, Object> map=new HashMap<String, Object>(). With Java7 there will be relief and this could look like Map<String, Object> map=new HashMap().
Annotations on Java Types: Annotations will be supported for more syntax element (JSR 308).
Language-level XML: I’m a bit scared about this one. See Mark Reinholds talk at JavaPolis 2006.JavaBean Property Support: Groovy (like other scripting languages) has a very explicit notion of a property expressed by syntactical elements. In the future Java we might see new keywords and we no longer have to select Alt+Shift+S+Generate Setters and Getters… (using my favourite IDE eclipse).
Closures: If you have ever programmed Lisp or Smalltalk (yes I did this) you really miss passing around code as argument to method calls etc. Scripting languages have gained wide popularity due to their simple but expressive syntax – so there is pressure on the Java language to catch up with these.
invokedynamic: In order to better support scripting languages a new byte code instruction invokedynamic (JSR 292) will help that scripting languages will perform much better on the Java platform.
Date / Time API: Probably inspired by the Joda Time project we might see an improved API (JSR 310) for manipulating date and time types.
Units and Quantities: If you are in implementation of business applications you repeatedly have to come up with your own implementations of units, quantities, etc. JSR 275 will address this by considering to include the JScience project.
JMX: JSR 255 defines JMX 2.0 which will feature annotations and remote connectors based on web services
Javadoc: Seems Javadoc has come to age and needs some update (JSR 260).
NIO 2: JSR 203 is going to complete the NIO API that was introduced with Java5.
JSF life-cycle – the trap?
I’m doing quite a lot of JSF demos and prototypes for my consulting and coaching engagements. So (some months ago) I started with a simple framework to speed up things.
One of the classes in this mini-framework is providing a query-by-example style user interaction
- fill in a query form
- perform a query based on the query fields
- show a table with the query matches or show a form if a single row matched
For providing the query result I’m working with a DataModel that is implemented through a property model.
protected DataModel model = new ListDataModel(Collections.EMPTY_LIST);
@Override
public DataModel getModel() {
model.setWrappedData(service.queryByExample(example));
return model;
}
An instance of the class providing the property above is bound as a request scoped managed-bean. Everything is working fine, but as the JSF life-cycle allows a property to be read multiple times as the view is processed. In a simple GET request it would be called once only – during the RENDER_RESPONSE phase. In a post-back it would be called at least during APPLY_REQUEST_VALUES and RENDER_RESPONSE so the database would be hit at least twice.
As I further analyzed this it got clear that the first hit is not returning the right result as the query form attributes have not yet been applied to the bound managed bean properties (this would only happen after the UPDATE_MODEL_VALUES phase).
Only the second query execution returns the desired result.
So I was like this: why not suppress the first query make my database’s life not miserable. Using the beforePhase and afterPhase method binding of the
BUT now my command links for each row were not working anymore.
Hibernate Validator
I have been using Hibernate for quite a number of projects now mostly all of them with JSF for implementing the web interface. I’d always found it boring to do the “form validation thing” – mostly it is look at the constraints in the mapping definition and attach the proper validation tag to a form input element.
So today I had a look at the Hibernate Validator project that promises to make those validation constraints from the model available across all layers of application code. The project provides plenty of annotation types for annotating the domain classes. In general I try not to overuse annotations, especially those for mapping domain attributes to database entities – but this kind of annotations make sense to me!
As you would expect Hibernate Validations integrates with Hibernate core of course and JPA implementations so all of your annotated elements will be validated when persisted.
To perform application level validation a validation API is provided for validating bean instances or single bean properties.
ClassValidator validator = new ClassValidator(Car.class);
InvalidValue[] validationMessages = validator .getInvalidValues(porsche);
InvalidValue[] propertyMessages = validator .getInvalidValues(porsche, "engine");
Overall the API looks fairly slim and simple! In the next days I will investigate if the API allows “nested properties”. I’m thinking of creating some JSF tag (like the Seam tags) to perform validation of complete forms
Maven2 eclipse web tools platform integration
When developing web applications it’s always been a hassle to keep the WEB-INF/lib folder up to date especially when starting to experiment with different versions of libraries or frameworks .
In the past (since being a Maven2 user) I helped myself with issuing the mvn war:inplace command to pull in all required libraries into WEB-INF/lib. So, occasionally I only would update my POM and rerun the command to have the latest versions of jars in my project!
This is extremely handy when using profiles for example to switch dependencies between a set of JSF 1.1 or JSF 1.2 libraries. Only with a twinkle I could change the classpath definition for any project. Ok so far this is nice.
For server development I’m working with the WTP plugin which makes handling a server a bit easier. So, regarding my library dependencies I’d feel more comfortable if they were updated every time I started my server (and thus publish the latest project files to the server).
So, I updated my m2eclipse plugin to 0.0.11 and tried to mark the Maven Dependencies Library Container as a J2EE Dependency, restarted my Web Container and was really excited that finally this is supported now. This means all of my dependencies from pom.xml are actually deployed to the server.
Back to blogging
I haven’t had a lot of blogging activity for a while – simply I have been on vacation and then been fairly busy with catching up with client projects.
But I’m back now and did some maintenance to my blog system:
- Upgrade to WordPress 2.3
- Activated the akismet spam filter – spam just got to intensive and annoying
- Setup permalinks to get nice links to my postings

