Probleme JSTL <c:foreach >
Bonjour.
Contexte : ExtremeComponents + Struts2 (Tiles2) + Spring2 + Hibernate3 / Tomcat 6.0.10 / WinXP
Problème : je n'arrive pas à itérer sur les propriétés d'objet qui sont des Collections.
Détails : dans <ec:table>, les propriétés items et var fonctionnent comme pour le tag <c:forEach>. L'itération fonctionne bien car toutes les lignes du tableau sont crées.
On peut accéder correctement à l'arborescence des objets comme le montre ceci : ${usr.contact.contactNameFirst}, qui fonctionne parfaitement.
Par contre, si je veux itérer sur les propriétés ${usr.projects} ou ${usr.projects} qui sont des Collections (cf <c:forEach> dans le code) j'ai l'erreur suivante :
Citation:
GRAVE: "Servlet.service()" pour la servlet jsp a lancé une exception
javax.servlet.jsp.JspException: TableTag Problem: javax.el.PropertyNotFoundException: Property '0' not found on type org.hibernate.collection.PersistentSet
at javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:193)
at javax.el.BeanELResolver.property(BeanELResolver.java:267)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:60)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
at org.apache.el.parser.AstValue.getValue(AstValue.java:97)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:928)
...
at org.extremecomponents.table.tag.TableTag.doCatch(TableTag.java:488)
at org.apache.jsp.WEB_002dINF.string.users_jsp._jspx_meth_ec_005ftable_005f0(users_jsp.java:148)
at org.apache.jsp.WEB_002dINF.string.users_jsp._jspService(users_jsp.java:77)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
...
Si l'on supprime le <c:forEach>, l'affichage de la propriété ${usr.projects} donne bien un vecteur :
Citation:
[com.iscd.bi.hibernate3.Project@408893, com.iscd.bi.hibernate3.Project@16999c8, com.iscd.bi.hibernate3.Project@1ef3d12, com.iscd.bi.hibernate3.Project@1a80e5a, com.iscd.bi.hibernate3.Project@1264c84, com.iscd.bi.hibernate3.Project@1927504, com.iscd.bi.hibernate3.Project@54cbb9]
Voici le code ma JSP :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| <%@ taglib prefix="s" uri="/struts-tags"
%><%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"
%><%@ taglib uri="http://acegisecurity.org/authz" prefix="authz"
%><%@ taglib prefix="ec" uri="http://www.extremecomponents.org"
%><%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"
%><div class="main" >
<br/>
<ec:table items="users" var="usr" action="users.action" title="Users" imagePath="/bi/img/table/*.gif">
<ec:exportPdf fileName="projects.pdf"/>
<ec:exportXls fileName="projects.xls"/>
<ec:row highlightRow="true">
<ec:column property="userId" title="User">
<s:a href="">${usr.userId}</s:a>
</ec:column>
<ec:column property="contactName" title="Contact">
<s:a href="">${usr.contact.contactNameFirst} ${usr.contact.contactNameLast} (${usr.contact.contactCompanyId})</s:a>
</ec:column>
<ec:column property="roles" title="Roles">
<s:a href="">${usr.roles}</s:a>
</ec:column>
<ec:column property="projects" title="Projects">
<s:a href="">${ usr.projects}</s:a>
</ec:column>
<ec:column property="projectsName" title="Projects">
<c:forEach items="${usr.projects}" var="prj">${prj.projectNameShort}</c:forEach>
</ec:column>
</ec:row>
</ec:table>
<s:debug></s:debug>
</div> |
Pouvez-vous m'aider SVP ?
Merci
PPDL.