• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Nested Bean Properties

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Fred Artes
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic