• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

html:select nesting of beans

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a question regarding the use of html:select
in Struts. I have an array list in the session scope named volumediscountArray. Each row of the
array is an "volumediscount" bean object.
VolumeDiscount has volumediscountId as string
My ActionForm is Campaignform
CampignForm has a array of CampaignSlabs
CampaignSlab has id,name,fromdate as Strings.
Now i want the users selection to be set in the CmapignSlabs id .
i tried this but doesn't work ::
<html:select name="campaignSlabBean" property="Id" >
<html ptions collection="volumediscountArray"
property="volumediscountId"
labelProperty="volumediscountId"/>
</html:select>
The error is:
javax.servlet.ServletException: Cannot find bean under name campaignSlabBean
It works fine if i have to set the displayed attribute directly under CampaignForm but here for deep nesting how to do it?
 
Sheriff
Posts: 17665
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Struts supports the "dot notation" for nested properties. That is,
   property="employee.id"
translates to a call to getEmployee().getId()
For indexed properties, you need a method such as
   public Object getEmployee(int index) { ... }
The property attribute would be
   property="employee[n]"
where n should be a valid index value. You can, of course combine the two:
   property="employee[1].id"
will invoke getEmployee(1).getId()
 
Remember to always leap before you look. But always take the time to smell the tiny ads:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic