org.apache.myfaces.commons.converter
Class BooleanConverter

java.lang.Object
  extended by org.apache.myfaces.commons.converter.BooleanConverter
All Implemented Interfaces:
javax.faces.component.StateHolder, javax.faces.convert.Converter

@JSFConverter(name="mcc:convertBoolean",
              tagClass="org.apache.myfaces.commons.converter.ConvertBooleanTag",
              serialuidtag="-6004262065580818687L")
public class BooleanConverter
extends Object
implements javax.faces.convert.Converter, javax.faces.component.StateHolder

Converter that translates between boolean values (true/false) and alternate versions of those boolean values like (yes/no), (1/0), and (way/no way).

To customize the representation of a boolean true and false, use setTrueValue(String) and setFalseValue(String) respectively. If not configured with these setter methods, it defaults to true and false.

The values are case sensitive.

Author:
Ken Weiner

Field Summary
static String CONVERTER_ID
           
 
Constructor Summary
BooleanConverter()
           
 
Method Summary
 Object getAsObject(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent uiComponent, String value)
           
 String getAsString(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent uiComponent, Object value)
           
 String getFalseValue()
          Value representing a boolean false, e.g.
 String getTrueValue()
          Value representing a boolean true, e.g.
 boolean isTransient()
           
 void restoreState(javax.faces.context.FacesContext context, Object state)
           
 Object saveState(javax.faces.context.FacesContext context)
           
 void setFalseValue(String falseValue)
           
 void setTransient(boolean newTransientValue)
           
 void setTrueValue(String trueValue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONVERTER_ID

public static final String CONVERTER_ID
See Also:
Constant Field Values
Constructor Detail

BooleanConverter

public BooleanConverter()
Method Detail

getFalseValue

@JSFProperty
public String getFalseValue()
Value representing a boolean false, e.g. FALSE, no, 0, etc.


setFalseValue

public void setFalseValue(String falseValue)

getTrueValue

@JSFProperty
public String getTrueValue()
Value representing a boolean true, e.g. TRUE, yes, 1, etc.


setTrueValue

public void setTrueValue(String trueValue)

getAsObject

public Object getAsObject(javax.faces.context.FacesContext facesContext,
                          javax.faces.component.UIComponent uiComponent,
                          String value)
                   throws javax.faces.convert.ConverterException
Specified by:
getAsObject in interface javax.faces.convert.Converter
Throws:
javax.faces.convert.ConverterException

getAsString

public String getAsString(javax.faces.context.FacesContext facesContext,
                          javax.faces.component.UIComponent uiComponent,
                          Object value)
                   throws javax.faces.convert.ConverterException
Specified by:
getAsString in interface javax.faces.convert.Converter
Throws:
javax.faces.convert.ConverterException

isTransient

public boolean isTransient()
Specified by:
isTransient in interface javax.faces.component.StateHolder

setTransient

public void setTransient(boolean newTransientValue)
Specified by:
setTransient in interface javax.faces.component.StateHolder

restoreState

public void restoreState(javax.faces.context.FacesContext context,
                         Object state)
Specified by:
restoreState in interface javax.faces.component.StateHolder

saveState

public Object saveState(javax.faces.context.FacesContext context)
Specified by:
saveState in interface javax.faces.component.StateHolder


Copyright © 2007-2011 The Apache Software Foundation. All Rights Reserved.