THANX A LOT Joe !!! :) All my problems with session scope beans are now resolved :)
So what was exactly the problem ? (it could be usefull to others, I guess) Well, to instantiate my beans, I always put the following line in my jsp files: <jsp:useBean id="xxxform" scope="session" class="XxxForm"/> But, as Joe wrote : >This is just a shot in the dark...but perhaps the explicit creation you >are specifying by the <jsp:useBean> tag is screwing up Strut's management of >the ActionForm bean? In any case, you don't need to use the <jsp:useBean> >tag at all for ActionForm beans, as Struts takes care of instantiating, And indeed, that seemed to be the main problem ! So, thanx again Joe, for your patience and all your help :) Friendly Regards, Slimane PS: pfiou, I'm happy that problem is finally resolved :) At 02:27 16/03/2002 +0100, Someone poor demented soul by the name of "Slimane" presented us with the following text which may contain useless information. >okay, thanx a lot for your help :) > >I'll try the second method tomorrow (now it's 2am and I'm feeling sleepy :) > >Friendly Regards, >Slimane > >At 17:02 15/03/2002 -0800, Someone poor demented soul by the name of >"Joseph Barefoot" presented us with the following text which may contain >useless information. >>Yep, that's what I meant, mis-type on my part there. hmmm...so you want 3 >>ActionForm beans to be instantiated when a single Action is delegated to, >>but don't want to use nested forms? >> >>Okay, you can do this two (maybe more) ways: >> >>1. You could chain your actionforwards such that the Action called forwards >>to a second Action, the second Action forwards to a 3rd, etc., and thus your >>ActionForms get instantiated. The final Action in the chain then forwards >>to whatever page you wanted the user to see. >> >>2. The Action (call it Action A) that is called when it's associated URI is >>requested explicitly creates whatever ActionForms you want and initializes >>them with setXXX methods. Then Action A places these form beans into the >>HTTPRequest object as attributes with the SAME NAME that struts would use >>for the attribute, i.e. the logical name specified in the action-mapping for >>the form bean. Then, when subsequent URI's are requested associated with >>other Actions, if Struts finds that an attribute with the associated (with >>the particular Action) form bean's logical name already exists, it will use >>that object rather than instantiating a new one (I'm pretty sure that's how >>it works). The only drawback is that you would have to make sure that >>Action A's URI is requested BEFORE the other Actions' URIs, so that your >>logic will initialize and store the ActionForm beans rather than the Struts >>framework. >> >>whew. I don't know if that helps, but it's the best I could come up with >>based on what I know about Struts. :) >> >>A final consideration: Is is possible that 2 of the 3 beans don't need to >>be ActionForm beans at all, but just value objects that are created and >>stored in the session? >> >> >>-----Original Message----- >>From: Slimane [mailto:[EMAIL PROTECTED]] >>Sent: Friday, March 15, 2002 3:49 PM >>To: Struts Users Mailing List >>Subject: RE: problem with bean having session scope >> >> >>Hi, >> >>Thanx again for your answer :) >> >>The problem is that I don't want to nest my ActionForm, I want them all >>treated as a unique session bean. Without them being into (dependant of) >>another ActionForm. >> >> >so you can retrieve them from other Actions/JSPs by >> >using request.getAttribute( <ActionForm logical name> ). >> >>I suppose you meant request.getSession().getAttribute( <ActionForm logical >>name> ), didn't you ? :) >> >>Friendly Regards, >>Slimane >> >>At 15:12 15/03/2002 -0800, Someone poor demented soul by the name of >>"Joseph Barefoot" presented us with the following text which may contain >>useless information. >> >Valid questions, all. :) I have to admit I'm not 100% sure when the >> >ActionForm bean is first instantiated/initialized, but this is what I >>think: >> >The ActionForm bean is created and initialized when the URI specified by >>the >> >action-mapping for this particular Action/ActionForm pair is requested. >> >(if this is incorrect, please someone correct me) >> > >> >If you want to share beans, just declare the scope to be "session" for the >> >bean in question in the action-mapping for this action inside >> >struts-config.xml. Struts stores these beans as attributes in the >> >HTTPSession object, so you can retrieve them from other Actions/JSPs by >> >using request.getAttribute( <ActionForm logical name> ). >> > >> >As for the last question, ActionForm beans can appear as fields inside >>other >> >ActionForms, so you can nest your form beans such that when one gets >> >instantiated, all of the nested form fields get instantiated too. Then you >> >can reference them as nested attributes of the parent ActionForm inside any >> >of your Struts JSP tags. You can also retrieve them from the session in a >> >similar manner: >> > >> >request.getAttribute( <ActionForm logical name> ).getMyNestedForm() >> > >> >happy coding, >> > >> >Joe >> > >> >-----Original Message----- >> >From: Slimane [mailto:[EMAIL PROTECTED]] >> >Sent: Friday, March 15, 2002 1:58 PM >> >To: Struts Users Mailing List >> >Subject: RE: problem with bean having session scope >> > >> > >> >Hi, >> > >> >Thanks for your answer, I'll try to remove the <jsp:useBean> tag. >> > >> >But I still do have a question :) You say that: >> > >Struts takes care of instantiating, >> > >read/writes, and scope management for these beans >> > >> >well, then when does he do that ? The first time I call the Action Class ? >> >If so, what if I want to share 3 beans ? The first time I'll call one >> >Action Class, only one ActionForm will be instanciated, no ? >> > >> >Friendly Regards, >> >Slimane >> > >> >At 10:03 15/03/2002 -0800, Someone poor demented soul by the name of >> >"Joseph Barefoot" presented us with the following text which may contain >> >useless information. >> > > > > I suppose the form bean is created the first time I use a >>jsp:useBean >> > >tag >> > > > > in my jsp file, isn't it ? >> > > > > >> > > > > (for example: <jsp:useBean id="searchbydateform" scope="session" >> > > > > class="be.stluc.info.struts.SearchByDateForm"/>) >> > > >> > >Actually, the creation of the ActionForm bean is handled by the Struts >> > >framework itself (I guess by the controller servlet?). That's how forms >> >can >> > >be populated "automatically" via the Struts taglibs and then passed to >>the >> > >Action class associated with this particular ActionForm class. >> > > >> > >This is just a shot in the dark...but perhaps the explicit creation you >>are >> > >specifying by the <jsp:useBean> tag is screwing up Strut's management of >> >the >> > >ActionForm bean? In any case, you don't need to use the <jsp:useBean> >>tag >> > >at all for ActionForm beans, as Struts takes care of instantiating, >> > >read/writes, and scope management for these beans. >> > > >> > > >> > >--joe >> > > >> > >-----Original Message----- >> > >From: Slimane Zouggari [mailto:[EMAIL PROTECTED]] >> > >Sent: Friday, March 15, 2002 9:15 AM >> > >To: Struts Users Mailing List >> > >Subject: Re: problem with bean having session scope >> > > >> > > >> > >Thanx, I supposed it was something like that :) >> > >The thing is, I still don't understand why my beans aren't shared among >>all >> > >of my action classes :( >> > > >> > >Friendly Regards, >> > >Slimane >> > > >> > >At 12:05 15/03/2002 -0500, you wrote: >> > > >AFAIK, a session bean is destroyed when the session expires (30 min by >> > > >default). >> > > > >> > > >Otavio >> > > > >> > > >----- Original Message ----- >> > > >From: "Slimane Zouggari" <[EMAIL PROTECTED]> >> > > >To: "Struts Users Mailing List" <[EMAIL PROTECTED]> >> > > >Sent: Friday, March 15, 2002 12:02 PM >> > > >Subject: Re: problem with bean having session scope >> > > > >> > > > >> > > > > well as nobody seems to have a clue about my problem. I'll ask my >> > >question >> > > > > differently :) >> > > > > >> > > > > When is a session bean destroyed ? >> > > > > If I specify, a form bean to have a session scope (as I did in the >> > > > > struts-config.xml), when will it be destroyed ? >> > > > > >> > > > > I suppose the form bean is created the first time I use a >>jsp:useBean >> > >tag >> > > > > in my jsp file, isn't it ? >> > > > > >> > > > > (for example: <jsp:useBean id="searchbydateform" scope="session" >> > > > > class="be.stluc.info.struts.SearchByDateForm"/>) >> > > > > >> > > > > Finally, what could be the reasons, that some of my Action classes >>see >> > > >(can >> > > > > use their values) some session beans, while others don't ? >> > > > > >> > > > > Thanx for having taken the time to read me :) >> > > > > >> > > > > Friendly Regards, >> > > > > Slimane >> > > > > >> > > > > At 12:11 15/03/2002 +0100, you wrote: >> > > > > >Hi, >> > > > > > >> > > > > >I have 3 form beans. Each of them have a session scope defined in >>the >> > > > > >struts-config.xml. >> > > > > > >> > > > > >Here's the config for one of them: >> > > > > >> <action path="/piechart" >> > > > > >> type="be.stluc.info.struts.PieChartAction" >> > > > > >> name="piechartform" >> > > > > >> scope="session"> >> > > > > > >> > > > > >When I try to access them in one of my Action class, I don't have >>any >> > > >problem. >> > > > > >But when I try to access them, from one other Action class, then >> > > >suddenly, >> > > > > >they don't exist anymore. >> > > > > > >> > > > > >I used the piece of code, Mr Keith Bacon posted in reply of one of >>my >> > > > > >previous mail ( >> > > > > >> > > > >> > > >> > >> >http://www.mail-archive.com/struts-user@jakarta.apache.org/msg25984.html ) >> > > > > > >> > > > > >And that so, I saw that one time, my session contains all three >>form >> > > >beans >> > > > > >and another time my session contains only one form bean. >> > > > > > >> > > > > >Here's the code I use in my Action classes: >> > > > > > >> > > > > >> ParticipantDetailsForm partDetForm = >> > > > > >> (ParticipantDetailsForm) >> > > > > >> request.getSession().getAttribute("participantdetailsform"); >> > > > > > >> > > > > >(participantdetailsform is one of the 3 form beans I share in the >> > > >session) >> > > > > > >> > > > > >Could anyone give me pointers where I should look for ? Because, >>I'm >> > >sure >> > > > > >it's a stupid mistake but I can't find it :( >> > > > > > >> > > > > >Thanx in advance. >> > > > > > >> > > > > >Friendly Regards, >> > > > > >Slimane >> > > > > > >> > > > > > >> > > > > >-- >> > > > > >To unsubscribe, e-mail: >> > > ><mailto:[EMAIL PROTECTED]> >> > > > > >For additional commands, e-mail: >> > > ><mailto:[EMAIL PROTECTED]> >> > > > > >> > > > > >> > > > > -- >> > > > > To unsubscribe, e-mail: >> > > ><mailto:[EMAIL PROTECTED]> >> > > > > For additional commands, e-mail: >> > > ><mailto:[EMAIL PROTECTED]> >> > > > > >> > > > >> > > > >> > > >-- >> > > >To unsubscribe, e-mail: >> > ><mailto:[EMAIL PROTECTED]> >> > > >For additional commands, e-mail: >> > ><mailto:[EMAIL PROTECTED]> >> > > >> > > >> > >-- >> > >To unsubscribe, e-mail: >> > ><mailto:[EMAIL PROTECTED]> >> > >For additional commands, e-mail: >> > ><mailto:[EMAIL PROTECTED]> >> > > >> > > >> > >-- >> > >To unsubscribe, e-mail: >> ><mailto:[EMAIL PROTECTED]> >> > >For additional commands, e-mail: >> ><mailto:[EMAIL PROTECTED]> >> > >> > >> >-- >> >Make it run, Make it right, Make it fast >> > >> > >> >-- >> >To unsubscribe, e-mail: >> ><mailto:[EMAIL PROTECTED]> >> >For additional commands, e-mail: >> ><mailto:[EMAIL PROTECTED]> >> > >> > >> >-- >> >To unsubscribe, e-mail: >><mailto:[EMAIL PROTECTED]> >> >For additional commands, e-mail: >><mailto:[EMAIL PROTECTED]> >> >> >>-- >>Make it run, Make it right, Make it fast >> >> >>-- >>To unsubscribe, e-mail: >><mailto:[EMAIL PROTECTED]> >>For additional commands, e-mail: >><mailto:[EMAIL PROTECTED]> >> >> >>-- >>To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> >>For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > >-- >Make it run, Make it right, Make it fast > > >-- >To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> >For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > -- Make it run, Make it right, Make it fast -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>