Could not get the wiki's example of

public class SkillActionForm extends ActionForm {
      protected List skills = new ArrayList();

      public List getSkills() {
          return skills;
      }

      public void setSkills(List skills) {
          this.skills = skills;
      }

      public SkillBean getSkills(int index) {
          // automatically grow List size
          while (index >= skills.size()) {
              skills.add(new SkillBean());
          }
          return (SkillBean)skills.get(index);
      }
  } 

However, as soon as I changed the setSkills(List) to
setSkills(SkillBean) and provided a non-bean collection populating
method (populateSkills(List)) everything seems to work. Apparently
Struts is/cannot examine the method arguments and is confused by the
naming.



-----Original Message-----
From: David McReynolds [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, November 17, 2004 4:46 PM
To: [EMAIL PROTECTED]
Subject: Indexed properties

I am getting the nested beans out of my form ok but saving gives no joy.
I am trying to use the "2.1 Hand Cranking lazy List in the ActionForm"
from http://wiki.apache.org/struts/StrutsCatalogLazyList. However, I
never see my log messages from the indexed getter methods for any of the
nested beans.


<nested:form action="saveUnitDayScheduleAction.do">
  <nested:iterate id="days" property="days" >
    <nested:iterate id="workgroups" property="workgroups">
      <nested:iterate id="employeeAppointments"
property="employeeAppointments">
        <nested:hidden property="statusCode" indexed="true" />
      </nested:iterate>
    </nested:iterate>
  </nested:iterate>
</nested:form>

The form has a collection of DayOfWeekBeans called days.
Each DOW bean has a collection of WorkgroupBeans called workgroups.
Each WG bean has a collection of EmployeeAppointmentBeans called
employeeAppointments.

To that end the form and each of DOW and WG beans have the following
general construct (in a garish form of C++ template syntax).
public <BEAN_TYPE> get<LIST>(int index) {
      while (index >= <list>.size()) {
          <list>.add(new <BEAN_TYPE>());
      }

      return (<BEAN_TYPE>)<list>.get(index);       
}

And of course the appropriate

public List get<LIST>(){ return <list>;} and Public void set<LIST>( List
<list> ) { this.<list> = <list>;}


The above JSP leads to this html fragment.

<form name="unitDayScheduleForm" method="post"
action="/labor/saveUnitDayScheduleAction.do">
        <input type="hidden"
name="unitDayScheduleForm[0].days[0].workgroups[0].employeeAppointments[
0].statusCode" value="N">
        <input type="hidden"
name="unitDayScheduleForm[1].days[0].workgroups[0].employeeAppointments[
1].statusCode" value="N">
        <input type="hidden"
name="unitDayScheduleForm[2].days[0].workgroups[0].employeeAppointments[
2].statusCode" value="N">
        <input type="hidden"
name="unitDayScheduleForm[3].days[0].workgroups[0].employeeAppointments[
3].statusCode" value="N">
        <input type="hidden"
name="unitDayScheduleForm[4].days[0].workgroups[0].employeeAppointments[
4].statusCode" value="N">
        <input type="hidden"
name="unitDayScheduleForm[5].days[0].workgroups[0].employeeAppointments[
5].statusCode" value="N">
        <input type="hidden"
name="unitDayScheduleForm[6].days[0].workgroups[0].employeeAppointments[
6].statusCode" value="N">
        <input type="hidden"
name="unitDayScheduleForm[7].days[0].workgroups[0].employeeAppointments[
7].statusCode" value="N">
      
  . . . Blah blah blah

---------------------------------------------------------------------
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