On 7/18/05, Scott Purcell <[EMAIL PROTECTED]> wrote: > So my question is as follows: > When using struts, is a nested bean common? And if so, how do you validate > just one bean from the parent? > > eg: Lets say that the bean lets call it "checkout" and inside it has the > users shipping information. So that bean will be called "shippinginfo" > So the bean checkout has a shippinginfo bean in it. Now when the user > navigates to the html form where he can update the shippinginfo, contents, I > need to validate the shippinginfo, that exists inside checkout. > > Can this be done, and if so is this the clean way to accomplish my task. Up > until now, I have basically created one bean, per html form so this is kind > of new to me.
Yes. It is easy to do. You use the same property reference syntax for nested bean properties in your validation.xml file that you would use to populate form fields automatically for your nested bean properties using the Struts html taglib. For example, here is partial validation.xml form element definition that specifies that the "city" property of the nested "shippinginfo" bean is a required property: <form name="checkoutForm"> <field property="shippinginfo.city" depends="required"> <arg0 key="shippinginfo.label.city"/> </field> ... </form> > > Thanks, > Scott -Van -- - Mike "Van" Riper [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]