Extract from the supar good book Core JSF (thanks for advices)

p.626 How do i carry out initialization or cleanup work ?

You have several choices, depending on the timing of your tasks.

* To manage application scope objects, attache a
ServletContextListener. Implement the contextInitialized and
contextDestroyed methods. Add the listener class to the web.xml file
like this :
   <listener>
     <listener-class>mypackage.MyListener</listener-class>
   </listener>

* To manage session scope objects, attach an HttpSessionListener.
Implement the sessionCreated and sessionDestroyed methods. Add the
listener class to the web.xml as in the preceding case

* To manage request scope objects, attach a PhaseListener. You can
initialize objects in the beforePhase method when the Phase ID is
APPLY_REQUEST_VALUES . You can clean up in the afterPhase method when
the phase ID is RENDER_RESPONSE


--
hicham ABASSI
[EMAIL PROTECTED]





2005/9/3, Craig McClanahan <[EMAIL PROTECTED]>:
> 
> 
> On 9/2/05, CONNER, BRENDAN (SBCSI) <[EMAIL PROTECTED]> wrote:
> > I went to the link you gave, but I got a "page not found" error.  Is
> > that link still valid?
> 
>  
>  Hmm ... the following link works just fine for me:
>  
>    http://struts.apache.org/shale/
>   
>  Even if that doesn't work, nightly builds are available at:
>  
>   
> http://cvs.apache.org/builds/struts/nightly/struts-shale/
>  
>  
> > And, I know I'm missing something here, but don't most people initialize
> > their backing beans just by using lazy fetches on their getters?  Either 
> > that, of course, or having some action initialize them?
> 
>  That is certainly a common technique for things cached at application or
> session scope ... for things needed just for the current request, it's a
> little more convenient (and maintainable) to deliberately acquire all the
> data you need for the current renderng -- which will possibly depend on
> dynamic state information from the current request.
>  
>  The other thing that makes this approach attractive is you don't have to
> have as deep an understanding of what a "getter" does, or the fact that it
> might be called more than once.  This makes Java and JSF more accessible to
> people coming from other programming environments that do not emphasize the
> object orientedness that we all know and love about the language itself.
>   
> > I'll definitely look into shale, though.  It sounds interesting.
>  
>  Try it, you'll like it :-).
>   
> > - Brendan
> 
>  Craig
>  
>  


-- 

hicham ABASSI
[EMAIL PROTECTED]

Reply via email to