Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/12.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 2 启用/禁用<;p:commandButton>;在<;p:dataTable>;基于<;p:列选择=";“多重”&燃气轮机;_Jsf 2_Primefaces_Facelets - Fatal编程技术网

Jsf 2 启用/禁用<;p:commandButton>;在<;p:dataTable>;基于<;p:列选择=";“多重”&燃气轮机;

Jsf 2 启用/禁用<;p:commandButton>;在<;p:dataTable>;基于<;p:列选择=";“多重”&燃气轮机;,jsf-2,primefaces,facelets,Jsf 2,Primefaces,Facelets,我有一个数据表,显示员工列表。在datatable的末尾有一个commandbutton。现在,如果用户选择datatable中的任何复选框,我希望启用我的commandbutton。最初,命令按钮被禁用 下面是我的index.xhtml页面 <p:dataTable value="#{userPreferencesBean.studentDataModel}" var="studentDetails" emptyMessage="No Student fo

我有一个数据表,显示员工列表。在datatable的末尾有一个commandbutton。现在,如果用户选择datatable中的任何复选框,我希望启用我的commandbutton。最初,命令按钮被禁用

下面是我的index.xhtml页面

<p:dataTable value="#{userPreferencesBean.studentDataModel}"
                var="studentDetails" emptyMessage="No Student found."
                selection="#{userPreferencesBean.selectedStudents}">
                <f:facet name="header">
                    List of Students
                </f:facet>

                <p:ajax event="rowSelect" update="submit" listener="#{userPreferencesBean.onRowSelect}"/>
                <p:ajax event="rowUnselect" update="submit" listener="#{userPreferencesBean.onRowSelect}"/>

                <p:column selectionMode="multiple" style="width:2%" />

                //All the columns 

                <f:facet name="footer">
                    <p:commandButton id="submit" value="Save Preferences"
                        icon="ui-icon-disk" style="float:right;"
                        action="#{userPreferencesBean.savePreferredInterfaces}"
                        update=":#{p:component('selectedInterfaceDetails')}" 
                        disabled="#{not userPreferencesBean.hasPreferenceChanged eq false}"/>
                </f:facet>
            </p:dataTable>
我所期望的是,一旦我选择了一行,我的提交按钮应该被启用。但事实并非如此。你能帮我理解我做错了什么吗?谢谢

关于,,
Sudipta Deb

试着把你的桌子整理好

此外,您还可以使其更加方便:

<p:commandButton id="submit" ... disabled="#{userPreferencesBean.selectedStudents==null}"/>


它已经在表单中。My userPreferencesBean.selectedStudents将包含保存在数据库中的选定学生。抱歉。我漏掉了“checkbox”这个词。我以为您希望选中行上的“启用”按钮。请检查是否调用了您的方法。是否有此更新?我正试图达到完全相同的行为。。。尝试将bean范围更改为视图,但没有成功!
<p:commandButton id="submit" ... disabled="#{userPreferencesBean.selectedStudents==null}"/>