Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf 验证两个h:列时在h:数据表中保存h:消息的位置_Jsf_Jsf 1.2 - Fatal编程技术网

Jsf 验证两个h:列时在h:数据表中保存h:消息的位置

Jsf 验证两个h:列时在h:数据表中保存h:消息的位置,jsf,jsf-1.2,Jsf,Jsf 1.2,我在每行中使用一个h:selectbooleancheckbox使两列可编辑 看看我的JSF页面 <h:dataTable id="editTable" styleClass = "listtable" value="#{bean.GroupList}" var="group" border="1" first="0" rows="8" width="75%" frame="hsides" rules="all" cellpadding="5" headerClass="tablehea

我在每行中使用一个h:selectbooleancheckbox使两列可编辑

看看我的JSF页面

<h:dataTable id="editTable" styleClass = "listtable" value="#{bean.GroupList}"  var="group" border="1" first="0" rows="8" width="75%" frame="hsides" rules="all" cellpadding="5" headerClass="tableheading" rowClasses="firstrow, secondrow">

    <f:facet name="header">
    <h:outputText value="Groups"></h:outputText>
    </f:facet>

    <h:column>
        <f:facet name="header">
        <h:outputText value="GroupId"></h:outputText>
        </f:facet>
        <h:outputText value="#{group.Id}" rendered="#{not bean.checked[group.Id]}"></h:outputText>
        <h:inputText value="#{group.Id}" rendered="#{bean.checked[group.Id]}" required="true"/>
    </h:column>

    <h:column>
        <f:facet name="header">
        <h:outputText value="GroupName"></h:outputText>
        </f:facet>
        <h:outputText value="#{group.Name}" rendered="#{not bean.checked[group.Id]}"></h:outputText>
        <h:inputText value="#{group.Name}" rendered="#{bean.checked[group.Id]}" required="true"/>
    </h:column>


    <h:column>
        <f:facet name="header">
        <h:outputText value="Check to Enable/Disable"></h:outputText>
        </f:facet>
        <h:selectBooleanCheckbox value="#{bean.checked[group.Id]}" />
    </h:column>

    </h:dataTable>

对于GroupId和GroupName列,我已要求=“true”

我没有找到为每列保存h:messages以显示requiredmessage的位置

请提供帮助。

您需要使用
来显示特定于输入元素的错误。
将显示任何
未涵盖的所有消息

<h:column>
    <f:facet name="header">
    <h:outputText value="GroupId"></h:outputText>
    </f:facet>
    <h:outputText value="#{group.Id}" rendered="#{not bean.checked[group.Id]}"></h:outputText>
    <h:inputText id="groupId" value="#{group.Id}" rendered="#{bean.checked[group.Id]}" required="true"/>
    <h:message for="groupId" />
</h:column>

<h:column>
    <f:facet name="header">
    <h:outputText value="GroupName"></h:outputText>
    </f:facet>
    <h:outputText value="#{group.Name}" rendered="#{not bean.checked[group.Id]}"></h:outputText>
    <h:inputText id="groupName" value="#{group.Name}" rendered="#{bean.checked[group.Id]}" required="true"/>
    <h:message for="groupName" />
</h:column>


谢谢您的回复BalusC。实际上我只是想问一下将h:message放在哪里。有没有办法将h:message单独列出来,这样datatable单元格就不会乱七八糟了?确实,只需将它放在另一个
中即可。此列将始终呈现。这是否是一个问题取决于布局/样式。始终呈现的.Ok.Column对我来说不是一个好选项。相反,最好在h:datatable顶部使用h:messages来显示所有错误消息。你怎么说?你的站点。你的要求。你的选择:)两者都很好。谢谢。我会尝试两者,看看哪一个更适合我的布局。