m t_daypart order by begin_time asc
<Mar 18, 2003 4:00:37 PM EST> <Error> <HTTP> <101017>
<[ServletContext(id=6914328,name=ctweb.war,context-path=)] Root cause
vletException
java.lang.IndexOutOfBoundsException: Index: 2, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:508)
at java.util.ArrayList.set(ArrayList.java:336)
at
org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:460)
at
org.apache.commons.beanutils.PropertyUtilsBean.setIndexedProperty(PropertyUt
ilsBean.java:1373)
at
org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:10
23)
at
org.apache.commons.beanutils.BeanUtilsBean.populate(BeanUtilsBean.java:818)
at
org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:343)
at
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1136)
at
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.j
ava:815)
at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1421)
at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:518)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(Servle
tStubImpl.java:1058)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:401)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:306)
at
weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(W
ebAppServletContext.java:5445)
at
weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManage
r.java:780)
at
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
ntext.java:3105)
at
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
:2588)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:213)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:189)
I'll give the debugger a shot and see what happens.
-Josh
-----Original Message-----
From: Karr, David [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 18, 2003 4:32 PM
To: Struts Users Mailing List
Subject: RE: Indexed Properties with DynaActionForm Problems
It would be hard for us to figure out anything without any description
of what really happens. Do you have an exception stack trace?
You could really help yourself out by setting this up in a JPDA debugger
and really tracking exactly what happens at the point of the error (and
before).
> -----Original Message-----
> From: Josh Rayls [mailto:[EMAIL PROTECTED]
>
> Hello,
>
> 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]