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

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by org.apache.myfaces.orchestra.conversation.jsf.components.ConverterTag
All Implemented Interfaces:
Serializable, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.Tag

public class ConverterTag
extends javax.servlet.jsp.tagext.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:

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
ConverterTag()
           
 
Method Summary
protected static javax.faces.convert.Converter createConverter(String beanName)
          Override this method in order to customise the bean instance.
 int doStartTag()
           
 void release()
           
 void setBeanName(String beanName)
           
 void setUseWrapper(boolean enabled)
           
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
doAfterBody, doEndTag, findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
 
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(String beanName)

setUseWrapper

public void setUseWrapper(boolean enabled)

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class javax.servlet.jsp.tagext.TagSupport
Throws:
javax.servlet.jsp.JspException

release

public void release()
Specified by:
release in interface javax.servlet.jsp.tagext.Tag
Overrides:
release in class javax.servlet.jsp.tagext.TagSupport

createConverter

protected static javax.faces.convert.Converter createConverter(String beanName)
                                                        throws javax.servlet.jsp.JspException
Override this method in order to customise the bean instance.

Throws:
javax.servlet.jsp.JspException


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