I've always used String values. Given that difference, I've seen this work:
<field property="birth" indexedListProperty="employees" depends="required,date"> <arg0 key="employeeform.birth.displayname"/> <var> <var-name>datePatternStrict</var-name> <var-value>MM/dd/yyyy</var-value> </var> </field> In this case, the form bean has a collection of "employees", and each employee has a "birth" field. Then something like <nested:errors property="birth"/> beside the field will show which of the many employees has the invalid date. I have a sample app (minus the <nested> tag, though I've just tried that and it works) somewhere you can download it if you want to see it. That sample app actually goes one level deeper: <field property="address.zip" indexedListProperty="employees" depends="required,integer"> <arg0 key="employeeform.address.zip.displayname"/> </field> Each "employee" has an address field which is also a nested form, with zip as an int field. Hubert On 12/15/05, Rick R <[EMAIL PROTECTED]> wrote: > Cutting right to the chase... > > I'm curious on how others handle the age-old struts problem of: "How do you > handle nested objects in an ActionForm that have non String properties that > might be editable by a user on a JSP?" > > To provide a watered down example... > > Imagine you go to the DB to get a List of Company objects. Each company > object in the List has nested in it a List of Division objects. Each > Division has a "date" field in it (say a startDate). You then need to > display a form that displays the companies and divisions and could allow the > user to edit the date (in a free-form text field) and submit the form. > > Things work fine if you didn't have to worry about form validation - in > which case, you could just have one property in your ActionForm: List > companies; //set/get and you are done (using the List of Company value > objects). You'd display the data on the form and submit and things are nice. > > However, nested sort of deep is that "date" field. If the user enters in the > date wrong we want to return to the page and display what they entered so > they can fix it. This can't be done if you just want to use the nested value > object(POJO) approach. > > This above scenario is Strut's biggest weakness. (It's compounded with > BeanUtils crazy notion of also not keeping wrapper clases like Integer truly > "null" when a String is null - instead it decides to make the Integer 0). > > Besides wondering how others deal with this annoying problem (other than > moving to another framework like JSF), I was wondering if maybe DyanForms > could be a solution? Can you nest them ? If so then that might be the > answer. Typically I haven't been too fond of DyanForms in the past (for a > couple of reasons), but if it could solve this issue it would definitely be > worth their use. > > -- > Rick Reumann > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]