Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSF converter for f:param

Tags:

jsf

el

I'm using dynamically created links:

          <h:link outcome="/page" value="#{name}">
            <f:param name="name" value="#{name}"/>
          </h:link>

I would like to attach custom converter for f:param to remove spaces from #{name} etc. But there is no converter property in f:param.

like image 763
karolkpl Avatar asked Oct 14 '11 11:10

karolkpl


2 Answers

A Converter is intented to convert from submitted String request parameter values to complex objects and vice versa in input fields. However, the <f:param> is pure output only and it will always call toString() on the value. It doesn't support a Converter.

Your cleanest and best bet is to create a custom EL function, so that you ultimately end up like:

<f:param name="name" value="#{util:prettyUrl(name)}"/>

Update: the JSF utility library OmniFaces has since version 1.4 (March 2013) a <o:param> component which extends the <f:param> with support for a fullworthy JSF converter, exactly like as you'd use in <h:outputText converter>.

<h:link outcome="/page" value="#{name}">
    <o:param name="name" value="#{name}" converter="somePrettyURLConverter" />
</h:link>

See also the showcase.

like image 129
BalusC Avatar answered Oct 22 '22 13:10

BalusC


what if you do something like this?

<f:param name="name" value="#{name.replace(' ', '')}" />

Isn't this working?

Or you want for all < f:param ... ??

Regards

like image 22
Alex Avatar answered Oct 22 '22 14:10

Alex