Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.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 Primefaces Commandbutton未在AJAX中更新_Ajax_Jsf 2_Primefaces - Fatal编程技术网

JSF Primefaces Commandbutton未在AJAX中更新

JSF Primefaces Commandbutton未在AJAX中更新,ajax,jsf-2,primefaces,Ajax,Jsf 2,Primefaces,我想在表的一个元素之后更新按钮“buttonEditRole” 已选择“dataTableSupUserRoles”。当一个元素被激活时,该按钮应被启用 挑选出来的。调用行选择后的侦听器方法。 在这个方法中,我将“disableNewSupUserRoleButton”设置为true。这也可以工作,但按钮未启用。 这是我的xhtml: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DT

我想在表的一个元素之后更新按钮“buttonEditRole”
已选择“dataTableSupUserRoles”。当一个元素被激活时,该按钮应被启用
挑选出来的。调用行选择后的侦听器方法。
在这个方法中,我将“disableNewSupUserRoleButton”设置为true。这也可以工作,但按钮未启用。
这是我的xhtml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:body>
    <ui:composition>
        <h:form id="formUserSettingsTabRole">
            <p:panelGrid>

                <p:row>
                    <p:column>
                        <p:dataTable id="dataTableSupUserRoles"
                            value="#{userSettingBean.supplierUserRoleList}" var="roles"
                            rowKey="#{roles.ID}"
                            selection="#{userSettingBean.selectedSupUserRole}"
                            selectionMode="single" paginator="true"
                            paginatorPosition="bottom" rows="10">

                            <p:ajax event="rowSelect"
                                update=":tabViewUserSettings:formUserSettingsTabRole:buttonEditRole"
                                listener="#{userSettingBean.onSupplierUserRoleRowSelect}" />

                            <p:column headerText="#{msg['global_company_tile']}">
                                <h:outputText value="#{roles.SUPPLIER.NAME}"
                                    styleClass="#{roles.IS_CONFIRMED ? 'textGreen' : 'textRed'}" />
                            </p:column>
                            <p:column headerText="#{msg['global_address_location']}">
                                <h:outputText
                                    value="#{roles.SUPPLIER.CITY}, #{roles.SUPPLIER.COUNTRY}"
                                    styleClass="#{roles.IS_CONFIRMED ? 'textGreen' : 'textRed'}" />
                            </p:column>
                            <p:column headerText="#{msg['global_role']}">
                                <h:outputText value="#{roles.ROLE.NAME}"
                                    styleClass="#{roles.IS_CONFIRMED ? 'textGreen' : 'textRed'}" />
                            </p:column>


                            <p:column>
                                <p:commandButton id="ComButSeeCurrentRole" icon="ui-icon-search"
                                styleClass="ui-blockui"/>

                                <p:overlayPanel for="ComButSeeCurrentRole">
                                    <p:outputLabel value="bababubu"/>
                                </p:overlayPanel>
                            </p:column>




                            <p:column headerText="#{msg['global_company_delete']}">
                                <p:commandButton id="ComButtDeleteSupUsRole" title="Delete"
                                    immediate="true" type="submit" update="dataTableSupUserRoles"
                                    actionListener="#{userSettingBean.deleteSupplierUserRole}"
                                    icon="ui-icon-trash">
                                    <f:param name="delteSupUserRole" value="#{roles.ID}" />
                                </p:commandButton>
                            </p:column>

                        </p:dataTable>
                    </p:column>
                </p:row>

                <p:row>
                    <p:column>
                        <p:commandButton id="buttonAddRole" value="#{msg['global_new']}" />

                        <p:overlayPanel id="OverLayPanelNewRole" for="buttonAddRole"
                            styleClass="ui-blockui">

                            <p:dataTable id="DataTableCompany"
                                value="#{userSettingBean.supplierList}" var="company"
                                selectionMode="single" rowKey="#{company.ID}"
                                selection="#{userSettingBean.selectedSupplier}" paginator="true"
                                paginatorPosition="bottom">

                                <p:ajax event="rowSelect" listener="#{userSettingBean.onNewSupUserRoleTableSelect}"
                                update=":tabViewUserSettings:formUserSettingsTabRole:CommandButtonSaveNewRole"/>


                                <p:column headerText="#{msg['global_company_tile']}">
                                    <p:outputLabel value="#{company.NAME}" />
                                </p:column>
                                <p:column headerText="Location">
                                    <p:outputLabel value="#{company.location}" />
                                </p:column>

                            </p:dataTable>

                            <p:outputLabel value="#{msg['global_role']}" />

                            <p:selectOneMenu id="SelectOneMenuRoles"
                                value="#{userSettingBean.selectedRole}" converter="roleIDConverter">

                                <f:selectItems value="#{userSettingBean.roleList}" var="role"
                                    itemLabel="#{role.NAME}" itemValue="#{role}" style="width:100%" />
                            </p:selectOneMenu>


                            <p:outputLabel value="#{msg['global_company_comment']}" />

                            <p:inputTextarea id="inpTxtACompCommentMyRole" rows="6" cols="33"
                                value="#{userSettingBean.newRoleComment}" maxlength="1000"
                                style="width:97%" />

                            <p:commandButton id="CommandButtonSaveNewRole" value="#{msg['global_company_form_status_create']}"
                                actionListener="#{userSettingBean.addSupplierUserRole}"
                                immediate="true" disabled="#{userSettingBean.disableNewSupUserRoleButton}"
                                update="dataTableSupUserRoles formUserSettingsTabRole" />


                        </p:overlayPanel>




                        <p:commandButton id="buttonEditRole" value="#{msg['global_company_form_status_edit']}"
                            disabled="#{userSettingBean.disableNewSupUserRoleButton}"
                            actionListener="#{userSettingBean.editSupplierUserRole}"
                            update="buttonEditRole outPLabelCompNameEdit dataTableSupUserRoles"
                            immediate="true" />


                        <p:outputLabel id="testLabel"
                            value="#{selectedSupUserRole.SUPPLIER.NAME}" />


                        <p:overlayPanel id="OverLayPanelEditRole" for="buttonEditRole"
                            styleClass="ui-blockui">
                            <p:panelGrid columns="2">

                                <p:outputLabel value="#{msg['global_company_tile']}" />

                                <p:outputLabel id="outPLabelCompNameEdit" disabled="true"
                                    value="#{selectedSupUserRole.SUPPLIER.NAME}" />

                                <p:outputLabel value="#{msg['global_role']}" />



                                <p:selectOneMenu id="SelectOneMenuRolesEdit"
                                    value="#{userSettingBean.selectedRole}" onchange="submit()"
                                    valueChangeListener="#{userSettingBean.roleChanged}">
                                    <f:selectItems value="#{userSettingBean.roleList}" var="role"
                                        itemLabel="#{role.NAME}" style="width:100%" />
                                </p:selectOneMenu>

                            </p:panelGrid>

                            <p:outputLabel value="#{msg['global_company_comment']}" />
                            <p:inputTextarea id="inpTxtACompCommentMyRoleEdit" rows="6"
                                cols="33" value="#{userSettingBean.newRoleComment}"
                                maxlength="1000" style="width:97%" />

                            <p:commandButton value="#{msg['global_company_save']}"
                                actionListener="#{userSettingBean.saveEditedSupUserRole}"
                                immediate="true"
                                update="dataTableSupUserRoles formUserSettingsTabRole" />
                        </p:overlayPanel>
                    </p:column>
                </p:row>


            </p:panelGrid>
        </h:form>

    </ui:composition>
</h:body>
</html>

您可以更新整个表单,而不是命令按钮

试试这个:

update = "@form"

只是为了测试,请尝试删除立即标记或将值更改为false,如果不起作用,请尝试将ajav事件中的更新代码更改为@formThank,谢谢您的回复!我尝试了你的两个技巧,但仍然不起作用。@hiaslosch17支持bean的范围是什么
@ViewScoped
始终建议使用ajax操作获得最佳效果
update = "@form"