webtier@glassfish.java.net

Re: Where to put one-time executed code on JSF page load

From: <webtier_at_javadesktop.org>
Date: Thu, 18 Mar 2010 05:59:24 PDT

In http://java.sun.com/javaee/javaserverfaces/2.0/docs/pdldocs/facelets/f/event.html is also stated, that the event attribute is named "name" and not "type".

The term "one-time executed code" is ambiguous and depends on the context where the code should be executed:

If you want to execute code before rendering a particular page I would call this pattern "page controller". In this case the above mentioned approach should be fine.

If you want to execute code before rendering any page, a servlet filter or phase listener should do it's work.

If you want to execute code to initialize the state of something stateful (like a controller e.g.), which does not depends on external parameters like request params or on which page the controller is used, an initalizer method sound quite fine to me.
[Message sent by forum member 'tzwoenn']

http://forums.java.net/jive/thread.jspa?messageID=392561