users@woodstock.java.net

Re: TableColumn sorting

From: Dan Labrecque <Dan.Labrecque_at_Sun.COM>
Date: Mon, 12 May 2008 10:08:06 -0400

The JSP Standard Tag Library (JSTL) |length| tag might be useful, but
there are interoperability issues with JSTL and JavaServer Faces, so use
with caution. The JSF property resolver may not be able to evaluate the
EL expression after the JSP page has been parsed.

Dan

Jscud wrote:
> Hi,
>
> i'm trying to sort a tablecolumn which displays the number of elements of a
> java.util.List
> I've done this (using Netbeans VWP 6.1 and glassfish 2ur2 btw):
>
> <jsp:root version="2.1"
> ...xmlns:fn="http://java.sun.com/jsp/jstl/functions"> //Added this part to
> the VWP generated stuff
>
> ...
> <webuijsf:tableRowGroup id="tableRowGroup1" rows="20"
> sourceData="#{IlesControleur.iles}"
> sourceVar="currentRow">
>
> <webuijsf:tableColumn headerText="Communes"
> id="tableColumn7" sort="#{fn:length(currentRow.value['communes'])}"
> descending="true">
> <webuijsf:staticText id="staticText1"
> text="#{fn:length(currentRow.value['communes'])}"/>
> </webuijsf:tableColumn>
>
>
> #{IlesControleur.iles} returns a List of POJOs Ile which contains the
> property communes as a List too.
> When I sort the column the first time, all is going well (getting the
> communes size descending), but the second time i sort I got an exception:
> javax.el.ELException: Function 'fn:length' not found
> at
> com.sun.el.lang.ExpressionBuilder.visit(ExpressionBuilder.java:213)
> at com.sun.el.parser.SimpleNode.accept(SimpleNode.java:162)
> at
> com.sun.el.lang.ExpressionBuilder.prepare(ExpressionBuilder.java:178)
> at
> com.sun.el.lang.ExpressionBuilder.build(ExpressionBuilder.java:189)
> at
> com.sun.el.lang.ExpressionBuilder.createValueExpression(ExpressionBuilder.java:232)
> at
> com.sun.el.ExpressionFactoryImpl.createValueExpression(ExpressionFactoryImpl.java:92)
> at
> com.sun.webui.jsf.faces.ValueBindingSortCriteria.readObject(ValueBindingSortCriteria.java:220)
>
> If it says it doesnt find the 'fn:length' jstl function, it shouldn't work
> at all.
> Any idea on this?
> Thanks in advance
>
>
>