In JSF2 there are tons of new and interesting features. Some are big changes and some are really neat small additional things, like the ProjectStage Enum.
Especially for tool-vendors (and component libraries) this is useful to specify the “runtime”. (Development vs. Production vs. SystemTest vs. UnitTest). One example could be the Trinidad Skinning facility. Currently by default we do compression of the generated CSS selectors, but that is a PITA for debugging (even with firebug). However, there is a way around it. Specify the following in your web.xml:
<context-param> <param-name> org.apache.myfaces.trinidad.DISABLE_CONTENT_COMPRESSION </param-name> <param-value>true</param-value> </context-param>
Fine.
Now… with the upcoming JSF2 ProjectStage Enum, we could easily change the Skinning facility to leverage the different possible values. Production, for instance, means compression is on, Development means there is no compression, etc.
However… this means the developer always has to change the WEB.XML (or do some JNDI setup); same is true for Trinidad’s skinning today
The big problem with the ProjectStage is that the JSF spec only talks about web.xml and JNDI for doing the setup configuration. It would be very cool if the specification would be changed to actually allow system props, since that makes our life easier!
One could easily launch a Trinidad application and on the commandline you specify the actual “project stage”:
mvn jetty:run -Djavax.faces.PROJECT_STAGE=Development
That would be great!
UPDATE:
I filed a bug against the spec for this topic.
That would be great indeed. If the spec does not include it, we can always add this in myfaces in the meanwhile
Bruno,
that is true. I thought so, but want to make sure life is easy for all of us…
It is somewhat funny that some (“old school”) is mostly overlooked by almost all Java EE related configurations. Instead … we just the extreme cool XML syntax…
Awesome!
At least your suggestion made it into MyFaces-2.0.0
In MyFaces one can use the system property
org.apache.myfaces.PROJECT_STAGE
LieGrue,
strub
Guess who did that for MyFaces
I’m pretty sure, that system property only accepts the values of the enum or is that more flexible?
Hi Werner!
Take a look at Apache MyFaces CODI ProjectStage if you like to have it more flexible.
It uses an extensible mechanism based on the ServiceLoader mechanism.
http://myfaces.apache.org/extensions/cdi/
https://cwiki.apache.org/confluence/display/EXTCDI/Core+Config+and+SPI
https://svn.apache.org/repos/asf/myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/projectstage/ProjectStage.java
LieGrue,
strub
Just took a brief look, but it sounds interesting. We used similar (the general idea is described in books by people like Josh Bloch for quite a while
Interface on top of a concrete implementation (could be an Enum, too) pattern in a PageFlow equivalent under Eclipse RCP, or for the most recent Unit-API implementation at BT.
Would be cool, if that could make it into CDI 1.1 and used across Java EE 7.
Please feel free to create a JavaEE-7 issue for it – you are the man for it