Hello,

I'm using an action which implements the ModelDriven interface where my
model is a hibernate POJO (e.g. Customer). In this Customer I have a
OneToMany relationship with another hibernate POJO (e.g. Address)...

    /** persistent field */
    @OneToMany(mappedBy="customer",
targetEntity=com.inftropy.plus.account.Customer.model.Address.class, cascade
= { CascadeType.ALL}, fetch=FetchType.EAGER)
    @IndexedEmbedded
    private Set<Address> addresses;

... I'm trying to create a form that allows the setting for multiple
addresses for the current customer. For example, say my address has two
fields (id and name) and I want to set two addresses for a certain
Customer....

BEGIN jsp
<s:iterator value="model" status="customerStatus" id="customer">
        <table>
          <tr>
            <td>
              <s:text name="addressIdTitle"/>
            </td>
            <s:iterator value="#attr.customer.addresses"
status="custAddressStatus">
            <td>
              <s:textfield name="addresses.id" value="%{id}"/>
            </td>
            </s:iterator>
          </tr>
          <tr>
            <td>
              <s:text name="addressCodeTitle"/>
            </td>
            <s:iterator value="#attr.customer.addresses"
status="custAddressStatus">
            <td>
              <s:textfield name="addresses.code" value="%{code}"/>
            </td>
            </s:iterator>
          </tr>
</s:iterator>
END jsp

BEGIN resulting html

        <table>
          <tr>
            <td>
              addressIdTitle
            </td>


            <td>
              <input type="text" name="addresses.id" value="2"
id="Customer_update_addresses_id"/>
            </td>

            <td>
              <input type="text" name="addresses.id" value="1"
id="Customer_update_addresses_id"/>
            </td>

          </tr>
          <tr>
            <td>

              addressCodeTitle
            </td>

            <td>
              <input type="text" name="addresses.code" value="SHIPTO"
id="Customer_update_addresses_code"/>
            </td>

            <td>
              <input type="text" name="addresses.code" value="BILLTO"
id="Customer_update_addresses_code"/>
            </td>
          </tr>
       </table>
END resulting html

... Is there a convention I can use (in this case I tried
addresses.<field>, which didn't work) so that the fields I set
correspond to the associated Address object for the current model?

Thanks,
Ryan

Reply via email to