开发者

Where to keep h:messages in a h:datatable while validating two h:columns

开发者 https://www.devze.com 2023-04-08 10:39 出处:网络
I am using one h:selectbooleancheckbox in each row to make 2 columns editable. Have a look at my JSF page

I am using one h:selectbooleancheckbox in each row to make 2 columns editable.

Have a look at my JSF page

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

I have required="true" for GroupId and GroupN开发者_JS百科ame columns.

I am not getting where to keep h:messages for each column to display requiredmessage

Please help.


You need to use <h:message> instead to display errors specific to an input element. The <h:messages> will display all messages which are not covered by any <h:message>.

<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>
0

精彩评论

暂无评论...
验证码 换一张
取 消