【发布时间】:2011-09-28 11:17:25
【问题描述】:
我正在研究 JSF2.0 和 Richfaces。如果验证失败,我需要更改表单字段(整行)的样式。我正在使用以下代码来显示字段标签和文本框。
<h:panelGrid columns="2">
<h:outputLabel value="#{uit.firstname}:">
<span class="required"><strong>*</strong> </span>
</h:outputLabel>
<h:inputText value="#{editUserProfileBean.firstName}" type="text"
id="firstname" styleClass="basicFormTextBox" size="30"
required="true" requiredMessage="#{uitkem.valueRequired}"
validatorMessage="#{prod.firstNameValidator}">
<f:validateLength maximum="#{prodConf.MaxLengthForFirstName}"
minimum="#{prodConf.MinLengthForFirstName}" />
<f:validator validatorId="trimSpaces" />
</h:inputText>
</h:panelGrid>
假设如果验证失败,我需要突出显示该行(标签和文本框)。
如果验证失败,我可以使用以下代码突出显示文本框。但我想突出显示整行,使用以下代码是不可能的。
<h:inputText value="#{editUserProfileBean.firstName}" required="true" styleClass="#{not component.valid ? 'newStyleClass' : ''}" />
谁能帮我解决这个问题?
提前致谢。
【问题讨论】: