This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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.
 
 
subject: Nested Bean Properties
 
Similar Threads
Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
jsp:getProperty gives null
Displaying a large ResultSet, in multiple HTML pages
HFSJ Question in JSTL
no getter method