Placing a converted value inside a rich:simpleTogglePanel label

Tags: , , ,



I’m in a situation where I need to place a date value inside a rich:simpleTogglePanel label. The problem is I need to converter the date prior to displaying it, using

<h:outputText converter="#{dateTimeConverter}" value="#{date}" />

Then I need to place another string in front of it. Unfortunately label is an attribute and only takes a string.

Is there anyway to do this? Any undocumented label facet? I’m using Richfaces version 3.3.3.Final.

Answer

I don’t know of any undocumented facets, thus using plain Java EL you’d have to provide a getter that returns the formatted date string.

Another option would be to use JBoss EL, which is an extension to the standard Java EL and allows to call methods with parameters.

You then could do something like this: label="#{dateTimeConverter.convert(date)}".
We use this a lot and it works like a charm.

Note the following:

  • you’d have use facelets with JBoss EL, JSP doesn’t work quite well
  • although JBoss EL is part of JBoss Seam, it can be used in a standalone way


Source: stackoverflow