Class MassAttribute
- java.lang.Object
-
- jakarta.faces.view.facelets.TagHandler
-
- org.omnifaces.taghandler.MassAttribute
-
- All Implemented Interfaces:
FaceletHandler
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
andrendered
, 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 tonull
.Usage
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 thedisabled="true"
attribute ininput1
,input2
andinput3
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 thestyleClass="#{component.valid ? '' : 'error'}"
attribute ininput1
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 thevalid
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.- Since:
- 1.8
- Author:
- Bauke Scholtz
-
-
Field Summary
-
Fields inherited from class jakarta.faces.view.facelets.TagHandler
nextHandler, tag, tagId
-
-
Constructor Summary
Constructors Constructor Description MassAttribute(TagConfig config)
The tag constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
apply(FaceletContext context, UIComponent parent)
-
Methods inherited from class jakarta.faces.view.facelets.TagHandler
getAttribute, getRequiredAttribute, toString
-
-
-
-
Constructor Detail
-
MassAttribute
public MassAttribute(TagConfig config)
The tag constructor.- Parameters:
config
- The tag config.
-
-
Method Detail
-
apply
public void apply(FaceletContext context, UIComponent parent) throws IOException
- Throws:
IOException
-
-