atom feed39 messages in org.apache.myfaces.usersRe: best way to initialize BackingBean?
FromSent OnAttachments
Stefan GesigoraAug 31, 2005 1:53 am 
Martin MarinschekAug 31, 2005 2:12 am 
Stefan GesigoraAug 31, 2005 2:20 am 
Stefan GesigoraAug 31, 2005 3:38 am 
Enrique MedinaAug 31, 2005 3:43 am 
Guy KatzAug 31, 2005 3:53 am 
Stefan GesigoraAug 31, 2005 4:00 am 
MuraliAug 31, 2005 4:19 am 
MuraliAug 31, 2005 4:43 am 
Jeff CooperAug 31, 2005 5:13 am 
Sean SchofieldAug 31, 2005 5:34 am 
Werner PunzAug 31, 2005 5:37 am 
hicham abassiAug 31, 2005 6:21 am 
Sean SchofieldAug 31, 2005 6:23 am 
hicham abassiAug 31, 2005 6:29 am 
Sean SchofieldAug 31, 2005 6:30 am 
Gary VanMatreAug 31, 2005 7:59 am 
Mike KienenbergerAug 31, 2005 10:57 am 
Ken WeinerAug 31, 2005 10:59 am 
Mike KienenbergerAug 31, 2005 11:13 am 
Craig McClanahanAug 31, 2005 11:25 am 
Mike KienenbergerAug 31, 2005 11:39 am 
Denn...@ak.blm.govAug 31, 2005 11:51 am 
Ken WeinerAug 31, 2005 11:54 am 
Craig McClanahanAug 31, 2005 12:25 pm 
Mike KienenbergerAug 31, 2005 12:34 pm 
Craig McClanahanAug 31, 2005 12:40 pm 
Craig McClanahanAug 31, 2005 12:51 pm 
Mike KienenbergerAug 31, 2005 1:07 pm 
Martin MarinschekAug 31, 2005 1:47 pm 
Mike KienenbergerSep 1, 2005 8:01 am 
Martin MarinschekSep 1, 2005 8:43 am 
Mike KienenbergerSep 1, 2005 8:50 am 
Martin MarinschekSep 1, 2005 9:06 am 
Mike KienenbergerSep 1, 2005 9:21 am 
Martin MarinschekSep 1, 2005 9:54 am 
CONNER, BRENDAN (SBCSI)Sep 2, 2005 5:59 pm 
Craig McClanahanSep 2, 2005 9:25 pm 
hicham abassiSep 6, 2005 12:15 pm 
Subject:Re: best way to initialize BackingBean?
From:hicham abassi (haba@gmail.com)
Date:Sep 6, 2005 12:15:09 pm
List:org.apache.myfaces.users

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 haba@gmail.com

2005/9/3, Craig McClanahan <crai@gmail.com>:

On 9/2/05, CONNER, BRENDAN (SBCSI) <bc1@sbc.com> 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