- java.lang.Object
-
- org.omnifaces.component.SimpleParam<T>
-
- Type Parameters:
T- The type of the value.
- All Implemented Interfaces:
ValueHolder,ParamHolder<T>
public class SimpleParam<T> extends Object implements ParamHolder<T>
This class provides a basic and default implementation of theParamHolderinterface. Ultimately, this class can be used as a simple key-value pair holder (parameter name-value) which uses an explicit/implicit Faces converter to convert the object value to string.- Since:
- 1.7
- Author:
- Bauke Scholtz
-
-
Constructor Summary
Constructors Constructor Description SimpleParam()Default constructor.SimpleParam(UIParameter param)Construct a simple param with name and value of givenUIParametercomponent.SimpleParam(String name, T value)Construct a simple param with name and value.SimpleParam(String name, T value, Converter<T> converter)Construct a simple param with name, value and converter.SimpleParam(ParamHolder<T> param)Construct a simple param with name, value and converter of givenParamHolderinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Converter<T>getConverter()Returns the converter, if any.TgetLocalValue()Returns the original, unconverted value of the parameter.StringgetName()Returns the name of the parameter.StringgetValue()Returns the value of the parameter asString.voidsetConverter(Converter converter)voidsetName(String name)Sets the parameter name.voidsetValue(Object value)
-
-
-
Constructor Detail
-
SimpleParam
public SimpleParam()
Default constructor.
-
SimpleParam
public SimpleParam(String name, T value)
Construct a simple param with name and value.- Parameters:
name- The parameter name.value- The parameter value.
-
SimpleParam
public SimpleParam(String name, T value, Converter<T> converter)
Construct a simple param with name, value and converter.- Parameters:
name- The parameter name.value- The parameter value.converter- The converter.
-
SimpleParam
public SimpleParam(UIParameter param)
Construct a simple param with name and value of givenUIParametercomponent.- Parameters:
param- TheUIParameterto copy.- Throws:
ClassCastException- When actual parameter value is notT.- Since:
- 2.2
-
SimpleParam
public SimpleParam(ParamHolder<T> param)
Construct a simple param with name, value and converter of givenParamHolderinstance.- Parameters:
param- TheParamHolderto copy.- Since:
- 2.2
-
-
Method Detail
-
getName
public String getName()
Description copied from interface:ParamHolderReturns the name of the parameter.- Specified by:
getNamein interfaceParamHolder<T>- Returns:
- The name of the parameter.
-
setName
public void setName(String name)
Sets the parameter name.- Parameters:
name- The parameter name.
-
getLocalValue
public T getLocalValue()
Description copied from interface:ParamHolderReturns the original, unconverted value of the parameter.- Specified by:
getLocalValuein interfaceParamHolder<T>- Specified by:
getLocalValuein interfaceValueHolder- Returns:
- The original, unconverted value of the parameter.
-
getValue
public String getValue()
Description copied from interface:ParamHolderReturns the value of the parameter asString. If the converter is set, or if any converter is available byApplication.createConverter(Class), passing the value's class, then return the result ofConverter.getAsString(jakarta.faces.context.FacesContext, jakarta.faces.component.UIComponent, Object), otherwise return theObject.toString()of the value.- Specified by:
getValuein interfaceParamHolder<T>- Specified by:
getValuein interfaceValueHolder- Returns:
- The value of the parameter as
String. - See Also:
Converter.getAsString(jakarta.faces.context.FacesContext, jakarta.faces.component.UIComponent, Object)
-
setValue
public void setValue(Object value)
- Specified by:
setValuein interfaceValueHolder- Throws:
ClassCastException- When actual value is notT.
-
getConverter
public Converter<T> getConverter()
Description copied from interface:ParamHolderReturns the converter, if any.- Specified by:
getConverterin interfaceParamHolder<T>- Specified by:
getConverterin interfaceValueHolder- Returns:
- The converter, if any.
-
setConverter
public void setConverter(Converter converter)
- Specified by:
setConverterin interfaceValueHolder
-
-