Before anyone flames me, I have read through the archive, and as someone
already said, there is info in there, but no concrete basic examples.

Here's the formBean I'm trying to handle:

    <form-bean name="familyForm"
type="org.apache.struts.validator.DynaValidatorForm">
      <form-property name="address" type="java.lang.String"/>
      <form-property name="city" type="java.lang.String"/>
      <form-property name="state" type="java.lang.String"/>
      <form-property name="zip" type="java.lang.String"/>
      <form-property name="homePhone" type="java.lang.String"/>
      <form-property name="status" type="java.lang.String"/>
      <form-property name="firstName" type="java.lang.String[]"/>
      <form-property name="lastName" type="java.lang.String[]"/>
      <form-property name="cellPhone" type="java.lang.String[]"/>
    </form-bean>

In short, there are some fields that are the same for everyone, and some
fields that are unique to each person.  I can place a hard limit on how many
firstNames there can be, but I want the code to refer to a constant
somewhere, say "Constants.MAXPEOPLE" or something.  I'm not trying to have
an array of some object type (there WAS somewhat of an example for that in
the archive), just flat out strings.

I know the JSP will look something like:

<html:form action="saveFamily">
<html:text property="address"/>
<html:text property="city"/>
<html:text property="state"/>
<html:text property="zip"/>
<html:text property="homePhone"/>
<html:text property="status"/>
<logic:iterate ?????????????????>
<html:input ???????????/> for firstName
<html:input ???????????/> for lastName
<html:input ???????????/> for cellPhone
</logic:iterate>
<html:submit/>
</html:form>

Then from my actions I can do this:

DynaActionForm dynaForm = (DynaActionForm) form;
address = dynaForm.get("address").toString();
city = dynaForm.get("city").toString();
state = dynaForm.get("state").toString();
zip = dynaForm.get("zip").toString();
homePhone = dynaForm.get("homePhone").toString();
status = dynaForm.get("status").toString();
for (int i = 0; i < ???????; i++) {
    thisFirstName = dynaForm.get("firstName", i).toString();
    thisLastName = dynaForm.get("lastName", i).toString();
    thisCellPhone = dynaForm.get("cellPhone", i).toString();
}

Can someone fill in the ??????, so to speak?




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

Reply via email to