0

I have a JSF page with commandbutton to show dialog and show data from datatable, but the problem RequestContext.getCurrentInstance().update doesn't update the dialog, can anyone tell me what is wrong with my code?

here is my JSF code

    <h:form id="formEmp">
        <p:commandButton value="Edit"
                         id="buttonUpdate"
                         actionListener="#{masterRoleController.doUpdate()}"/>

        <br/>
        <p:separator/>

        <p:dataTable id="dtEmployee" 
                     value="#{masterRoleController.lazyUserRole}" var="dtEmp"
                     selectionMode="single"
                     selection="#{masterRoleController.userRole}"
                     rowKey="#{dtEmp.roleId}"
                     paginator="true"
                     rowsPerPageTemplate="15, 25, 50"
                     rows="15"
                     lazy="true"
                     resizableColumns="true"
                     emptyMessage="No Data"
                     styleClass="eric-panelgrid">

                                <p:ajax event="rowSelect"
                                        listener="#{masterRoleController.enableButtonEdit()}"
                                        update=":formEmp:buttonDelete, :formEmp:buttonUpdate" />

            <p:column headerText="Id">
                <h:outputText value="#{dtEmp.roleId}" styleClass="eric-textInput"/>
            </p:column>
            <p:column headerText="Role Name">
                <h:outputText value="#{dtEmp.roleName}" styleClass="eric-textInput"/>
            </p:column>
            <p:column headerText="Role Desc" style="width: 50%">
                <h:outputText value="#{dtEmp.roleDesc}" styleClass="eric-textInput"/>
            </p:column>

        </p:dataTable>
    </h:form>
</center>

<h:form id="formDlgUpdate">
            <p:dialog id="dlgUpdate"
                      widgetVar="widDlgUpdate"
                      header="Update Role"
                      modal="true"
                      resizable="false"
                      dynamic="true"
                      showEffect="fade"
                      hideEffect="fade"
                      draggable="false">
                <p:panelGrid id="pgridUpdate" columns="3" >
                    <h:outputText value="Role Name"/>
                    <h:outputText value=":"/>
                    <p:inputText id="inEmpTpName"
                                 value="#{masterRoleController.userRole.roleName}"
                                 required="true"
                                 requiredMessage="Name must be filled."
                                 maxlength="50"
                                 onblur="value = value.toUpperCase();
                                             value = trim(this.value)"
                                 onkeypress="return checkAlpNumeric(event)">
                        <f:validator validatorId="com.hospital.util.validator.UniqueValidator"/>
                        <f:attribute name="table" value="user_role"/>
                        <f:attribute name="column" value="role_name" />
                        <f:attribute name="info" value="Test Role"/>
                        <f:attribute name="actInfo" value="#{masterRoleController.actInfo}"/>
                        <f:attribute name="compare" value="#{masterRoleController.nameTemp}"/>
                    </p:inputText>

                    <h:outputText value="Role Desc"/>
                    <h:outputText value=":"/>
                    <p:inputTextarea value="#{masterRoleController.userRole.roleDesc}"
                                     required="true"
                                     requiredMessage="Description must be filled."
                                     maxlength="100"
                                     onblur="value = value.toUpperCase();
                                                 value = trim(this.value)"
                                     onkeypress="return checkAlpNumeric(event)"/>

                    <h:outputText value=""/>
                    <h:outputText value=""/>
                    <p:commandButton value="Edit"
                                     actionListener="#{masterRoleController.update()}"
                                     update="pgridUpdate">
                    </p:commandButton>
                </p:panelGrid>
            </p:dialog>
        </h:form>

and here is my managedbean

public void doUpdate() {
        headerInsUpd = "Update";
        toggleBtnInsUpd = false;
        actInfo = "U";
        nameTemp = userRole.getRoleName();
        RequestContext.getCurrentInstance().execute("PF('widDlgUpdate').show()");
        RequestContext.getCurrentInstance().update("formDlgUpdate:dlgUpdate");
    }
san san
  • 53
  • 1
  • 1
  • 4

1 Answers1

-1

It doesn't work because your dialog is dynamic (dynamic="true"). You should disable dynamic behavior to achieve what you want. Or to update not the dialog itselt but a component inside the dialog after the dialog is opened.