Class MenuRenderer
- java.lang.Object
-
- jakarta.faces.render.Renderer
-
- com.sun.faces.renderkit.html_basic.HtmlBasicRenderer
-
- com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer
-
- com.sun.faces.renderkit.html_basic.MenuRenderer
-
- Direct Known Subclasses:
ListboxRenderer
,SelectManyCheckboxListRenderer
public class MenuRenderer extends HtmlBasicInputRenderer
MenuRenderer is a class that renders the current value ofUISelectOne
orUISelectMany
component as a list of menu options.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.sun.faces.renderkit.html_basic.HtmlBasicRenderer
HtmlBasicRenderer.OptionComponentInfo, HtmlBasicRenderer.Param
-
-
Field Summary
-
Fields inherited from class com.sun.faces.renderkit.html_basic.HtmlBasicRenderer
EMPTY_PARAMS, logger
-
Fields inherited from class jakarta.faces.render.Renderer
PASSTHROUGH_RENDERER_LOCALNAME_KEY
-
-
Constructor Summary
Constructors Constructor Description MenuRenderer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Collection<Object>
bestGuess(Class<? extends Collection<Object>> type, int initialSize)
protected Collection<Object>
cloneValue(Object value)
Utility method to invoke the theclone
method on the provided value.protected Object
coerceToModelType(FacesContext ctx, Object value, Class<?> itemValueType)
protected boolean
containsaValue(Object valueArray)
Object
convertSelectManyValue(FacesContext context, UISelectMany uiSelectMany, String[] newValues)
protected Object
convertSelectManyValuesForArray(FacesContext context, UISelectMany uiSelectMany, Class<?> elementType, String[] newValues)
protected Collection<Object>
convertSelectManyValuesForCollection(FacesContext context, UISelectMany uiSelectMany, Class<? extends Collection<Object>> collectionType, String[] newValues)
protected Object
convertSelectManyValuesForModel(FacesContext context, UISelectMany uiSelectMany, Class<?> modelType, String[] newValues)
Object
convertSelectOneValue(FacesContext context, UISelectOne uiSelectOne, String newValue)
protected Collection<Object>
createCollection(Collection<Object> collection, Class<? extends Collection<Object>> fallBackType)
protected Collection<Object>
createCollectionFromHint(Object collectionTypeHint)
Create a collection from the provided hint.void
decode(FacesContext context, UIComponent component)
Decode any new state of the specifiedUIComponent
from the request contained in the specifiedFacesContext
, and store that state on theUIComponent
.void
encodeBegin(FacesContext context, UIComponent component)
Render the beginning specifiedUIComponent
to the output stream or writer associated with the response we are creating.void
encodeEnd(FacesContext context, UIComponent component)
Render the ending of the current state of the specifiedUIComponent
, following the rules described forencodeBegin()
to acquire the appropriate value to be rendered.Object
getConvertedValue(FacesContext context, UIComponent component, Object submittedValue)
Attempt to convert previously stored state information into an object of the type required for this component (optionally using the registeredConverter
for this component, if there is one).protected Object
getCurrentSelectedValues(UIComponent component)
protected String
getMultipleText(UIComponent component)
protected Object[]
getSubmittedSelectedValues(UIComponent component)
protected static boolean
isHideNoSelection(UIComponent component)
protected boolean
isSelected(FacesContext context, UIComponent component, Object itemValue, Object valueArray, Converter<?> converter)
protected boolean
renderOption(FacesContext context, UIComponent component, UIComponent selectComponent, Converter<?> converter, SelectItem curItem, Object currentSelections, Object[] submittedValues, HtmlBasicRenderer.OptionComponentInfo optionInfo)
protected int
renderOptions(FacesContext context, UIComponent component, SelectItemsIterator<SelectItem> items)
protected void
renderSelect(FacesContext context, UIComponent component)
protected void
writeDefaultSize(ResponseWriter writer, int itemCount)
-
Methods inherited from class com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer
getNonOnChangeBehaviors, getNonOnClickSelectBehaviors, getValue, setSubmittedValue
-
Methods inherited from class com.sun.faces.renderkit.html_basic.HtmlBasicRenderer
augmentIdReference, convertClientId, decodeBehaviors, encodeRecursive, getBehaviorParameters, getChildren, getCurrentValue, getEndTextToRender, getFacet, getForComponent, getFormattedValue, getFormattedValue, getMessageIter, getParamList, getPassThruBehaviors, getRendersChildren, isBehaviorSource, rendererParamsNotNull, shouldDecode, shouldEncode, shouldEncodeChildren, shouldWriteIdAttribute, writeIdAttributeIfNecessary
-
Methods inherited from class jakarta.faces.render.Renderer
encodeChildren
-
-
-
-
Method Detail
-
convertSelectManyValue
public Object convertSelectManyValue(FacesContext context, UISelectMany uiSelectMany, String[] newValues) throws ConverterException
- Throws:
ConverterException
-
convertSelectOneValue
public Object convertSelectOneValue(FacesContext context, UISelectOne uiSelectOne, String newValue) throws ConverterException
- Throws:
ConverterException
-
decode
public void decode(FacesContext context, UIComponent component)
Description copied from class:Renderer
Decode any new state of the specified
UIComponent
from the request contained in the specifiedFacesContext
, and store that state on theUIComponent
.During decoding, events may be enqueued for later processing (by event listeners that have registered an interest), by calling
queueEvent()
on the associatedUIComponent
.- Overrides:
decode
in classHtmlBasicRenderer
- Parameters:
context
-FacesContext
for the request we are processingcomponent
-UIComponent
to be decoded.
-
encodeBegin
public void encodeBegin(FacesContext context, UIComponent component) throws IOException
Description copied from class:Renderer
Render the beginning specified
UIComponent
to the output stream or writer associated with the response we are creating. If the conversion attempted in a previous call togetConvertedValue()
for this component failed, the state information saved during execution ofdecode()
should be used to reproduce the incorrect input.- Overrides:
encodeBegin
in classRenderer
- Parameters:
context
-FacesContext
for the request we are processingcomponent
-UIComponent
to be rendered- Throws:
IOException
- if an input/output error occurs while rendering
-
encodeEnd
public void encodeEnd(FacesContext context, UIComponent component) throws IOException
Description copied from class:Renderer
Render the ending of the current state of the specified
UIComponent
, following the rules described forencodeBegin()
to acquire the appropriate value to be rendered.- Overrides:
encodeEnd
in classHtmlBasicRenderer
- Parameters:
context
-FacesContext
for the response we are creatingcomponent
-UIComponent
to be rendered- Throws:
IOException
- if an input/output error occurs while rendering
-
getConvertedValue
public Object getConvertedValue(FacesContext context, UIComponent component, Object submittedValue) throws ConverterException
Description copied from class:Renderer
Attempt to convert previously stored state information into an object of the type required for this component (optionally using the registered
Converter
for this component, if there is one). If conversion is successful, the new value should be returned from this method; if not, aConverterException
should be thrown.- Overrides:
getConvertedValue
in classHtmlBasicInputRenderer
- Parameters:
context
-FacesContext
for the request we are processingcomponent
-UIComponent
to be decoded.submittedValue
- a value stored on the component duringdecode
.- Returns:
- the converted value
- Throws:
ConverterException
- if the submitted value cannot be converted successfully.
-
convertSelectManyValuesForModel
protected Object convertSelectManyValuesForModel(FacesContext context, UISelectMany uiSelectMany, Class<?> modelType, String[] newValues)
-
convertSelectManyValuesForArray
protected Object convertSelectManyValuesForArray(FacesContext context, UISelectMany uiSelectMany, Class<?> elementType, String[] newValues) throws ConverterException
- Throws:
ConverterException
-
convertSelectManyValuesForCollection
protected Collection<Object> convertSelectManyValuesForCollection(FacesContext context, UISelectMany uiSelectMany, Class<? extends Collection<Object>> collectionType, String[] newValues)
-
renderOption
protected boolean renderOption(FacesContext context, UIComponent component, UIComponent selectComponent, Converter<?> converter, SelectItem curItem, Object currentSelections, Object[] submittedValues, HtmlBasicRenderer.OptionComponentInfo optionInfo) throws IOException
- Throws:
IOException
-
writeDefaultSize
protected void writeDefaultSize(ResponseWriter writer, int itemCount) throws IOException
- Throws:
IOException
-
containsaValue
protected boolean containsaValue(Object valueArray)
-
getCurrentSelectedValues
protected Object getCurrentSelectedValues(UIComponent component)
-
getMultipleText
protected String getMultipleText(UIComponent component)
-
getSubmittedSelectedValues
protected Object[] getSubmittedSelectedValues(UIComponent component)
-
isSelected
protected boolean isSelected(FacesContext context, UIComponent component, Object itemValue, Object valueArray, Converter<?> converter)
-
renderOptions
protected int renderOptions(FacesContext context, UIComponent component, SelectItemsIterator<SelectItem> items) throws IOException
- Throws:
IOException
-
renderSelect
protected void renderSelect(FacesContext context, UIComponent component) throws IOException
- Throws:
IOException
-
coerceToModelType
protected Object coerceToModelType(FacesContext ctx, Object value, Class<?> itemValueType)
-
createCollection
protected Collection<Object> createCollection(Collection<Object> collection, Class<? extends Collection<Object>> fallBackType)
- Parameters:
collection
- a Collection instance- Returns:
- a new
Collection
instance or null if the instance cannot be created
-
cloneValue
protected Collection<Object> cloneValue(Object value)
Utility method to invoke the the
clone
method on the provided value.- Parameters:
value
- the value to clone- Returns:
- the result of invoking
clone()
ornull
if the value could not be cloned or does not implement theCloneable
interface
-
bestGuess
protected Collection<Object> bestGuess(Class<? extends Collection<Object>> type, int initialSize)
- Parameters:
type
- the target model typeinitialSize
- the initial size of theCollection
- Returns:
- a
Collection
instance that best matchestype
-
createCollectionFromHint
protected Collection<Object> createCollectionFromHint(Object collectionTypeHint)
Create a collection from the provided hint.
- Parameters:
collectionTypeHint
- the Collection type as either a String or Class- Returns:
- a new Collection instance
-
isHideNoSelection
protected static boolean isHideNoSelection(UIComponent component)
-
-