JSF 2: ProjectStage only half-baked

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.

About these ads

Howdy!

Posted in jsf, myfaces, trinidad
8 comments on “JSF 2: ProjectStage only half-baked
  1. baranda says:

    That would be great indeed. If the spec does not include it, we can always add this in myfaces in the meanwhile ;)

  2. matthiaswessendorf says:

    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! ;-)

  3. struberg says:

    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

  4. matthiaswessendorf says:

    Guess who did that for MyFaces ;-)

  5. Werner Keil says:

    I’m pretty sure, that system property only accepts the values of the enum or is that more flexible?

  6. struberg says:

    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

  7. 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.

  8. struberg says:

    Please feel free to create a JavaEE-7 issue for it – you are the man for it :)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 33 other followers

%d bloggers like this: