tag:blogger.com,1999:blog-29026849679131779342024-02-20T18:12:00.463-08:00Joe's BlogJoe Deanhttp://www.blogger.com/profile/13829736333464087854noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-2902684967913177934.post-58074751142783461362008-09-26T17:01:00.000-07:002008-09-26T17:37:25.984-07:00JSF1.2 and JSP2.1 unified EL not fully IntegratedI need to iterate through a List in a ListDataModel object using JSF 1.2 with JSP2.1 and JSTL 1.2. I was hoping to leverage the integration via the Unified EL. The following java.net <a href="http://wiki.java.net/bin/view/Projects/JavaServerFacesSpecFaq#12coreTags">FAQ</a> made this sound promising.<br /><br />BTW: I'm using Seam 2.0.2sp1 to make JSF integration with backing bean easier.<br /><br />Here's my backing bean:<br /><blockquote>@Name("test")<br />@Scope(ScopeType.CONVERSATION)<br />public class Test implements Serializable {<br /><br />/**<br /> *<br /> */<br />private static final long serialVersionUID = 7261056085418809473L;<br /><br />@DataModel<br />private List<list><string>> items;<br /><br />@Factory(value="items")<br />public void findItems() {<br /> items = new ArrayList<list><string>>();<br /> List<string> first=new ArrayList<string>();<br /> first.add("fvalue1");<br /> first.add("fValue2");<br /> first.add("fvalue3");<br /> items.add(first);<br /> List<string> second=new ArrayList<string>();<br /> second.add("svalue1");<br /> second.add("sValue2");<br /> second.add("svalue3");<br /> items.add(second);<br />}<br />}</string></string></string></string></string></list></string></list></blockquote><br /><br />And Here's my JSP page:<br /><br /><pre><br /><?xml version="1.0"?><br /><jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"<br /> xmlns:c="http://java.sun.com/jsp/jstl/core"<br /> xmlns:h="http://java.sun.com/jsf/html"<br /> xmlns:f="http://java.sun.com/jsf/core"<br /> xmlns:s="http://jboss.com/products/seam/taglib"<br /> xmlns="http://www.w3.org/1999/xhtml"<br /> version="2.1"><br /><jsp:output doctype-root-element="html"<br /> doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"<br /> doctype-system="http://www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/><br /><jsp:directive.page contenttype="text/html"><br /><html><br /><head><br /><title>Test</title><br /></head><br /><body><br /><h1>Test</h1><br /><br /><f:view><br /> <table><br /> <c:foreach items="#{items.wrappedData}" var="_item"><br /> <c:foreach items="#{_item}" var="val"><br /> <tr><td><br /> <h:outputtext value="#{val}"></h:outputText><br /> </td></tr><br /> </c:forEach><br /> </c:forEach><br /> </table><br /><br /></f:view><br /></body><br /></html><br /></jsp:root><br /></pre><br /><br />This works and produces the following results:<br /><br /><pre><br />fvalue1<br />fValue2<br />fvalue3<br />svalue1<br />sValue2<br />svalue3<br /></pre><br /><br />Which is exactly what I want, but when I do the following it fails.<br /><pre><br /><?xml version="1.0"?><br /><jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"<br /> xmlns:c="http://java.sun.com/jsp/jstl/core"<br /> xmlns:h="http://java.sun.com/jsf/html"<br /> xmlns:f="http://java.sun.com/jsf/core"<br /> xmlns:s="http://jboss.com/products/seam/taglib"<br /> xmlns="http://www.w3.org/1999/xhtml"<br /> version="2.1"><br /><jsp:output doctype-root-element="html"<br /> doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"<br /> doctype-system="http://www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/><br /><jsp:directive.page contenttype="text/html"><br /><html><br /><head><br /><title>Test</title><br /></head><br /><body><br /><h1>Test</h1><br /><br /><f:view><br /> <table><br /> <c:foreach items="#{items.wrappedData}" var="_item"><br /> <c:foreach items="#{_item}" var="val"><br /> <tr><td><br /> <h:outputtext value="#{val}"></h:outputText><br /> </td></tr><br /> </c:forEach><br /> </c:forEach><br /> </table><br /><br /></f:view><br /></body><br /></html><br /></jsp:root><br /><br />This fails with the following exception:<br /><blockquote>root cause<br /><br />javax.servlet.ServletException: javax.servlet.jsp.JspTagException:<br /> Don't know how to iterate over supplied "items" in &lt;forEach&gt;<br /> org.apache.jasper.runtime.PageContextImpl.doHandlePageException<br /> (PageContextImpl.java:850)</blockquote><br /><br />So, it seams you can not access the referenced #{_item} in the<br />forEach.<br /><br /></pre>Joe Deanhttp://www.blogger.com/profile/13829736333464087854noreply@blogger.com1