You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Charles GAY <ch...@wanadoo.fr> on 2003/12/04 16:38:32 UTC

dynaActionForm,JSTL, and indexed properties

hi all.
i have in my DynaValidatorForm called entrantesForm, declared an ArrayList (called colRequetes) of  RequeteTO objects.
<form-property name="colRequetes" type="java.util.ArrayList" /></form-bean>

in my jsp, i want to update some properties of RequeteTO, like 'typeRequete' with the html-tag(html-el taglib declared above) with the <html:selec>t tag.

  <c:forEach  items="${entrantesForm.map.colRequetes}" var="enregistrement" varStatus="status">
  <c:set var="numero" value="${status.index}" scope="page" />  
  <tr>
	<td><html:radio property="id" value="${enregistrement.id}"  /></td>
    <td><c:out value="${enregistrement.nomRequete}" /></td>
    <td><c:out value="${enregistrement.typeObjet}" /></td>    
	<td><html:select size="1"  name="colRequetes" property="typeRequete" indexed="true" value="${enregistrement.typeRequete}" >
		  <html:option value="Publique" >
			<c:if test="${enregistrement.typeRequete == 'Publique'}"><c:out  value="${enregistrement.typeRequete}" /></c:if>
		  </html:option>
		  <html:option value="Privée" >
			<c:if test="${enregistrement.typeRequete == 'Privée'}"><c:out  value="${enregistrement.typeRequete}" /></c:if>
		  </html:option>
		</html:select >
	</td>
  </tr>
  </c:forEach>

the jsp result is good.

an extract of the html source producted by the jsp:
<form name="entrantesForm" method="POST" action="/comsis/entrantes/EntrantesRequete.do">    

<table>
 <tr>
   <th></th>    
   <th>Nom de la requete</th>
   <th>Type dossier</th>  
   <th>Type requete</th>
 </tr>
 
   
 <tr>
<td><input type="radio" name="id" value="13" checked="checked" /></td>
   <td>s</td>
   <td>entrante</td>    
<td><select name="colRequetes[0].typeRequete" size="1"><option value="Publique" selected="selected">Publique</option>
 <option value="Privée">Privée</option></select>
</td>
 </tr>
 
   
 <tr>
<td><input type="radio" name="id" value="15" /></td>
   <td>gbgh,gh</td>
   <td>entrante</td>    
<td><select name="colRequetes[1].typeRequete" size="1"><option value="Publique">Publique</option>
 <option value="Privée" selected="selected">Privée</option></select>
</td>
 </tr>
 
</table>


but, when i submit the form,
the server says that:
StandardWrapperValve[action]: "Servlet.service()" pour la servlet action a généré une exception
javax.servlet.ServletException: BeanUtils.populate
	at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1254)
	at org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:821)
	at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
	at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
........
........
----- Root Cause -----
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
	at java.util.ArrayList.RangeCheck(ArrayList.java:507)
	at java.util.ArrayList.get(ArrayList.java:324)
	at org.apache.struts.action.DynaActionForm.get(DynaActionForm.java:298)
	at org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils.java:474)
	at org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils.java:428)
	at org.apache.commons.beanutils.PropertyUtils.getNestedProperty(PropertyUtils.java:770)
	at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:801)
	at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:881)
	at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
	at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1252)
	at org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:821)
	at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
	at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
.......
.......
the collection seems not be initialized, but *before* the request, the jsp display his content......
crazy problem.......
any helps will be very appreciated!!

thanks in advance,
charles.



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: dynaActionForm,JSTL, and indexed properties

Posted by Richard Yee <ry...@yahoo.com>.
Charles,
If you the size of the ArrayList is constant, you can
specify the form-property 'size' attribute and this
will fix your problem. Otherwise, you need to use
session scope to store the FormBean. The reason is
that Struts will not size the colRequetes ArrayList
when the form is submitted. If the form is in request
scope, it will already be sized for you.

-Richard

--- Charles GAY <ch...@wanadoo.fr> wrote:
> hi all.
> i have in my DynaValidatorForm called entrantesForm,
> declared an ArrayList (called colRequetes) of 
> RequeteTO objects.
> <form-property name="colRequetes"
> type="java.util.ArrayList" /></form-bean>
> 
> in my jsp, i want to update some properties of
> RequeteTO, like 'typeRequete' with the
> html-tag(html-el taglib declared above) with the
> <html:selec>t tag.
> 
>   <c:forEach 
> items="${entrantesForm.map.colRequetes}"
> var="enregistrement" varStatus="status">
>   <c:set var="numero" value="${status.index}"
> scope="page" />  
>   <tr>
> 	<td><html:radio property="id"
> value="${enregistrement.id}"  /></td>
>     <td><c:out value="${enregistrement.nomRequete}"
> /></td>
>     <td><c:out value="${enregistrement.typeObjet}"
> /></td>    
> 	<td><html:select size="1"  name="colRequetes"
> property="typeRequete" indexed="true"
> value="${enregistrement.typeRequete}" >
> 		  <html:option value="Publique" >
> 			<c:if test="${enregistrement.typeRequete ==
> 'Publique'}"><c:out 
> value="${enregistrement.typeRequete}" /></c:if>
> 		  </html:option>
> 		  <html:option value="Priv�e" >
> 			<c:if test="${enregistrement.typeRequete ==
> 'Priv�e'}"><c:out 
> value="${enregistrement.typeRequete}" /></c:if>
> 		  </html:option>
> 		</html:select >
> 	</td>
>   </tr>
>   </c:forEach>
> 
> the jsp result is good.
> 
> an extract of the html source producted by the jsp:
> <form name="entrantesForm" method="POST"
> action="/comsis/entrantes/EntrantesRequete.do">    
> 
> <table>
>  <tr>
>    <th></th>    
>    <th>Nom de la requete</th>
>    <th>Type dossier</th>  
>    <th>Type requete</th>
>  </tr>
>  
>    
>  <tr>
> <td><input type="radio" name="id" value="13"
> checked="checked" /></td>
>    <td>s</td>
>    <td>entrante</td>    
> <td><select name="colRequetes[0].typeRequete"
> size="1"><option value="Publique"
> selected="selected">Publique</option>
>  <option value="Priv�e">Priv�e</option></select>
> </td>
>  </tr>
>  
>    
>  <tr>
> <td><input type="radio" name="id" value="15" /></td>
>    <td>gbgh,gh</td>
>    <td>entrante</td>    
> <td><select name="colRequetes[1].typeRequete"
> size="1"><option value="Publique">Publique</option>
>  <option value="Priv�e"
> selected="selected">Priv�e</option></select>
> </td>
>  </tr>
>  
> </table>
> 
> 
> but, when i submit the form,
> the server says that:
> StandardWrapperValve[action]: "Servlet.service()"
> pour la servlet action a g�n�r� une exception
> javax.servlet.ServletException: BeanUtils.populate
> 	at
>
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1254)
> 	at
>
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:821)
> 	at
>
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
> 	at
>
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
> 	at
>
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
> 	at
>
javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
> 	at
>
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> 	at
>
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
> 	at
>
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
> ........
> ........
> ----- Root Cause -----
> java.lang.IndexOutOfBoundsException: Index: 0, Size:
> 0
> 	at
> java.util.ArrayList.RangeCheck(ArrayList.java:507)
> 	at java.util.ArrayList.get(ArrayList.java:324)
> 	at
>
org.apache.struts.action.DynaActionForm.get(DynaActionForm.java:298)
> 	at
>
org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils.java:474)
> 	at
>
org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils.java:428)
> 	at
>
org.apache.commons.beanutils.PropertyUtils.getNestedProperty(PropertyUtils.java:770)
> 	at
>
org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:801)
> 	at
>
org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:881)
> 	at
>
org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
> 	at
>
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1252)
> 	at
>
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:821)
> 	at
>
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
> 	at
>
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
> 	at
>
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
> 	at
>
javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
> 	at
>
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> 	at
>
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
> 	at
>
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
> .......
> .......
> the collection seems not be initialized, but
> *before* the request, the jsp display his
> content......
> crazy problem.......
> any helps will be very appreciated!!
> 
> thanks in advance,
> charles.
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org