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.
When you specify for example the standard <f:convertDateTime>
by
converterId="javax.faces.DateTime"
, then you'll be able to use all its attributes such as
pattern
and locale
as per its documentation, but then with the possibility to supply
deferred value expressions.
<o:converter converterId="javax.faces.DateTime" pattern="#{item.pattern}" locale="#{item.locale}" />
The converter ID of all standard JSF 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.
The <o:converter>
is currently not compatible with converters which are managed via JSF 2.3's
new managed=true
attribute set on the FacesConverter
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>
, the managed=true
attribute needs to be removed, so that OmniFaces ConverterManager
will automatically manage them.
DeferredTagHandlerHelper
Modifier and Type | Class and Description |
---|---|
protected static class |
Converter.DeferredConverter
So that we can have a serializable converter.
|
delegateFactory
nextHandler, tag, tagId
Constructor and Description |
---|
Converter(ConverterConfig config)
The constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
apply(FaceletContext context,
UIComponent parent)
Create a
Converter based on the binding and/or converterId
attributes as per the standard JSF <f:converter> implementation and collect the render time
attributes. |
TagAttribute |
getTagAttribute(String name)
Just return TagHandler#getAttribute() via a public method (it's by default protected and otherwise thus
unavailable inside collectDeferredAttributes().
|
protected TagHandlerDelegate |
getTagHandlerDelegate() |
boolean |
isDisabled(FaceletContext context) |
getConverterId
applyAttachedObject, getAttachedObjectHandlerHelper, getFor
applyNextHandler, createMetaRuleset, getBinding, getTag, getTagId, setAttributes
getAttribute, getRequiredAttribute, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
applyAttachedObject, getFor
public Converter(ConverterConfig config)
config
- The converter config.public void apply(FaceletContext context, UIComponent parent) throws IOException
Converter
based on the binding
and/or converterId
attributes as per the standard JSF <f:converter>
implementation and collect the render time
attributes. Then create an anonymous Converter
implementation which wraps the created
Converter
and delegates the methods to it after setting the render time attributes. Finally set the
anonymous implementation on the parent component.apply
in interface FaceletHandler
apply
in class DelegatingMetaTagHandler
context
- The involved facelet context.parent
- The parent component to set the Converter
on.IOException
- If something fails at I/O level.public TagAttribute getTagAttribute(String name)
getTagAttribute
in class DelegatingMetaTagHandler
name
- The attribute name.protected TagHandlerDelegate getTagHandlerDelegate()
getTagHandlerDelegate
in class ConverterHandler
public boolean isDisabled(FaceletContext context)
isDisabled
in class DelegatingMetaTagHandler
Copyright © 2012–2022 OmniFaces. All rights reserved.