繁体   English   中英

JSF Primefaces命令按钮未更新AJAX

[英]JSF Primefaces Commandbutton is not updated AJAX

我想在表格的元素之后更新Button“ 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>

和侦听器方法:

public void onSupplierUserRoleRowSelect(SelectEvent e){

    this.disableSupUserRoleButtons=false;
}

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

尝试这个:

update = "@form"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM