获取datatable myfaces 2.1中的行的值

时间:2012-12-06 19:51:55

标签: jsf jsf-1.2

myfaces 1.2我在myfaces2.1中有一个数据表,如果我针对要在托管bean中获取行数据的行选择一个(或多个)复选框,则会在数据表的每一行上显示一个复选框并希望将这些特定值传递到不同的屏幕,任何人都可以帮助我将特定的已检查行值传递给托管bean。?

                <h:column>
                    <h:selectBooleanCheckbox   value="#{myResourcesDetails.chkBxVal}" binding="#{myResourcesDetails.selectedValue(actionEvent)}"/>

                </h:column>

                <h:column>
                    <f:facet name="header">
                        <h:outputText id="tblHdr0" value="Employee Id" style="font-family: arial; font-size: 12px; color: blue"/>
                    </f:facet> 
                    <h:commandLink id="emNo" value="#{resList.empNo}" onclick="fn_openResDetails(#{resList.empNo});" style="font-family: verdana; font-size: 12px; color: olive"/>
                </h:column>

                <h:column>
                    <f:facet name="header">
                        &nbsp;&nbsp;&nbsp;
                        <h:outputText id="tblHdr1" value="Resource Name" style="font-family: arial; font-size: 12px; color: blue"/>
                    </f:facet> 
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <h:outputText value="#{resList.resName}" style="font-family: verdana; font-size: 12px; color: olive"/>
                </h:column>



                <h:column>
                    <f:facet name="header">
                        &nbsp;&nbsp;&nbsp;&nbsp;
                        <h:outputText id="tblHdr3" value="Project Name" style="font-family: arial; font-size: 12px; color: blue"/>
                    </f:facet>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <h:outputText value="#{resList.projName}" style="font-family: verdana; font-size: 12px; color: olive"/>
                </h:column>

                <h:column>
                    <f:facet name="header">
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <h:outputText id="tblHdr4" value="Manager Id" style="font-family: arial; font-size: 12px; color: blue"/>
                    </f:facet>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <h:outputText value="#{resList.manager}" style="font-family: verdana; font-size: 12px; color: olive"/>
                </h:column>

                 </h:dataTable>

1 个答案:

答案 0 :(得分:0)

chkBxVal字段添加到resList

内的对象

尝试

并更改

<h:selectBooleanCheckbox   value="#{myResourcesDetails.chkBxVal}" 
   binding="#{myResourcesDetails.selectedValue(actionEvent)}"/>

<h:selectBooleanCheckbox value="#{resList.chkBxVal}"/>

比向列表中的值提交数据到服务器循环时,查看列表中每个对象的chkBxVal值...