Class HtmlBasicRenderer
- Direct Known Subclasses:
BaseTableRenderer
,BodyRenderer
,ButtonRenderer
,CommandScriptRenderer
,FormRenderer
,GroupRenderer
,HtmlBasicInputRenderer
,ImageRenderer
,LinkRenderer
,MessageRenderer
,MessagesRenderer
,OutcomeTargetRenderer
,PassthroughRenderer
,WebsocketRenderer
public abstract class HtmlBasicRenderer extends Renderer
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
HtmlBasicRenderer.OptionComponentInfo
Structure to hold common info used by Select* components to reduce the number of times component attributes are evaluated when rendering options.static class
HtmlBasicRenderer.Param
Simple class to encapsulate the name and value of aUIParameter
. -
Field Summary
Fields Modifier and Type Field Description protected static HtmlBasicRenderer.Param[]
EMPTY_PARAMS
protected static Logger
logger
-
Constructor Summary
Constructors Constructor Description HtmlBasicRenderer()
-
Method Summary
Modifier and Type Method Description protected String
augmentIdReference(String forValue, UIComponent fromComponent)
Conditionally augment an id-reference value.String
convertClientId(FacesContext context, String clientId)
Convert the component generated client id to a form suitable for transmission to the client.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
.protected String
decodeBehaviors(FacesContext context, UIComponent component)
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.protected void
encodeRecursive(FacesContext context, UIComponent component)
Render nested child components by invoking the encode methods on those components, but only when therendered
property istrue
.protected Collection<ClientBehaviorContext.Parameter>
getBehaviorParameters(UIComponent command)
Collections parameters for use with Behavior script rendering.protected Iterator<UIComponent>
getChildren(UIComponent component)
protected String
getCurrentValue(FacesContext context, UIComponent component)
protected void
getEndTextToRender(FacesContext context, UIComponent component, String currentValue)
Renderers override this method to write appropriate HTML content into the buffer.protected UIComponent
getFacet(UIComponent component, String name)
protected UIComponent
getForComponent(FacesContext context, String forComponent, UIComponent component)
Locates the component identified byforComponent
protected String
getFormattedValue(FacesContext context, UIComponent component, Object currentValue)
protected String
getFormattedValue(FacesContext context, UIComponent component, Object currentValue, Converter converter)
Overloads getFormattedValue to take a advantage of a previously obtained converter.protected Iterator
getMessageIter(FacesContext context, String forComponent, UIComponent component)
protected HtmlBasicRenderer.Param[]
getParamList(UIComponent command)
protected static Map<String,List<ClientBehavior>>
getPassThruBehaviors(UIComponent component, String domEventName, String componentEventName)
When rendering pass thru attributes, we need to take any attached Behaviors into account.boolean
getRendersChildren()
Return a flag indicating whether thisRenderer
is responsible for rendering the children the component it is asked to render.protected Object
getValue(UIComponent component)
protected boolean
isBehaviorSource(FacesContext ctx, String behaviorSourceId, String componentClientId)
protected void
rendererParamsNotNull(FacesContext context, UIComponent component)
protected void
setSubmittedValue(UIComponent component, Object value)
Renderers override this method to store the previous value of the associated component.protected boolean
shouldDecode(UIComponent component)
protected boolean
shouldEncode(UIComponent component)
protected boolean
shouldEncodeChildren(UIComponent component)
protected boolean
shouldWriteIdAttribute(UIComponent component)
protected String
writeIdAttributeIfNecessary(FacesContext context, ResponseWriter writer, UIComponent component)
Methods inherited from class jakarta.faces.render.Renderer
encodeBegin, encodeChildren, getConvertedValue
-
Field Details
-
Constructor Details
-
HtmlBasicRenderer
public HtmlBasicRenderer()
-
-
Method Details
-
convertClientId
Description copied from class:Renderer
Convert the component generated client id to a form suitable for transmission to the client.
The default implementation returns the argument
clientId
unchanged.- Overrides:
convertClientId
in classRenderer
- Parameters:
context
-FacesContext
for the current requestclientId
- the client identifier to be converted to client a specific format.- Returns:
- the converted
clientId
-
decode
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 classRenderer
- Parameters:
context
-FacesContext
for the request we are processingcomponent
-UIComponent
to be decoded.
-
encodeEnd
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 classRenderer
- Parameters:
context
-FacesContext
for the response we are creatingcomponent
-UIComponent
to be rendered- Throws:
IOException
- if an input/output error occurs while rendering
-
getRendersChildren
public boolean getRendersChildren()Description copied from class:Renderer
Return a flag indicating whether this
Renderer
is responsible for rendering the children the component it is asked to render. The default implementation returnsfalse
.- Overrides:
getRendersChildren
in classRenderer
- Returns:
- the current value of the flag
-
decodeBehaviors
-
isBehaviorSource
protected boolean isBehaviorSource(FacesContext ctx, String behaviorSourceId, String componentClientId)- Parameters:
ctx
- theFacesContext
for the current requestbehaviorSourceId
- the ID of the behavior sourcecomponentClientId
- the client ID of the component being decoded- Returns:
true
if the behavior source is for the component being decoded, otherwisefalse
-
augmentIdReference
Conditionally augment an id-reference value.
If the
forValue
doesn't already include a generated suffix, but the id of thefromComponent
does include a generated suffix, then append the suffix from thefromComponent
to theforValue
. Otherwise just return theforValue
as is.- Parameters:
forValue
- - the basic id-reference value.fromComponent
- - the component that holds the code>forValue.- Returns:
- the (possibly augmented)
forValue
.
-
encodeRecursive
Render nested child components by invoking the encode methods on those components, but only when the
rendered
property istrue
.- Parameters:
context
- FacesContext for the current requestcomponent
- the component to recursively encode- Throws:
IOException
- if an error occurrs during the encode process
-
getChildren
- Parameters:
component
-UIComponent
for which to extract children- Returns:
- an Iterator over the children of the specified component, selecting only those that have a
rendered
property oftrue
.
-
getCurrentValue
- Parameters:
context
- the FacesContext for the current requestcomponent
- the UIComponent whose value we're interested in- Returns:
- the value to be rendered and formats it if required. Sets to empty string if value is null.
-
getEndTextToRender
protected void getEndTextToRender(FacesContext context, UIComponent component, String currentValue) throws IOExceptionRenderers override this method to write appropriate HTML content into the buffer.- Parameters:
context
- the FacesContext for the current requestcomponent
- the UIComponent of interestcurrentValue
-component
's current value- Throws:
IOException
- if an error occurs rendering the text
-
getFacet
- Parameters:
component
- Component from which to return a facetname
- Name of the desired facet- Returns:
- the specified facet from the specified component, but only if its
rendered
property is set totrue
.
-
getForComponent
protected UIComponent getForComponent(FacesContext context, String forComponent, UIComponent component)Locates the component identified byforComponent
- Parameters:
context
- the FacesContext for the current requestforComponent
- - the component to search forcomponent
- - the starting point in which to begin the search- Returns:
- the component with the the
id
forComponent otheriwse null if no match is found.
-
getFormattedValue
protected String getFormattedValue(FacesContext context, UIComponent component, Object currentValue, Converter converter) throws ConverterExceptionOverloads getFormattedValue to take a advantage of a previously obtained converter.- Parameters:
context
- the FacesContext for the current requestcomponent
- UIComponent of interestcurrentValue
- the current value ofcomponent
converter
- the component's converter- Returns:
- the currentValue after any associated Converter has been applied
- Throws:
ConverterException
- if the value cannot be converted
-
getFormattedValue
protected String getFormattedValue(FacesContext context, UIComponent component, Object currentValue) throws ConverterException- Parameters:
context
- the FacesContext for the current requestcomponent
- UIComponent of interestcurrentValue
- the current value ofcomponent
- Returns:
- the currentValue after any associated Converter has been applied
- Throws:
ConverterException
- if the value cannot be converted
-
getMessageIter
protected Iterator getMessageIter(FacesContext context, String forComponent, UIComponent component) -
getParamList
- Parameters:
command
- the command which may have parameters- Returns:
- an array of parameters
-
getBehaviorParameters
Collections parameters for use with Behavior script rendering. Similar to getParamList(), but returns a collection of ClientBehaviorContext.Parameter instances.- Parameters:
command
- the command which may have parameters- Returns:
- a collection of ClientBehaviorContext.Parameter instances.
-
getValue
-
setSubmittedValue
Renderers override this method to store the previous value of the associated component.- Parameters:
component
- the target component to which the submitted value will be setvalue
- the value to set
-
shouldWriteIdAttribute
- Parameters:
component
- the component of interest- Returns:
- true if this renderer should render an id attribute.
-
writeIdAttributeIfNecessary
protected String writeIdAttributeIfNecessary(FacesContext context, ResponseWriter writer, UIComponent component) -
rendererParamsNotNull
-
shouldEncode
-
shouldDecode
-
shouldEncodeChildren
-
getPassThruBehaviors
protected static Map<String,List<ClientBehavior>> getPassThruBehaviors(UIComponent component, String domEventName, String componentEventName)When rendering pass thru attributes, we need to take any attached Behaviors into account. The presence of a non-empty Behaviors map can cause us to switch from optimized pass thru attribute rendering to the unoptimized code path. However, in two very common cases - attaching action behaviors to commands and attaching value change behaviors to editable value holders - the behaviors map is populated with behaviors that are not handled by the pass thru attribute code - ie. the behaviors are handled locally by the renderer. In order to optimize such cases, we check to see whether the component's behaviors map actually contains behaviors only for these non-pass thru attributes. If so, we can pass a null behavior map into renderPassThruAttributes(), thus ensuring that we can take advantage of the optimized pass thru rendering logic. Note that in all cases where we use this method, we actually have two behavior events that we want to check for - a low-level/dom event (eg. "click", or "change") plus a high-level component event (eg. "action", or "valueChange").- Parameters:
component
- the component that we are renderingdomEventName
- the name of the dom-level eventcomponentEventName
- the name of the component-level event
-