Question

Is there a simple possibility to apply a specific style to input labels that are invalid?

I've seen omnifaces highlight component which does the job for the input itself, but the given styleguide for my project, forces this for the label of the input.

Something like this would be great:

<h:outputLabel for="inputId" value="label" />
<h:inputText id="inputId" value="..." />

<o:highlight errorLabelStyle="errorLabel" />
Was it helpful?

Solution

This was not possible with <o:highlight>. It's however relatively simple to apply the same style class for the labels as well, so it has been implemented. As per OmniFaces 1.2, you can use it as follows:

<h:outputLabel for="inputId" value="label" />
<h:inputText id="inputId" value="..." />

<o:highlight />

with the following CSS:

label.error {
    color: red;
}

input.error, select.error, textarea.error {
    background: pink;
}

The default stlye class name of error is overrideable the usual way:

<o:highlight styleClass="invalid" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top