|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.faces.component.UIComponent javax.faces.component.UIComponentBase javax.faces.component.UIMessages javax.faces.component.html.HtmlMessages org.omnifaces.component.messages.OmniMessages
public class OmniMessages
The <o:messages>
is a component that extends the standard <h:messages>
with
the following new features:
for
componentsfor
attribute. The below example
would only display messages for input1
and input3
:
<h:form>
<o:messages for="input1 input3" />
<h:inputText id="input1" />
<h:inputText id="input2" />
<h:inputText id="input3" />
<h:inputText id="input4" />
</h:form>
It can even refer non-input components which in turn contains input components. The below example would only display
messages for input1
and input2
:
<h:form>
<o:messages for="inputs" />
<h:panelGroup id="inputs">
<h:inputText id="input1" />
<h:inputText id="input2" />
</h:panelGroup>
<h:inputText id="input3" />
<h:inputText id="input4" />
</h:form>
You can even combine them. The below example would only display messages for input1
,
input2
and input4
.
<h:form>
<o:messages for="inputs input4" />
<h:panelGroup id="inputs">
<h:inputText id="input1" />
<h:inputText id="input2" />
</h:panelGroup>
<h:inputText id="input3" />
<h:inputText id="input4" />
</h:form>
escape
attribute.
<o:messages escape="false" />
Beware of potential XSS attack holes when user-controlled input is redisplayed through messages!
var
attribute which sets the current FacesMessage
in the request scope and disables the default table/list rendering. For example,
<dl>
<o:messages var="message">
<dt>#{message.severity}</dt>
<dd title="#{message.detail}">#{message.summary}</dd>
</o:messages>
</dl>
Note: the iteration is by design completely stateless. It's therefore not recommended to nest form components inside
the <o:messages>
component. It should be used for pure output only, like as the standard
<h:messages>
. Plain output links are however no problem. Also note that the escape
attribute has in this case no effect. If you'd like to escape message properties, just use
<h:outputText escape="false">
the usual way.
Design notice: the component class is named OmniMessages
instead of Messages
to avoid
confusion with the Messages
utility class.
Field Summary | |
---|---|
static java.lang.String |
COMPONENT_TYPE
The standard component type. |
Fields inherited from class javax.faces.component.UIMessages |
---|
COMPONENT_FAMILY |
Fields inherited from class javax.faces.component.UIComponent |
---|
BEANINFO_KEY, bindings, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, CURRENT_COMPONENT, CURRENT_COMPOSITE_COMPONENT, FACETS_KEY, VIEW_LOCATION_KEY |
Constructor Summary | |
---|---|
OmniMessages()
Construct a new OmniMessages component whereby the renderer type is set to
MessagesRenderer.RENDERER_TYPE . |
Method Summary | |
---|---|
void |
encodeAll(javax.faces.context.FacesContext context)
An override which delegates directly to UIComponentBase.encodeChildren(FacesContext) . |
java.lang.String |
getVar()
Returns the name of the request attribute which exposes the current faces message. |
java.lang.Boolean |
isEscape()
Returns whether the message detail and summary should be HTML-escaped. |
void |
setEscape(java.lang.Boolean escape)
Sets whether the message detail and summary should be HTML-escaped. |
void |
setValueExpression(java.lang.String name,
javax.el.ValueExpression binding)
An override which checks if this isn't been invoked on var attribute. |
void |
setVar(java.lang.String var)
Sets the name of the request attribute which exposes the current faces message. |
Methods inherited from class javax.faces.component.html.HtmlMessages |
---|
getDir, getErrorClass, getErrorStyle, getFatalClass, getFatalStyle, getInfoClass, getInfoStyle, getLang, getLayout, getStyle, getStyleClass, getTitle, getWarnClass, getWarnStyle, isTooltip, setDir, setErrorClass, setErrorStyle, setFatalClass, setFatalStyle, setInfoClass, setInfoStyle, setLang, setLayout, setStyle, setStyleClass, setTitle, setTooltip, setWarnClass, setWarnStyle |
Methods inherited from class javax.faces.component.UIMessages |
---|
getFamily, getFor, isGlobalOnly, isRedisplay, isShowDetail, isShowSummary, setFor, setGlobalOnly, setRedisplay, setShowDetail, setShowSummary |
Methods inherited from class javax.faces.component.UIComponentBase |
---|
addClientBehavior, addFacesListener, broadcast, clearInitialState, decode, encodeBegin, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getClientId, getDefaultEventName, getEventNames, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getParent, getRenderer, getRendererType, getRendersChildren, getValueBinding, invokeOnComponent, isRendered, isTransient, markInitialState, processDecodes, processRestoreState, processSaveState, processUpdates, processValidators, queueEvent, removeFacesListener, restoreAttachedState, restoreState, saveAttachedState, saveState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding |
Methods inherited from class javax.faces.component.UIComponent |
---|
getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getListenersForEventClass, getNamingContainer, getResourceBundleMap, getStateHelper, getStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, setInView, subscribeToEvent, unsubscribeFromEvent, visitTree |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String COMPONENT_TYPE
Constructor Detail |
---|
public OmniMessages()
OmniMessages
component whereby the renderer type is set to
MessagesRenderer.RENDERER_TYPE
.
Method Detail |
---|
public void setValueExpression(java.lang.String name, javax.el.ValueExpression binding)
var
attribute.
Finally it delegates to the super method.
setValueExpression
in class javax.faces.component.UIComponent
java.lang.IllegalArgumentException
- When this value expression is been set on var
attribute.public void encodeAll(javax.faces.context.FacesContext context) throws java.io.IOException
UIComponentBase.encodeChildren(FacesContext)
.
encodeAll
in class javax.faces.component.UIComponent
java.io.IOException
public java.lang.String getVar()
public void setVar(java.lang.String var)
var
- The name of the request attribute which exposes the current faces message.public java.lang.Boolean isEscape()
true
.
public void setEscape(java.lang.Boolean escape)
escape
- Whether the message detail and summary should be HTML-escaped.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |