I'm having a similar problem.  I haven't been able to get my custom
ActionForm to work.

I'm using Struts 1.1 b2.


I've got MyActionForm which contains

        Private String[] firstName;
        Private String[] lasstName;

With getters and setters

        Public String[] getFirstName() { return this.firstName; }
        Public void setFirstName(String[] firstName) { this.firstName =
firstName; }
        Public String[] getLastName() { return this.lastName; }
        Public void setLastName(String[] lastName) { this.lastName =
lastName; }

I've also tried

        Public String getFirstName(int i) { return this.firstName[i]; }
        Public void setFirstName(int I, String firstName) {
this.firstName[i] = firstName; }
        Public String getLastName(int i) { return this.lastName[i]; }
        Public void setLastName(int I, String lastName) {
this.lastName[i] = lastName; }

My struts-config contains:

        <form-bean dynamic="false" name="MyActionForm"
type="com.bbdodetroit.struts.form.MyActionForm">
            <form-property name="firstName" type="java.lang.String[]"/>
            <form-property name="lastName" type="java.lang.String[]"/>
        </form-bean>

And in my JSP I'm declaring the fields as follows:

      <bean:message key="prompt.firstName"/>
      <html:text property="firstName(0)"/>
      <html:errors property="firstName(0)"/>
      &nbsp;
        <bean:message key="prompt.lastName"/>
      <html:text property="lastName(0)"/>
      <html:errors property="lastName(0)"/>

I've also tried "firstName[0]", and even (after spotting it in the
archives somewhere and thinking perhaps this might be some undocumented
internal approach) "firstName(0).label" and "firstName[0].label").

Can someone (ANYONE?) explain exactly what the syntax should be in each
of these three places for this to work?  Or please provide a URL which
does so?






























-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, January 15, 2003 10:54 AM
To: [EMAIL PROTECTED]
Subject: RE: A form with a List



> But my doubt is not how to use iterate tag. It's how to model
> the form that store the list of professionals (or anything else).

Try something like that:

private Professional[] professionals;


public Professional getProfessionals(int i){
  return professionals[i];
}

public Professional[] getProfessionals(){
  return professionals;
}

public void setProfessionals(int i, Professional aProfessional){
  professionals[i] = aProfessional;
}

public void setProfessionals(Professional[] aProfessionals){
  professionals = aProfessionals;
}
        



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


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

Reply via email to