Yes, it most certainly does work!

Firstly, I would use 1.1b3 if at all possible.

In order to properly use the <nested> tags you have to tell it the root context.  
There are a few ways of achieving this; the simplest case is if your <nested> tags are 
within the scope of a <nested:form>.  In this case all the <nested> tags within 
"inherit" the form-bean associated with the form.

While I understand that a UserForm has a collection of UserPrefForm objects, I'm not 
sure I understand the relationship between User, Preferences and UserForm.  So, 
working under the premise that an object of type UserForm is the form-bean for the 
action associated with the form,

<nested:form action="/someAction.do">
  <%-- print the userFormName property of UserForm --%>
  <nested:write property="userFormName"/>
  <%-- Iterate over all the UserPrefForms --%>
  <nested:iterate property="userPrefForms">
    <%-- The context within this loop is *a* UserPrefForm --%>
    <nested:text property="somePref"/>
    <nested:text property="someOtherPref"/>
  </nested:iterate>
</nested:form>

Like with "normal" Struts tags, property="foo" results in a call to the method 
getFoo() of the appropriate bean.  Submitting this form *will* result in the 
properties being updated correctly.

Whether you work with a form-bean or use the <nested:root> tag to specify the bean, it 
is imperative that the bean be available in some scope with the proper key.

Hope that helps

Sri

> -----Original Message-----
> From: Sundar Narasimhan [mailto:[EMAIL PROTECTED]] 
> Sent: Wednesday, February 05, 2003 11:37 PM
> To: [EMAIL PROTECTED]
> Subject: nest sytax.. looks cool but does it work? :)
> 
> 
> I finally gave up w/ 1.0 and moved to 1.1b2 (the one that 
> comes w/ WSAD).
> 
> And the first thing I try w/ it doesn't work, so I must have 
> the wrong model again. So here goes;
> 
> I have a top level User -- who has a bunch of Preferences. 
> There is a UserForm, and a UserPrefForm. The UserForm has a 
> collection of UserPrefForm, and in addition has a property 
> called "selectedPref" which actions set to one of the 
> UserPrefForms.  (The reason I want to do this is simple: I 
> want to display a table with all the UserPrefForms in summary 
> form, and when the user clicks on a Preference to display the 
> detail along with the form). The trouble is how can I display 
> a UserPrefForm's fields when I'm displaying a User? So I 
> think <nested> can help. 1. I first try 
>    <nested:text property="selectedPref.someField"> </nested:text>
>    Doesn't work -- PropertyUtils.throw an IllegalArgument exception --
>    No bean specified.
> 2. I then try
>    <nested:nest property="selectedPref"
>       <html:text property="someField">...
>    </nested:nest>      
>    and
>    <nested:nest property="selectedPref"
>       <nested:text property="someField">...
>    </nested:nest>      
>    nada .. 
> 3. Then I think.. hmm I did read something about "root" and 
> maybe that's needed to set the scoping right..
>     <nested:root name="selectedPref">
>         <...>   
>     </nested:root>
> Now I get "selectedPref" not found in any scope!
> 
> How is this supposed to work!!! 
> Frustrated.
> 
> p.s. do I have the right model here.. that if I use the 
> nested tag, and invoke the action (say Save), the populate 
> process in struts will find the appropriate "selected" 
> preference and save the nested fields "in" the selected form. 
> Note that this is what the document seems to imply with all 
> the discussion of bananas and monkeys.. does the code not 
> correspond to the documentation? (I was assuming that I'd get 
> bi-directional transfer.. i.e. from the forms to the jsp, and 
> vice-versa.. i.e. jsp to actions to the forms -- and that 
> such master-detail traversals are what nesting was designed for).
> 
> If I have this wrong, or if the implementation is just plain 
> not working yet, please could someone let me know. 
> 
> Thanks.
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to