【问题标题】:Highlighting entire table row if validation fails如果验证失败,突出显示整个表格行
【发布时间】: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' : ''}" />

谁能帮我解决这个问题?

提前致谢。

【问题讨论】:

    标签: jsf-2 richfaces


    【解决方案1】:

    您可以使用 jQuery 编写一个小型 JS 脚本,或者为此使用 &lt;rich:jQuery&gt;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-01-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-24
      • 1970-01-01
      相关资源
      最近更新 更多