Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

nested indexed properties in struts

 
Dianne Pop
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I'm having trouble with indexed properties. I have read the FAQ but my code has another level of nesting, which kind of messes things a bit.

The form contains an object of type Bill which contains a List of BillPart objects (with corresponding getters and setters). The user can enter a variable number of BillParts.

so the ActionForm has a



and my Bill class has the definition of the list of parts, and the method as suggested in the FAQ:



a BillPart has a name and an amount property.

In my jsp I put:


This doesn't create the appropriate name of the <input type="text"> property though. The setter of amount or name is never called.
I have tried several variations of what the <nested:text> name should be - nothing works. Other bill properties are set, but this nested ones aren't.
The generated html source doesn't look right:


It should be something like name="bill.part[0].name" or "bill.parts[0].name"


By omitting the name completely, I get a source html like this:


this should work - the hierarchy looks correct (not sure about the form[0] thing, but I assume it's something standard)

But still, the setters are never called. The other setters of Bill object are called, but never the ones of BillPart object.


Any suggestions?

Thank you
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic