jsf highlight label for invalid input

↘锁芯ラ 提交于 2019-12-13 16:28:55

问题


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

I've seen omnifaces highlight component wich 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" />

回答1:


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" />


来源:https://stackoverflow.com/questions/12954249/jsf-highlight-label-for-invalid-input

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!