RE: Don't want the ActionForm to refill my form.
Hi, Aren't form beans reused ? I thought only the reset is called. Thanks, Mohan -Original Message- From: Karr, David [mailto:david.karr;attws.com] Sent: Tuesday, November 05, 2002 9:38 PM To: Struts Users Mailing List Subject: RE: Don't want the ActionForm to refill my form. Is your action scope set to session or request? I would guess it's set to session. I believe if you set it to request, your form bean will be created on each request. -Original Message- From: Marcus Biel [mailto:Marcus.Biel;bmw.de] Sent: Tuesday, November 05, 2002 6:25 AM To: [EMAIL PROTECTED] Subject: Don't want the ActionForm to refill my form. I want to add data records using a jsp. When the user entered the data, and hits submit, an actions adds the data record to the database. When this is done, it forwards to the same page again, so that the user can add more data records. The problem is that the form gets filled by the ActionForm again, when forwarding. That's a bit confusing for a user who simply wants to add new data, but he gets shown the old data he just entered. Any ideas how to prevent the Actionform from refilling the form on the jsp ? thx, marcus -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
RE: Don't want the ActionForm to refill my form.
Re-initialize the form-bean to the way it was when the page was first invoked. If form was all blank fields, you can simply delete the form bean; it'll get re-created. Sri -Original Message- From: Marcus Biel [mailto:Marcus.Biel;bmw.de] Sent: Tuesday, November 05, 2002 9:25 AM To: [EMAIL PROTECTED] Subject: Don't want the ActionForm to refill my form. I want to add data records using a jsp. When the user entered the data, and hits submit, an actions adds the data record to the database. When this is done, it forwards to the same page again, so that the user can add more data records. The problem is that the form gets filled by the ActionForm again, when forwarding. That's a bit confusing for a user who simply wants to add new data, but he gets shown the old data he just entered. Any ideas how to prevent the Actionform from refilling the form on the jsp ? thx, marcus -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
RE: Don't want the ActionForm to refill my form.
Redirect instead of forward. You can do this in your struts-config.xml file for your action by setting the redirect attribute of the forward element to true; or, if you are manually creating the forward, the constructor takes a boolean which indicates a redirect instead of a forward. robert -Original Message- From: Marcus Biel [mailto:Marcus.Biel;bmw.de] Sent: Tuesday, November 05, 2002 9:25 AM To: [EMAIL PROTECTED] Subject: Don't want the ActionForm to refill my form. I want to add data records using a jsp. When the user entered the data, and hits submit, an actions adds the data record to the database. When this is done, it forwards to the same page again, so that the user can add more data records. The problem is that the form gets filled by the ActionForm again, when forwarding. That's a bit confusing for a user who simply wants to add new data, but he gets shown the old data he just entered. Any ideas how to prevent the Actionform from refilling the form on the jsp ? thx, marcus -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
RE: Don't want the ActionForm to refill my form.
Sri Sankaran wrote: you can simply delete the form bean; it'll get re-created. Can you clarify? You say the form been will get re-created, yet I have this code in my Action: if ( form == null ) { form = (ActionForm) session.getAttribute( contactForm ); if ( form == null ) { form = new ContactForm(); } if ( request.equals( mapping.getScope() ) ) { request.setAttribute( mapping.getAttribute(), form ); } else { session.setAttribute( mapping.getAttribute(), form ); } } This came straight from EditSubscriptionAction in the struts-example webapp. It doesn't look to me like the form bean gets re-created, it looks like I have to do it myself. Am I missing something? Thanks! -- Wendy Smoak http://sourceforge.net/projects/unidbtags
RE: Don't want the ActionForm to refill my form.
When a request is submitted, the ActionServlet matches the request URI against the known action mappings. If there is an associated form-bean then it'll look for an ActionForm with the given name. If one isn't found, it will be created. Sri -Original Message- From: Wendy Smoak [mailto:Wendy.Smoak;asu.edu] Sent: Tuesday, November 05, 2002 9:41 AM To: 'Struts Users Mailing List' Subject: RE: Don't want the ActionForm to refill my form. Sri Sankaran wrote: you can simply delete the form bean; it'll get re-created. Can you clarify? You say the form been will get re-created, yet I have this code in my Action: if ( form == null ) { form = (ActionForm) session.getAttribute( contactForm ); if ( form == null ) { form = new ContactForm(); } if ( request.equals( mapping.getScope() ) ) { request.setAttribute( mapping.getAttribute(), form ); } else { session.setAttribute( mapping.getAttribute(), form ); } } This came straight from EditSubscriptionAction in the struts-example webapp. It doesn't look to me like the form bean gets re-created, it looks like I have to do it myself. Am I missing something? Thanks! -- Wendy Smoak http://sourceforge.net/projects/unidbtags -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
RE: Don't want the ActionForm to refill my form.
Is your action scope set to session or request? I would guess it's set to session. I believe if you set it to request, your form bean will be created on each request. -Original Message- From: Marcus Biel [mailto:Marcus.Biel;bmw.de] Sent: Tuesday, November 05, 2002 6:25 AM To: [EMAIL PROTECTED] Subject: Don't want the ActionForm to refill my form. I want to add data records using a jsp. When the user entered the data, and hits submit, an actions adds the data record to the database. When this is done, it forwards to the same page again, so that the user can add more data records. The problem is that the form gets filled by the ActionForm again, when forwarding. That's a bit confusing for a user who simply wants to add new data, but he gets shown the old data he just entered. Any ideas how to prevent the Actionform from refilling the form on the jsp ? thx, marcus -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org