users@javaserverfaces.java.net

Re: How do I define a function to be used with Unified Expression Language in JSF?

From: Raymond DeCampo <rdecampo_at_twcny.rr.com>
Date: Sun, 13 Apr 2008 11:20:15 -0400

Todd Patrick wrote:
> I'm Reading the section "Unified Expression Language" in the Java EE
> Tutorial.
>
> The JSP expression language allows you to define a function that can be
> invoked in an
> expression.
>
> What I'd like to do is the following:
>
> 1.) Within a h:dataTable I have a JSF component that looks like this:
>
> <h:dataTable var="row" value="#{mybean.clientList}">
> ...
> <h:outputText value="#{row.clientCreated}"/>
>
> "mybean" is in request scope and the clientList is a List<Client>. The
> clientCreated property returns a Long which is the milliseconds of the
> Date Time of when the Client was added.
>
>
> 2.) I have a public String method in the same "mybean" that converts
> milliseconds to a human readable date time format.
>
> public String myClientTime(Long milliseconds){
> }
>
>
> 3.) Is it possible to do something like this?
>
> <h:dataTable var="row" value="#{mybean.clientList}">
> ...
> <h:outputText value="#{mybean.myClientTime(row.clientCreated)}"/>
>
>
> I don't control the List<Client> that is provided to the value of the
> h:dataTable, so I can't convert the milliseconds to a human readable
> format before I display the value in the h:outputText component.
>
> I appreciate any suggestions on the best way to do this.
>
I would write a custom converter that invokes the desired static method.

Ray