Hi,
I am trying to use the new DynaActionForm (from beta1) with nested
properties, and it seems like that DynaActionForm ignores the nesting stuff.
While checking out code, it appears like BeanUtils.populate() does not seem
to traverse the property nesting properly for dyna properties. It works ok
if I switch to regular form bean.

I would very much appreciate if anyone can throw some light on this. If
DynaActionForm is NOT designed to be used with nested properties, it would
be nice if we had some scope and usage document listing when to use Dyna and
when to use regular form bean. If it is a bug, I can try to work on this and
provide a patch. 

Here is my form bean configuration:
    <form-bean      name="cart" 
                    type="MyDynaActionForm"
                    className="MyFormBeanConfig">
      <form-property name="name" type="java.lang.String"/>
      <form-property name="items" type="ShoppingItem[]"/>
    </form-bean>

MyDynaActionForm is an extension to prevent "reset()" from clearing "items"
array.
MyFormBeanConfig is an extension to recognize MyDynaActionForm class name as
dynamic.
ShoppingItem is a bean with 3 properties - id, quantity, and 'remove'
boolean.

Here is how my JSP looks:
<nested:form action="/updateCart">
<nested:text property="name"/>
<TABLE>
  <nested:iterate id="it" property="items">
  <TR>
    <TD><nested:text property="id"/></TD>
    <TD><nested:text property="quantity"/></TD>
    <TD><nested:checkbox property="remove"/></TD>
  </TR>
  </nested:iterate>
</TABLE>

<nested:submit property="Update" value="Update"/>
</nested:form>

Generated html looks like:
<form name="cart" method="POST" action="/cart/updateCart.do">
<input type="text" name="name">

<TABLE>
  <TR>
    <TD><input type="text" name="items[0].name" value="first"></TD>
    <TD><input type="text" name="items[0].quantity" value="1"></TD>
    <TD><input type="checkbox" name="items[0].remove" value="on"></TD>
  </TR>
  
  <TR>
    <TD><input type="text" name="items[1].name" value="second"></TD>
    <TD><input type="text" name="items[1].quantity" value="2"></TD>
    <TD><input type="checkbox" name="items[1].remove" value="on"></TD>
  </TR>
  
</TABLE>

<input type="submit" name="Update" value="Update">
</form>

So, when the form is submitted, BeanUtils finds the dyna property for
"items", and tries to invoke equivalent of following on the dynaform bean.
set("items", 0, "first")  instead of get("items", 0).setName("quantity").

Looking forward to any help.
Apologize for posting to "developers"; assuming there are not many users of
the new beta features out there yet.

Thank you in advance,
Anil Mandava

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

Reply via email to