public class ReadableIdProcessor extends Object implements AdvancedWidgetProcessor<javax.faces.component.UIComponent,UIMetawidget>
Unlike UIViewRoot.createUniqueId
, tries to make the id human readable, both for
debugging purposes and for when running unit tests (using, say, WebTest). Because the ids are
based off the value binding (or method binding) of the UIComponent, this WidgetProcessor must
come after StandardBindingProcessor
(or equivalent).
Clients can plug in a different WidgetProcessor to use UIViewRoot.createUniqueId
if
preferred. They can even plug in assigning a changing, random id to a component each time it is
generated. This is a great way to fox hackers who are trying to POST back pre-generated payloads
of HTTP fields (ie. CSRF attacks).
Constructor and Description |
---|
ReadableIdProcessor() |
Modifier and Type | Method and Description |
---|---|
void |
onEndBuild(UIMetawidget metawidget)
Event called at the end of widget building, after all widgets have been built and added to
the
Layout . |
void |
onStartBuild(UIMetawidget metawidget)
Event called at the start of the widget building process, before the
WidgetBuilder is called. |
javax.faces.component.UIComponent |
processWidget(javax.faces.component.UIComponent component,
String elementName,
Map<String,String> attributes,
UIMetawidget metawidget)
Process the given widget.
|
protected void |
setUniqueId(String id,
javax.faces.component.UIComponent component,
UIMetawidget metawidget) |
protected void |
setUniqueId(javax.faces.component.UIComponent component,
String expressionString,
UIMetawidget metawidget) |
public void onStartBuild(UIMetawidget metawidget)
AdvancedWidgetProcessor
WidgetBuilder
is called. WidgetProcessor
s may wish to act on this
event to initialize themselves ready for processing. This event is only called once per
inspection, not once per widget built.onStartBuild
in interface AdvancedWidgetProcessor<javax.faces.component.UIComponent,UIMetawidget>
metawidget
- the parent Metawidget. Never nullpublic javax.faces.component.UIComponent processWidget(javax.faces.component.UIComponent component, String elementName, Map<String,String> attributes, UIMetawidget metawidget)
WidgetProcessor
WidgetBuilder
, and before it is added to the Layout
.processWidget
in interface WidgetProcessor<javax.faces.component.UIComponent,UIMetawidget>
component
- the widget to process. Never nullelementName
- XML node name of the business field. Typically 'entity', 'property' or 'action'.
Never nullattributes
- attributes of the widget to process. Never null. This Map is modifiable - changes
will be passed to subsequent WidgetProcessors and Layoutsmetawidget
- the parent Metawidget. Never nullpublic void onEndBuild(UIMetawidget metawidget)
AdvancedWidgetProcessor
Layout
. WidgetProcessor
s may wish to act on this event to clean
themselves up after processing. This event is only called once per inspection, not once per
widget built.onEndBuild
in interface AdvancedWidgetProcessor<javax.faces.component.UIComponent,UIMetawidget>
metawidget
- the parent Metawidget. Never nullprotected void setUniqueId(javax.faces.component.UIComponent component, String expressionString, UIMetawidget metawidget)
protected void setUniqueId(String id, javax.faces.component.UIComponent component, UIMetawidget metawidget)
Copyright © 2015. All Rights Reserved.