Class Converter
-
- All Implemented Interfaces:
AttachedObjectHandler
,FaceletHandler
,ValueHolderAttachedObjectHandler
public class Converter extends ConverterHandler
The
<o:converter>
is a taghandler that extends the standard<f:converter>
tag family with support for deferred value expressions in all attributes. In other words, the converter attributes are not evaluated anymore on a per view build time basis, but just on every access like as with UI components and bean properties. This has among others the advantage that they can be evaluated on a per-iteration basis inside an iterating component, and that they can be set on a custom converter without needing to explicitly register it in a tagfile.Usage
When you specify for example the standard
<f:convertDateTime>
byconverterId="jakarta.faces.DateTime"
, then you'll be able to use all its attributes such aspattern
andlocale
as per its documentation, but then with the possibility to supply deferred value expressions.<o:converter converterId="jakarta.faces.DateTime" pattern="#{item.pattern}" locale="#{item.locale}" />
The converter ID of all standard Faces converters can be found in their javadocs. First go to the javadoc of the class of interest, then go to
CONVERTER_ID
in its field summary and finally click the Constant Field Values link to see the value.JSF 2.3 compatibility
The
<o:converter>
is currently not compatible with converters which are managed via themanaged=true
attribute set on theFacesConverter
annotation, at least not when using Mojarra. Internally, the converters are wrapped in another instance which doesn't have the needed setter methods specified. In order to get them to work with<o:converter>
, themanaged=true
attribute needs to be removed, so that OmniFacesConverterManager
will automatically manage them.- Author:
- Bauke Scholtz
- See Also:
DeferredTagHandlerHelper
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
Converter.DeferredConverter
So that we can have a serializable converter.
-
Field Summary
-
Fields inherited from class jakarta.faces.view.facelets.DelegatingMetaTagHandler
delegateFactory
-
Fields inherited from class jakarta.faces.view.facelets.TagHandler
nextHandler, tag, tagId
-
-
Constructor Summary
Constructors Constructor Description Converter(ConverterConfig config)
The constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
apply(FaceletContext context, UIComponent parent)
Create aConverter
based on thebinding
and/orconverterId
attributes as per the standard Faces<f:converter>
implementation and collect the render time attributes.TagAttribute
getTagAttribute(String name)
protected TagHandlerDelegate
getTagHandlerDelegate()
boolean
isDisabled(FaceletContext context)
-
Methods inherited from class jakarta.faces.view.facelets.ConverterHandler
getConverterId
-
Methods inherited from class jakarta.faces.view.facelets.FaceletsAttachedObjectHandler
applyAttachedObject, getAttachedObjectHandlerHelper, getFor
-
Methods inherited from class jakarta.faces.view.facelets.DelegatingMetaTagHandler
applyNextHandler, createMetaRuleset, getBinding, getTag, getTagId, setAttributes
-
Methods inherited from class jakarta.faces.view.facelets.TagHandler
getAttribute, getRequiredAttribute, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jakarta.faces.view.AttachedObjectHandler
applyAttachedObject, getFor
-
-
-
-
Constructor Detail
-
Converter
public Converter(ConverterConfig config)
The constructor.- Parameters:
config
- The converter config.
-
-
Method Detail
-
apply
public void apply(FaceletContext context, UIComponent parent) throws IOException
Create aConverter
based on thebinding
and/orconverterId
attributes as per the standard Faces<f:converter>
implementation and collect the render time attributes. Then create an anonymousConverter
implementation which wraps the createdConverter
and delegates the methods to it after setting the render time attributes. Finally set the anonymous implementation on the parent component.- Specified by:
apply
in interfaceFaceletHandler
- Overrides:
apply
in classDelegatingMetaTagHandler
- Parameters:
context
- The involved facelet context.parent
- The parent component to set theConverter
on.- Throws:
IOException
- If something fails at I/O level.
-
getTagAttribute
public TagAttribute getTagAttribute(String name)
- Overrides:
getTagAttribute
in classDelegatingMetaTagHandler
-
getTagHandlerDelegate
protected TagHandlerDelegate getTagHandlerDelegate()
- Overrides:
getTagHandlerDelegate
in classConverterHandler
-
isDisabled
public boolean isDisabled(FaceletContext context)
- Overrides:
isDisabled
in classDelegatingMetaTagHandler
-
-