Re: Form Submission Question
Patches are always welcome (once you get it figured out) :) On Nov 15, 2007 2:22 PM, Hernandez, David <[EMAIL PROTECTED]> wrote: > > Thanks guys. The bootstrap should have an example where the fields are > populated by the Action Class's member variables. But I figured it out, > I think . . . - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Form Submission Question
Just to further Dave is saying. If the class is a proper JavaBean with a zero-argument constructor, if it is null during autopopulation, then the framework will automatically instantiate it. For fancier implementations, we can even provide a custom type converter for a class, that could do something like lookup a complete City record from a database based on the ID. * http://struts.apache.org/2.x/docs/type-conversion.html HTH, Ted. On Nov 15, 2007 5:15 PM, Dave Newton <[EMAIL PROTECTED]> wrote: > Or you can put the city.id in the form as a hidden > field. > > d. > > --- "Hernandez, David" <[EMAIL PROTECTED]> > wrote: > > > > > > Sorry, The problem was that building has a member > > variable that is a > > class (City) which is going out of scope. > > Building.toString() calls > > city.getId() throwing the exception and returning > > null . . . > > Now, to keep that in scope somehow . . . > > > > -Original Message- > > From: Hernandez, David > > Sent: Thursday, November 15, 2007 3:12 PM > > To: 'Struts Users Mailing List' > > Subject: RE: Form Submission Question > > > > I'm having a problem with my bean going out of > > scope. The form is > > populated with the bean information fine, but when I > > submit building is > > null? How do I keep it in scope? Do I have to pull > > it back out of the > > ActionContext? > > > > public class BuildingFormTestAction extends > > ActionSupport { > > private static final long serialVersionUID = > > 6692492667406189130L; > > private Building building; > > public String init() throws Exception > > { > > //Fetch Building from db . . . > > return ActionSupport.SUCCESS; > > } > > public String execute() throws Exception > > { > > System.out.println("Submitting: "); > > System.out.println(building);//PRINTS NULL! > > return ActionSupport.SUCCESS; > > } > > public void setBuilding(Building b) > > { > > building = b; > > } > > public Building getBuilding() > > { > > return building; > > } > > } > > > > Here's the JSP Form: > > > > > > > >> /> > > > > > > > > > > > > > > > > > > And Struts.xml exerpt: > > > method="init"> > > /buildingFormTest.jsp > > /error.jsp > > > name="setBuilding" class="BuildingFormTestAction" > > method="execute"> > > /buildingFormTest.jsp > > /error.jsp > > > > -Original Message- > > From: Dave Newton [mailto:[EMAIL PROTECTED] > > Sent: Thursday, November 15, 2007 2:20 PM > > To: Struts Users Mailing List > > Subject: Re: Form Submission Question > > > > --- Gary Affonso <[EMAIL PROTECTED]> wrote: > > > Dave Newton wrote: > > >> The action that *processes* the form submission > > may extend > > >> ActionSupport. > > > > > > Dave knows that, of course, but I didn't want the > > emphasis on > > > "*processes*" above to make you think > > ActionSupport was only > > > appropriate for form processing actions. > > > > Yep, that was a good clarificaton to make :) > > > > d. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Form Submission Question
Sorry, The problem was that building has a member variable that is a class (City) which is going out of scope. Building.toString() calls city.getId() throwing the exception and returning null . . . Now, to keep that in scope somehow . . . -Original Message- From: Hernandez, David Sent: Thursday, November 15, 2007 3:12 PM To: 'Struts Users Mailing List' Subject: RE: Form Submission Question I'm having a problem with my bean going out of scope. The form is populated with the bean information fine, but when I submit building is null? How do I keep it in scope? Do I have to pull it back out of the ActionContext? public class BuildingFormTestAction extends ActionSupport { private static final long serialVersionUID = 6692492667406189130L; private Building building; public String init() throws Exception { //Fetch Building from db . . . return ActionSupport.SUCCESS; } public String execute() throws Exception { System.out.println("Submitting: "); System.out.println(building);//PRINTS NULL! return ActionSupport.SUCCESS; } public void setBuilding(Building b) { building = b; } public Building getBuilding() { return building; } } Here's the JSP Form: And Struts.xml exerpt: /buildingFormTest.jsp /error.jsp /buildingFormTest.jsp /error.jsp -Original Message- From: Dave Newton [mailto:[EMAIL PROTECTED] Sent: Thursday, November 15, 2007 2:20 PM To: Struts Users Mailing List Subject: Re: Form Submission Question --- Gary Affonso <[EMAIL PROTECTED]> wrote: > Dave Newton wrote: >> The action that *processes* the form submission may extend >> ActionSupport. > > Dave knows that, of course, but I didn't want the emphasis on > "*processes*" above to make you think ActionSupport was only > appropriate for form processing actions. Yep, that was a good clarificaton to make :) d. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice. IRS Circular 230 Disclosure: Please be advised that any discussion of U.S. tax matters contained within this communication (including any attachments) is not intended or written to be used and cannot be used for the purpose of (i) avoiding U.S. tax related penalties or (ii) promoting, marketing or recommending to another party any transaction or matter addressed herein. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Form Submission Question
Or you can put the city.id in the form as a hidden field. d. --- "Hernandez, David" <[EMAIL PROTECTED]> wrote: > > Sorry, The problem was that building has a member > variable that is a > class (City) which is going out of scope. > Building.toString() calls > city.getId() throwing the exception and returning > null . . . > Now, to keep that in scope somehow . . . > > -Original Message- > From: Hernandez, David > Sent: Thursday, November 15, 2007 3:12 PM > To: 'Struts Users Mailing List' > Subject: RE: Form Submission Question > > I'm having a problem with my bean going out of > scope. The form is > populated with the bean information fine, but when I > submit building is > null? How do I keep it in scope? Do I have to pull > it back out of the > ActionContext? > > public class BuildingFormTestAction extends > ActionSupport { > private static final long serialVersionUID = > 6692492667406189130L; > private Building building; > public String init() throws Exception > { > //Fetch Building from db . . . > return ActionSupport.SUCCESS; > } > public String execute() throws Exception > { > System.out.println("Submitting: "); > System.out.println(building);//PRINTS NULL! > return ActionSupport.SUCCESS; > } > public void setBuilding(Building b) > { > building = b; > } > public Building getBuilding() > { > return building; > } > } > > Here's the JSP Form: > > > >/> > > > > > > > > > And Struts.xml exerpt: > method="init"> > /buildingFormTest.jsp > /error.jsp > name="setBuilding" class="BuildingFormTestAction" > method="execute"> > /buildingFormTest.jsp > /error.jsp > > -Original Message- > From: Dave Newton [mailto:[EMAIL PROTECTED] > Sent: Thursday, November 15, 2007 2:20 PM > To: Struts Users Mailing List > Subject: Re: Form Submission Question > > --- Gary Affonso <[EMAIL PROTECTED]> wrote: > > Dave Newton wrote: > >> The action that *processes* the form submission > may extend > >> ActionSupport. > > > > Dave knows that, of course, but I didn't want the > emphasis on > > "*processes*" above to make you think > ActionSupport was only > > appropriate for form processing actions. > > Yep, that was a good clarificaton to make :) > > d. > > > - > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > > - - - - - - - - - - - - - - - - - - - - - - - - - - > - - - - - - - - - - - - - - - - - - > > This message is intended only for the personal and > confidential use of the designated recipient(s) > named above. If you are not the intended recipient > of this message you are hereby notified that any > review, dissemination, distribution or copying of > this message is strictly prohibited. This > communication is for information purposes only and > should not be regarded as an offer to sell or as a > solicitation of an offer to buy any financial > product, an official confirmation of any > transaction, or as an official statement of Lehman > Brothers. Email transmission cannot be guaranteed > to be secure or error-free. Therefore, we do not > represent that this information is complete or > accurate and it should not be relied upon as such. > All information is subject to change without notice. > > > IRS Circular 230 Disclosure: > Please be advised that any discussion of U.S. tax > matters contained within this communication > (including any attachments) is not intended or > written to be used and cannot be used for the > purpose of (i) avoiding U.S. tax related penalties > or (ii) promoting, marketing or recommending to > another party any transaction or matter addressed > herein. > > > > - > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Form Submission Question
I'm having a problem with my bean going out of scope. The form is populated with the bean information fine, but when I submit building is null? How do I keep it in scope? Do I have to pull it back out of the ActionContext? public class BuildingFormTestAction extends ActionSupport { private static final long serialVersionUID = 6692492667406189130L; private Building building; public String init() throws Exception { //Fetch Building from db . . . return ActionSupport.SUCCESS; } public String execute() throws Exception { System.out.println("Submitting: "); System.out.println(building);//PRINTS NULL! return ActionSupport.SUCCESS; } public void setBuilding(Building b) { building = b; } public Building getBuilding() { return building; } } Here's the JSP Form: And Struts.xml exerpt: /buildingFormTest.jsp /error.jsp /buildingFormTest.jsp /error.jsp -Original Message- From: Dave Newton [mailto:[EMAIL PROTECTED] Sent: Thursday, November 15, 2007 2:20 PM To: Struts Users Mailing List Subject: Re: Form Submission Question --- Gary Affonso <[EMAIL PROTECTED]> wrote: > Dave Newton wrote: >> The action that *processes* the form submission may extend >> ActionSupport. > > Dave knows that, of course, but I didn't want the emphasis on > "*processes*" above to make you think ActionSupport was only > appropriate for form processing actions. Yep, that was a good clarificaton to make :) d. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice. IRS Circular 230 Disclosure: Please be advised that any discussion of U.S. tax matters contained within this communication (including any attachments) is not intended or written to be used and cannot be used for the purpose of (i) avoiding U.S. tax related penalties or (ii) promoting, marketing or recommending to another party any transaction or matter addressed herein. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Form Submission Question
The action that *processes* the form submission may extend ActionSupport. You submit the form to an action. The action either contains the fields of the form or contains a bean that can be used on the form. The bootstrap tutorial goes through a simple form processing example. http://struts.apache.org/2.x/docs/bootstrap.html d. --- "Hernandez, David" <[EMAIL PROTECTED]> wrote: > > Can anyone point me to a location that outlines the > Form > submission/processing flow for struts 2? I'm having > a bit of a problem > deciphering how forms are supposed to be handled. > For instance I have a > Bean (Building) that I want to update (to a DB) from > a form: > > JSP: > > >value="streetAddress" /> > > > > > > > Should I have the bean extend ActionSupport and > implement the execute > method? That seems like it would be a violation of > the MVC model . . . > - - - - - - - - - - - - - - - - - - - - - - - - - - > - - - - - - - - - - - - - - - - - - > > This message is intended only for the personal and > confidential use of the designated recipient(s) > named above. If you are not the intended recipient > of this message you are hereby notified that any > review, dissemination, distribution or copying of > this message is strictly prohibited. This > communication is for information purposes only and > should not be regarded as an offer to sell or as a > solicitation of an offer to buy any financial > product, an official confirmation of any > transaction, or as an official statement of Lehman > Brothers. Email transmission cannot be guaranteed > to be secure or error-free. Therefore, we do not > represent that this information is complete or > accurate and it should not be relied upon as such. > All information is subject to change without notice. > > > IRS Circular 230 Disclosure: > Please be advised that any discussion of U.S. tax > matters contained within this communication > (including any attachments) is not intended or > written to be used and cannot be used for the > purpose of (i) avoiding U.S. tax related penalties > or (ii) promoting, marketing or recommending to > another party any transaction or matter addressed > herein. > > > > - > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Form Submission Question
Thanks guys. The bootstrap should have an example where the fields are populated by the Action Class's member variables. But I figured it out, I think . . . -Original Message- From: Dave Newton [mailto:[EMAIL PROTECTED] Sent: Thursday, November 15, 2007 2:20 PM To: Struts Users Mailing List Subject: Re: Form Submission Question --- Gary Affonso <[EMAIL PROTECTED]> wrote: > Dave Newton wrote: >> The action that *processes* the form submission may extend >> ActionSupport. > > Dave knows that, of course, but I didn't want the emphasis on > "*processes*" above to make you think ActionSupport was only > appropriate for form processing actions. Yep, that was a good clarificaton to make :) d. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice. IRS Circular 230 Disclosure: Please be advised that any discussion of U.S. tax matters contained within this communication (including any attachments) is not intended or written to be used and cannot be used for the purpose of (i) avoiding U.S. tax related penalties or (ii) promoting, marketing or recommending to another party any transaction or matter addressed herein. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Form Submission Question
--- Gary Affonso <[EMAIL PROTECTED]> wrote: > Dave Newton wrote: >> The action that *processes* the form submission >> may extend ActionSupport. > > Dave knows that, of course, but I didn't want the > emphasis on "*processes*" above to make you > think ActionSupport was only appropriate > for form processing actions. Yep, that was a good clarificaton to make :) d. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Form Submission Question
Dave Newton wrote: The action that *processes* the form submission may extend ActionSupport. Yup. Note that it's commonly not just "form processing actions" that extend ActionSupport, it's often all actions. Dave knows that, of course, but I didn't want the emphasis on "*processes*" above to make you think ActionSupport was only appropriate for form processing actions. Your beans do *not* extend ActionSupport. They're typically referenced within the action as a standard property and getters/setters for that property. That way your form/views have access to the bean's properties through a variety of view/form techniques. - Gary - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]