File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Nested Bean Properties Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Nested Bean Properties" Watch "Nested Bean Properties" New topic
Author

Nested Bean Properties

Fred Artes
Ranch Hand

Joined: Nov 14, 2008
Posts: 43
Hello I have some problem with nested bean properties. This is my situation

JSP


ACTIONFORM


BEAN CUSTOMER


BEAN ADDRESS


The select is showed correctly but on form submit idCity is not valued. Where am I wrong ?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Struts will only populate the property in your ActionForm bean, not in your Customer bean. Just remove the name attribute from your html:select tag and struts will assign the idCity value to the address bean in the ActionForm.


Merrill
Consultant, Sima Solutions
Fred Artes
Ranch Hand

Joined: Nov 14, 2008
Posts: 43
I use



because I want use the same JSP for insert and modify. In my action I have boolean bNew
bNew = true --> insert
bNew = false --> modify



So in HTML code I have




How can I populate idCity on form submit ?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
If your ActionForm is in request scope, you will need to instantiate the Address option before Struts can populate its properties. Change line 1 of your ActionForm to:

If you do this, Struts should populate the idCity property of the Address in the ActionForm when the form is submitted.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Nested Bean Properties