RE: request scope and forms
nothin to do with bean-magic just pure http. work-arounds: - session - either the form-bean or the vector - Renauds serialized form-bean regards Alexander -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Wednesday, November 14, 2001 6:57 PM To: [EMAIL PROTECTED] Subject: Re: request scope and forms so much for magic beans... Thanks all for your replies! Rob |+-- || Andy Noble| || andy.noble@data-wor| || kshop.com | || | || 14/11/2001 17:35| || Please respond to | || Struts Users | || Mailing List | || | |+-- ---| | | | To: Struts Users Mailing List [EMAIL PROTECTED] | | cc: | | Subject: Re: request scope and forms | | | | | ---| I had this very problem. You want the best of both worlds like I did - the formbean somehow lives between two requests but doesn't clog up memory like a session bean could. I chose the request only option in the end. All the data in the bean gets sent to the client, and a new formbean is created and populated when that form is reposted by the user. In effect, the lifetime of the data is held with the client, rather than the server. The processing cost in terms of creating new formbeans and repopulating them with HTML data is negligible compared with the potential for session beans to clog up the system holding data that may never be reused. Andy - Original Message - From: Rob Breeds [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Wednesday, November 14, 2001 5:12 PM Subject: RE: request scope and forms Robert OK, so even if I forward to a JSP with a form bean in the request, and the JSP displays data from that form bean, as soon as I submit the form again, the original form bean is lost. Hmmm, I was hoping I could somehow keep the forward chain going and Struts would magically keep my ActionForm alive. Thanks Rob Robert Nocera To: 'Struts Users Mailing List' [EMAIL PROTECTED] rnocera@neosl cc: lc.com Subject: RE: request scope and forms 14/11/2001 16:19 Please respond to Struts Users Mailing List If I understood your question correction, you probably want to use a session scope bean. In your case when the JSP is submitted each time a new form bean is created because at that point it is a new request, not a forward. Robert Nocera New England Open Solutions www.neosllc.com You supply the vision, we'll do the rest. -Original Message- From: Rob Breeds [mailto:[EMAIL PROTECTED]] Sent: Wednesday, November 14, 2001 11:03 AM To: Struts Users Mailing List Subject: request scope and forms I'm getting stuck with request scope and ActionForm objects not sticking around across requests. If I have a jsp that has an input text field called name that populates a corresponding field in an ActionForm called name, then that field gets populated. If the Action associated with this ActionForm then takes that name value and adds it a different property in the ActionForm (say to a Vector) and then forwards to the SAME input jsp again, why is it that a new ActionForm object is instantiated every time (according to the log), such that theActionForm never gets more than one String added to the Vector? I was under the impression that if I forwarded, any ActionForm passed to the Action would be persisted in the request. Thanks Rob Breeds -- 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
Re: request scope and forms
Hi Andy, how exactly did you do that? Many thanks in advance twr -Original Message- From : Andy Noble [EMAIL PROTECTED] To : Struts Users Mailing List [EMAIL PROTECTED] Date : 14 November 2001 17:35:49 Subject : Re: request scope and forms I had this very problem. You want the best of both worlds like I did - theformbean somehow lives between two requests but doesn't clog up memory like a session bean could. I chose the request only option in the end. All the data in the bean gets sent to the client, and a new formbean is created and populated when that form is reposted by the user. In effect, the lifetime of the data is held with the client, rather than the server. The processing cost in terms of creating new formbeans and repopulating them with HTML data is negligible compared with the potential for session beans to clog up the system holding data that may never be reused. Andy - Original Message - From: Rob Breeds [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Wednesday, November 14, 2001 5:12 PM Subject: RE: request scope and forms Robert OK, so even if I forward to a JSP with a form bean in the request, and the JSP displays data from that form bean, as soon as I submit the form again, the original form bean is lost. Hmmm, I was hoping I could somehow keep the forward chain going and Struts would magically keep my ActionForm alive. Thanks Rob Robert Nocera To: 'Struts Users Mailing List' [EMAIL PROTECTED] rnocera@neosl cc: lc.com Subject: RE: request scope and forms 14/11/2001 16:19 Please respond to Struts Users Mailing List If I understood your question correction, you probably want to use a session scope bean. In your case when the JSP is submitted each time a new form bean is created because at that point it is a new request, not a forward. Robert Nocera New England Open Solutions www.neosllc.com You supply the vision, we'll do the rest. -Original Message- From: Rob Breeds [mailto:[EMAIL PROTECTED]] Sent: Wednesday, November 14, 2001 11:03 AM To: Struts Users Mailing List Subject: request scope and forms I'm getting stuck with request scope and ActionForm objects not sticking around across requests. If I have a jsp that has an input text field called name that populates a corresponding field in an ActionForm called name, then that field gets populated. If the Action associated with this ActionForm then takes that name value and adds it a different property in the ActionForm (say to a Vector) and then forwards to the SAME input jsp again, why is it that a new ActionForm object is instantiated every time (according to the log), such that theActionForm never gets more than one String added to the Vector? I was under the impression that if I forwarded, any ActionForm passed to the Action would be persisted in the request. Thanks Rob Breeds -- 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] :-) As sceptical as one can be! (-: -- Get a free, personalised email address at http://another.com TXT ALRT! Stop wasting money now. Send FREE, personalised txt from http://another.com -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: request scope and forms
Hi twr, Well, in my original plan (using 'edit record' for example): 1. The user sends a request to edit a record 2. Retrieve data from db, populate ActionForm and store in session 3. Populate HTML form send to user for editing. 4. User edits, makes changes and posts data back 5. Action picks up session scoped ActionForm with original values 6. Compares original with submitted HTML and updates db with differences. The problem was that session scoped objects last for the a timeout period (usually 30 mins) after the session has ended unless explicitly removed from the session which would only happen if the user posted the results back. Potentially, there could be users flipping around the system (lots of forms) without actually changing much, and therefore with many users (500+) the memory could get clogged with session scoped objects that are essentially useless. Instead, I decided to: 1. The user sends a request to edit a record 2. Retrieve data from db, populate ActionForm and store in *request* 3. Populate HTML form send to user for editing BUT INCLUDE DATABASE UNIQUE KEYS (after converting to strings) in hidden form fields. 4. After send to user, the ActionForm goes out of scope and gets cleared up 4. User edits, makes changes, taking as long as he wants and posts data back, or maybe he doesn't 5. If he decides to post changes, Action creates (or reuses) request scoped ActionForm and populates with posted values (after conversion from strings for db keys) 6. Updates db with all values, regardless of whether or not it has changed. (if it was critical to only post changes, I'd have to post original (hidden) and 'user changeable' copies of data in HTML and compare when posted back. Here, rather than storing data in my servers memory, I store it in the client's HTML form - if they never post it back who cares? The downside I guess is that there is a little extra processing on the server having to create a request scoped bean every time (I suspect very tiny as we're only creating one object here), and a little bit more hassle for the programmer. Regards Andy - Original Message - From: [EMAIL PROTECTED] To: struts users mailing list [EMAIL PROTECTED] Sent: Thursday, November 15, 2001 7:55 AM Subject: Re: request scope and forms Hi Andy, how exactly did you do that? Many thanks in advance twr -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: request scope and forms
If I understood your question correction, you probably want to use a session scope bean. In your case when the JSP is submitted each time a new form bean is created because at that point it is a new request, not a forward. Robert Nocera New England Open Solutions www.neosllc.com You supply the vision, we'll do the rest. -Original Message- From: Rob Breeds [mailto:[EMAIL PROTECTED]] Sent: Wednesday, November 14, 2001 11:03 AM To: Struts Users Mailing List Subject: request scope and forms I'm getting stuck with request scope and ActionForm objects not sticking around across requests. If I have a jsp that has an input text field called name that populates a corresponding field in an ActionForm called name, then that field gets populated. If the Action associated with this ActionForm then takes that name value and adds it a different property in the ActionForm (say to a Vector) and then forwards to the SAME input jsp again, why is it that a new ActionForm object is instantiated every time (according to the log), such that theActionForm never gets more than one String added to the Vector? I was under the impression that if I forwarded, any ActionForm passed to the Action would be persisted in the request. Thanks Rob Breeds -- 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]
RE: request scope and forms
Robert OK, so even if I forward to a JSP with a form bean in the request, and the JSP displays data from that form bean, as soon as I submit the form again, the original form bean is lost. Hmmm, I was hoping I could somehow keep the forward chain going and Struts would magically keep my ActionForm alive. Thanks Rob Robert Nocera To: 'Struts Users Mailing List' [EMAIL PROTECTED] rnocera@neosl cc: lc.com Subject: RE: request scope and forms 14/11/2001 16:19 Please respond to Struts Users Mailing List If I understood your question correction, you probably want to use a session scope bean. In your case when the JSP is submitted each time a new form bean is created because at that point it is a new request, not a forward. Robert Nocera New England Open Solutions www.neosllc.com You supply the vision, we'll do the rest. -Original Message- From: Rob Breeds [mailto:[EMAIL PROTECTED]] Sent: Wednesday, November 14, 2001 11:03 AM To: Struts Users Mailing List Subject: request scope and forms I'm getting stuck with request scope and ActionForm objects not sticking around across requests. If I have a jsp that has an input text field called name that populates a corresponding field in an ActionForm called name, then that field gets populated. If the Action associated with this ActionForm then takes that name value and adds it a different property in the ActionForm (say to a Vector) and then forwards to the SAME input jsp again, why is it that a new ActionForm object is instantiated every time (according to the log), such that theActionForm never gets more than one String added to the Vector? I was under the impression that if I forwarded, any ActionForm passed to the Action would be persisted in the request. Thanks Rob Breeds -- 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]
Re: request scope and forms
Don't know if I understood the question, but i think you should specify the scope for your action form : in the sturts-config.xml, change the scope=request to scope=session (in the Action Mappings Definitions). Hope it helps - just don't forget to remove it from your session From: Rob Breeds [EMAIL PROTECTED] Robert OK, so even if I forward to a JSP with a form bean in the request, and the JSP displays data from that form bean, as soon as I submit the form again, the original form bean is lost. Hmmm, I was hoping I could somehow keep the forward chain going and Struts would magically keep my ActionForm alive. Thanks Rob -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: request scope and forms
I had this very problem. You want the best of both worlds like I did - the formbean somehow lives between two requests but doesn't clog up memory like a session bean could. I chose the request only option in the end. All the data in the bean gets sent to the client, and a new formbean is created and populated when that form is reposted by the user. In effect, the lifetime of the data is held with the client, rather than the server. The processing cost in terms of creating new formbeans and repopulating them with HTML data is negligible compared with the potential for session beans to clog up the system holding data that may never be reused. Andy - Original Message - From: Rob Breeds [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Wednesday, November 14, 2001 5:12 PM Subject: RE: request scope and forms Robert OK, so even if I forward to a JSP with a form bean in the request, and the JSP displays data from that form bean, as soon as I submit the form again, the original form bean is lost. Hmmm, I was hoping I could somehow keep the forward chain going and Struts would magically keep my ActionForm alive. Thanks Rob Robert Nocera To: 'Struts Users Mailing List' [EMAIL PROTECTED] rnocera@neosl cc: lc.com Subject: RE: request scope and forms 14/11/2001 16:19 Please respond to Struts Users Mailing List If I understood your question correction, you probably want to use a session scope bean. In your case when the JSP is submitted each time a new form bean is created because at that point it is a new request, not a forward. Robert Nocera New England Open Solutions www.neosllc.com You supply the vision, we'll do the rest. -Original Message- From: Rob Breeds [mailto:[EMAIL PROTECTED]] Sent: Wednesday, November 14, 2001 11:03 AM To: Struts Users Mailing List Subject: request scope and forms I'm getting stuck with request scope and ActionForm objects not sticking around across requests. If I have a jsp that has an input text field called name that populates a corresponding field in an ActionForm called name, then that field gets populated. If the Action associated with this ActionForm then takes that name value and adds it a different property in the ActionForm (say to a Vector) and then forwards to the SAME input jsp again, why is it that a new ActionForm object is instantiated every time (according to the log), such that theActionForm never gets more than one String added to the Vector? I was under the impression that if I forwarded, any ActionForm passed to the Action would be persisted in the request. Thanks Rob Breeds -- 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]