Are you using Struts-EL?  You can't reference EL expressions in Struts
tags, just Struts-EL.

> -----Original Message-----
> From: Josh Rayls [mailto:[EMAIL PROTECTED]
> 
> I have been struggling with this for a couple of days now.  I've
scoured
> the
> archives from top to bottom, and I've found some useful tidbits, but
> nothing
> that directly addresses my dilemma.  Then again, maybe I'm just not
> getting
> it!
> 
> I get an IndexOutOfBoundsException each time.  I want to be able to
have
> an
> arbitrary numbers of rows in the form and then be able to construct
beans
> from the rows in my action class.
> 
> Any help would be greatly appreciated.  I'm going to have very little
hair
> left when this is done....
> 
> -Josh
> 
> Code is below:
> 
> JSP ---------------
> 
> <!-- Begin table body data -->
>     <tbody>
>      <c:set var="count" value="-1"/>
>      <c:forEach items="${collection}" var="dayPart">
>       <c:set var="count" value="${count + 1}"/>
>       <tr>
>        <td>
>         <html:hidden property="id" value="${dayPart.id}"
indexed="true"/>
>         <html:hidden property="status" value="${dayPart.status}"
> indexed="true"/>
>         <html:hidden property="deleteable"
value="${dayPart.deleteable}"
> indexed="true"/>
>         <html:text property="code" size="3" maxlength="3"
> value="${dayPart.code}" indexed="true"/>
>        </td>
>        <td>
>         <html:text property="name" size="16" value="${dayPart.name}"
> indexed="true"/>
>        </td>
>        <td>
>         <html:text property="beginTime" maxlength="4" size="10"
> value="${dayPart.beginTime}" onblur="check24Hours(this)"
indexed="true"/>
>        </td>
>        <td>
>         <html:text property="endTime" maxlength="4" size="10"
> value="${dayPart.endTime}" onblur="check24Hours(this)"
indexed="true"/>
>        </td>
>        <td>
>         <c:if test="${dayPart.deleteable}">
>          <ct:isAuthorized screen="68" control="30">
>           <html:link
> href="javascript:post('delete','null','${dayPart.id}');">
>            <html:img src="images/delete.gif" border="0"/>
>           </html:link>
>          </ct:isAuthorized>
>         </c:if>
>        </td>
>       </tr>
>      </c:forEach>
>      <html:hidden property="rows" value="${count}"/>
>     </tbody>
>     <!-- End table body data -->
> 
> Action -------------
> 
>     // instance variables
>     ActionErrors errors = new ActionErrors();
>     Collection c = new ArrayList();
>     int rows = ((Integer)PropertyUtils.getProperty(actionForm,
> "rows")).intValue();
> 
>     // populate the collection with day parts
>     DayPart dayPart = null;
>     PropertyDescriptor[] props =
> PropertyUtils.getPropertyDescriptors(DayPart.class);
>     for (int x=0; x<rows; x++) {
>       dayPart = new DayPart();
>       for (int i=0; i<props.length; i++) {
>         PropertyUtils.getIndexedProperty(actionForm,
props[i].getName(),
> x);
>       }
>       // add the new day part to the collection
>       c.add(dayPart);
>     }
> 
>     try {
>       CorporateManager manager = JNDIUtil.createCorporateManager();
>       manager.updateDayParts(c);
>     } catch (SetupException se) {
>       LogManager.error(this.getClass(), "There has been a problem
updating
> dayparts.", se);
>       errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("The day
parts
> could not be updated."));
>     }
> 
>     // forward request
>     if (errors.isEmpty()) {
>       return actionMapping.findForward("view");
>     } else {
>       this.saveErrors(request, errors);
>       return actionMapping.findForward("view");
>     }
> 
> Struts-Config.xml ----------------
> 
>               <form-bean name="daypartForm"
> type="org.apache.struts.action.DynaActionForm">
>                <form-property name="action" type="java.lang.String"/>
>                <form-property name="sortType"
type="java.lang.String"/>
>                <form-property name="id" type="java.util.ArrayList"/>
>                <form-property name="status"
type="java.util.ArrayList"/>
>                <form-property name="deleteable"
> type="java.util.ArrayList"/>
>                <form-property name="code" type="java.util.ArrayList"/>
>                <form-property name="name" type="java.util.ArrayList"/>
>                <form-property name="beginTime"
> type="java.util.ArrayList"/>
>                <form-property name="endTime"
type="java.util.ArrayList"/>
>                <form-property name="rows" type="java.lang.Integer"/>
>               </form-bean>

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

Reply via email to