public class MassAttribute extends TagHandler
The <o:massAttribute> sets an attribute of the given name and value on all nested components,
if they don't already have an attribute set. On boolean attributes like disabled
, readonly
and rendered
, any literal (static) attribute value will be ignored and overridden. Only if they have
already a value expression #{...}
as attribute value, then it won't be overridden. This is a technical
limitation specifically for boolean attributes as they don't default to null
.
For example, the following setup
<o:massAttribute name="disabled" value="true"> <h:inputText id="input1" /> <h:inputText id="input2" disabled="true" /> <h:inputText id="input3" disabled="false" /> <h:inputText id="input4" disabled="#{true}" /> <h:inputText id="input5" disabled="#{false}" /> </o:massAttribute>will set the
disabled="true"
attribute in input1
, input2
and
input3
as those are the only components without a value expression on the boolean attribute.
As another general example without booleans, the following setup
<o:massAttribute name="styleClass" value="#{component.valid ? '' : 'error'}"> <h:inputText id="input1" /> <h:inputText id="input2" styleClass="some" /> <h:inputText id="input3" styleClass="#{'some'}" /> <h:inputText id="input4" styleClass="#{null}" /> </o:massAttribute>will only set the
styleClass="#{component.valid ? '' : 'error'}"
attribute in input1
as
that's the only component on which the attribute is absent.
Do note that the specified EL expression will actually be evaluated on a per-component basis.
To target a specific component (super)class, use the target
attribute. The example below skips labels
(as that would otherwise fail in the example below because they don't have the valid
property):
<o:massAttribute name="styleClass" value="#{component.valid ? '' : 'error'}" target="javax.faces.component.UIInput"> <h:outputLabel for="input1" /> <h:inputText id="input1" /> <h:outputLabel for="input2" /> <h:inputText id="input2" /> <h:outputLabel for="input3" /> <h:inputText id="input3" /> </o:massAttribute>
nextHandler, tag, tagId
Constructor and Description |
---|
MassAttribute(TagConfig config)
The tag constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
apply(FaceletContext context,
UIComponent parent) |
getAttribute, getRequiredAttribute, toString
public MassAttribute(TagConfig config)
config
- The tag config.public void apply(FaceletContext context, UIComponent parent) throws IOException
IOException
Copyright © 2012–2016 OmniFaces. All rights reserved.