com.ibm.xsp.convert
Class BooleanConverter

java.lang.Object
  extended by javax.faces.convert.BooleanConverter
      extended by com.ibm.xsp.convert.BooleanConverter
All Implemented Interfaces:
ComponentBindingObject, ValueBindingObject, ClientSideConverter, javax.faces.component.StateHolder, javax.faces.convert.Converter

public class BooleanConverter
extends javax.faces.convert.BooleanConverter
implements ValueBindingObject, ComponentBindingObject, javax.faces.component.StateHolder, ClientSideConverter

The xp:convertDateTime tag converts a String value to a Boolean, true or false value. The conversion is not locale-aware, so translated versions of the words "true" and "false" are not supported. In the default non-strict mode, Strings that are a case in-sensitive match for "true" result in the boolean true, while all other values result in the boolean false. In strict mode, the check for true is the same, but there is also a case-insensitive check for "false", which results in the boolean false, and other values (neither "true" nor "false") will give a validation error. In either case, a null or empty string value will result in a null Boolean. This has both client-side and server-side validation.

Since:
9.0.0 Added in version 9.0

Field Summary
static java.lang.String CONVERTER_ID
          The converter id for this converter, which can be used as a value for the tag property: ConverterImpl.setConverterId(String).
 
Constructor Summary
BooleanConverter()
           
 
Method Summary
 java.lang.String generateClientSideConverter(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Generate client side conversion.
 java.lang.Object getAsObject(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.String value)
          Converts the value from a String to null or a java.lang.Boolean, possibly throwing a ConverterException.
 java.lang.String getAsString(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.Object value)
          Converts the value to a String from either null (converts to ""), or from a Boolean object.
 javax.faces.component.UIComponent getComponent()
          See ValueBindingObjectImpl.getComponent()
protected  java.lang.String getDefaultMessage()
           
protected  javax.faces.context.FacesContext getFacesContext()
          Helper method to return the current FacesContext.
 java.lang.String getMessage()
          The message property specified in the XPage source, used when strict=true.
 javax.faces.el.ValueBinding getValueBinding(java.lang.String name)
          See ValueBindingObjectImpl.getValueBinding(String)
 boolean isStrict()
          Enforces strict conversion so only the text "false" will be saved as false.
 boolean isTransient()
          See ValueBindingObjectImpl.isTransient()
 void restoreState(javax.faces.context.FacesContext context, java.lang.Object value)
          See ValueBindingObjectImpl.restoreState(FacesContext, Object)
 java.lang.Object saveState(javax.faces.context.FacesContext context)
          See ValueBindingObjectImpl.saveState(FacesContext)
 void setComponent(javax.faces.component.UIComponent component)
          See ValueBindingObjectImpl.setComponent(UIComponent)
 void setMessage(java.lang.String message)
          Sets the validation error message used when in strict mode and the submitted value does not match "true" or "false".
 void setStrict(boolean strict)
          Sets the strictness mode, by default is non-strict.
 void setTransient(boolean transientFlag)
          See ValueBindingObjectImpl.setTransient(boolean)
 void setValueBinding(java.lang.String name, javax.faces.el.ValueBinding binding)
          See ValueBindingObjectImpl.setValueBinding(String, ValueBinding)
 
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 java.lang.String CONVERTER_ID
The converter id for this converter, which can be used as a value for the tag property: ConverterImpl.setConverterId(String).

See Also:
Constant Field Values
Constructor Detail

BooleanConverter

public BooleanConverter()
Method Detail

getAsObject

public java.lang.Object getAsObject(javax.faces.context.FacesContext context,
                                    javax.faces.component.UIComponent component,
                                    java.lang.String value)
Converts the value from a String to null or a java.lang.Boolean, possibly throwing a ConverterException.

Specified by:
getAsObject in interface javax.faces.convert.Converter
Overrides:
getAsObject in class javax.faces.convert.BooleanConverter
Throws:
javax.faces.convert.ConverterException
See Also:
BooleanConverter.getAsObject(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.String)

getDefaultMessage

protected java.lang.String getDefaultMessage()
Returns:
the default translated validation message to use when in strict mode and a non-true, non-false value is supplied.

getAsString

public java.lang.String getAsString(javax.faces.context.FacesContext context,
                                    javax.faces.component.UIComponent component,
                                    java.lang.Object value)
Converts the value to a String from either null (converts to ""), or from a Boolean object.

Specified by:
getAsString in interface javax.faces.convert.Converter
Overrides:
getAsString in class javax.faces.convert.BooleanConverter
See Also:
BooleanConverter.getAsString(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.Object)

getMessage

public java.lang.String getMessage()
The message property specified in the XPage source, used when strict=true. Specifies the message that will be displayed when failing to convert from a String to an object. This is only used when the Strict Conversion is enabled. The message is displayed when the page is submitted.

Returns:
the message

setMessage

public void setMessage(java.lang.String message)
Sets the validation error message used when in strict mode and the submitted value does not match "true" or "false".

Parameters:
message - the message to set

isStrict

public boolean isStrict()
Enforces strict conversion so only the text "false" will be saved as false. By default the conversion is lenient, so that any value other than "true" is saved as false. The conversion is always case insensitive, even when using strict conversion.

Returns:
the strictness configuration

setStrict

public void setStrict(boolean strict)
Sets the strictness mode, by default is non-strict.

Parameters:
strict - the strict to set

getFacesContext

protected javax.faces.context.FacesContext getFacesContext()
Helper method to return the current FacesContext. This method is commonly present in implementors of ValueBindingObject.


getValueBinding

public javax.faces.el.ValueBinding getValueBinding(java.lang.String name)
See ValueBindingObjectImpl.getValueBinding(String)

Specified by:
getValueBinding in interface ValueBindingObject
Parameters:
name - Name of the property
Returns:
ValueBinding instance to used to calculate the value for the specified property
See Also:
ValueBindingObject.getValueBinding(java.lang.String)

setValueBinding

public void setValueBinding(java.lang.String name,
                            javax.faces.el.ValueBinding binding)
See ValueBindingObjectImpl.setValueBinding(String, ValueBinding)

Specified by:
setValueBinding in interface ValueBindingObject
Parameters:
name - Name of the property
binding - The ValueBinding to set, or null to remove an existing ValueBinding
See Also:
ValueBindingObject.setValueBinding(java.lang.String, javax.faces.el.ValueBinding)

setComponent

public void setComponent(javax.faces.component.UIComponent component)
See ValueBindingObjectImpl.setComponent(UIComponent)

Specified by:
setComponent in interface ComponentBindingObject
See Also:
ComponentBindingObject.setComponent(javax.faces.component.UIComponent)

getComponent

public javax.faces.component.UIComponent getComponent()
See ValueBindingObjectImpl.getComponent()

Specified by:
getComponent in interface ComponentBindingObject
Returns:
the associated UIComponent instance
See Also:
ComponentBindingObject.getComponent()

isTransient

public boolean isTransient()
See ValueBindingObjectImpl.isTransient()

Specified by:
isTransient in interface javax.faces.component.StateHolder
See Also:
StateHolder.isTransient()

setTransient

public void setTransient(boolean transientFlag)
See ValueBindingObjectImpl.setTransient(boolean)

Specified by:
setTransient in interface javax.faces.component.StateHolder
See Also:
StateHolder.setTransient(boolean)

saveState

public java.lang.Object saveState(javax.faces.context.FacesContext context)
See ValueBindingObjectImpl.saveState(FacesContext)

Specified by:
saveState in interface javax.faces.component.StateHolder
See Also:
StateHolder.saveState(javax.faces.context.FacesContext)

generateClientSideConverter

public java.lang.String generateClientSideConverter(javax.faces.context.FacesContext context,
                                                    javax.faces.component.UIComponent component)
                                             throws java.io.IOException
Description copied from interface: ClientSideConverter
Generate client side conversion.

Specified by:
generateClientSideConverter in interface ClientSideConverter
Throws:
java.io.IOException
See Also:
ClientSideConverter.generateClientSideConverter(javax.faces.context.FacesContext, javax.faces.component.UIComponent)

restoreState

public void restoreState(javax.faces.context.FacesContext context,
                         java.lang.Object value)
See ValueBindingObjectImpl.restoreState(FacesContext, Object)

Specified by:
restoreState in interface javax.faces.component.StateHolder
See Also:
StateHolder.restoreState(javax.faces.context.FacesContext, java.lang.Object)