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="jakarta.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>
Since OmniFaces 3.10, the target attribute supports a commaseparated string.
| Name | Required | Type | Description |
|---|---|---|---|
name | true | jakarta.el.ValueExpression
(must evaluate to java.lang.String)
| The name of the attribute to be set on all nested components. This cannot be set to id or binding as those are already evaluated during view build time and they shouldn't be shared among components anyway. |
target | false | jakarta.el.ValueExpression
(must evaluate to java.lang.String)
| The FQN of the specific UIComponent (super)class for which the attribute should be set. This value can be a comma separated string of FQNs. |
value | true | jakarta.el.ValueExpression
(must evaluate to java.lang.String)
| The value of the attribute to be set on all nested components. This will be evaluated on a per-component basis. In other words, #{component} can be used here to refer the "current" component. |
Output generated by Vdldoc View Declaration Language Documentation Generator.