I want set a special error class to div block into my custom component for JSF. I want set errorClass to “error” if this field failed the validation.
<c:if test="${?????}">
<c:set var="errorClass" value="error" />
</c:if>
<div class="input ${errorClass}">
<label for="#{rich:clientId('input')}:input">#{cc.attrs.label}</label>
<h:inputText id="input" value="#{cc.attrs.value}"
<cc:insertChildren />
</h:inputText>
</div>
You can use
component.validinside the style or styleClass attribute of your inputText:However, this won’t work in your
divsince it is no jsf component. You could try component binding (from theory, not tested):