org.apache.myfaces.orchestra.conversation.jsf.components
Class ConverterTag

java.lang.Object
  extended by TagSupport
      extended by org.apache.myfaces.orchestra.conversation.jsf.components.ConverterTag

public class ConverterTag
extends TagSupport

Works like f:converter except that the converter instance is a managed-bean instance rather than a simple class.

In addition, the retrieved Converter instance is (by default) wrapped in a SerializableConverter instance. See the documentation for that class for further details.

This is not actually orchestra-specific functionality; this is something that the JSF core library could offer, or an add-on library such as Tomahawk. But at the current time, no common library offers this feature and the use of a SerializableConverter wrapper is very convenient.

The primary use-case for this tag is custom Converter classes that access conversation state. For example, a Converter may be written to convert an object instance into a string by reading its primary key, and on postback convert the string (a primary key) back into an object instance by loading it using the persistence context associated with a particular conversation. Of course such a converter must be configured with the appropriate Orchestra scope, and therefore must be loaded as a managed bean rather than via the standard f:converter mechanism.

An alternative to using this tag is simply to use the standard "converter" attribute available on most JSF component tags, but if a SerializableConverter wrapper is desired then two bean definitions are needed rather than just one; see class SerializableConverter for details.

Creating custom converter tags

If you have written a custom Converter instance that can be configured then configuration may be done via the managed-bean system. However it can also be nice to configure instances via the tag, like the standard f:dateTimeConverter or f:numberConverter. To do this, you can:


Constructor Summary
ConverterTag()
           
 
Method Summary
protected static Converter createConverter(java.lang.String beanName)
          Override this method in order to customise the bean instance.
 int doStartTag()
           
 void release()
           
 void setBeanName(java.lang.String beanName)
           
 void setUseWrapper(boolean enabled)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConverterTag

public ConverterTag()
Method Detail

setBeanName

public void setBeanName(java.lang.String beanName)

setUseWrapper

public void setUseWrapper(boolean enabled)

doStartTag

public int doStartTag()
               throws JspException
Throws:
JspException

release

public void release()

createConverter

protected static Converter createConverter(java.lang.String beanName)
                                    throws JspException
Override this method in order to customise the bean instance.

Throws:
JspException


Copyright © 2009 The Apache Software Foundation. All Rights Reserved.