According to this answer multiple converters on single value are not supported. So I tried to build chained converter by employing bean helper:
// Bean.java
public Converter chained(Converter... converters) { return ...; }
// view.xhtml
<p:inputText ... converter=#{bean.chained(aConverter, bConverter)} />
Unfortunatelly, this is not possible due of EL cast exception (proxy can not be cast to Converter
nor to Object
). This is probably caused by SpringBeanFacesELResolver
registered in faces-config.xml.
Second attempt was try to build @FacesConverter
from component attributes, however UIComponent#getAttributes()
does not contain attributes where value is @Component
injection.
<f:attribute name="converter_a" value="#{aConverter}" />
So the only way I can think of is to provide in attribute converter id and try to find it in "ChainingConverter" instance somehow.
Do you know how to find converter by id?
UPDATE
I've also tried to pass converter method as MethodExpression
:
// Bean.java
public Converter chained(MethodExpression... expressions) { return ...; }
// view.xhtml
<p:inputText ... converter=#{bean.chained(aConverter.getAsString, bConverter.getAsString)} />
In this case {ConverterClass} does not have the property 'getAsString'
(It seems that passing an expressions is possible only in composites with method-signature attributes).
UPDATE
I have ended with solution which builds converter in backing bean:
// Bean.java
public Converter getConverter() { return ...; }
// view.xthml
<p:inputText ... converter=#{bean.converter} />