-1

I did try lots of ways but couldnt find a solution for my problem. My problem is , clicking the button of the selected row to view dialog doesnt set the selecteduser object. It seems null. Thank you for your time. Here is my xhtml page.

<ui:composition template="/pages/admin/admin.xhtml"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui">

    <ui:define name="center">
        <h:form id="updateform">
            <p:growl id="messages"/>
            <p:panel id="pnlUpdateUser" header="#{menu['menu.admin.usermanager.updateuser']}">
                <p:panelGrid columns="2" styleClass="cm_ui-panel-grid">
                    <p:outputLabel value="#{menu['menu.admin.createuser.name']}" styleClass="cm_ui-output-label"/>
                    <p:inputText styleClass="cm_input-text" value="#{userMB.userQuery.name}"/>

                    <p:outputLabel value="#{menu['menu.admin.createuser.surname']}" styleClass="cm_ui-output-label"/>
                    <p:inputText styleClass="cm_input-text" value="#{userMB.userQuery.surname}" />

                    <f:facet name="footer">
                        <p:commandButton value="#{menu.search}" action="#{userMB.queryUsers}" update=":userresultform"/>
                    </f:facet>
                </p:panelGrid>
            </p:panel>
        </h:form>
        <h:form id="userresultform">
            <p:dataTable id="userresulttable" var="u" value="#{userMB.users}"
                         rendered="#{(userMB.users.size() > 0)}">
                <f:facet name="header">
                    <p:outputLabel value="#{menu['menu.admin.updateuser.list']}"/>
                </f:facet>
                <p:column headerText="#{menu['menu.admin.createuser.id']}">
                    <h:outputText value="#{u.id}" />
                </p:column>
                <p:column headerText="#{menu['menu.admin.createuser.name']}">
                    <h:outputText value="#{u.name}" />
                </p:column>
                <p:column headerText="#{menu['menu.admin.createuser.surname']}">
                    <h:outputText value="#{u.surname}" />
                </p:column>
                <p:column headerText="#{menu['menu.admin.createuser.grade']}">
                    <h:outputText value="#{u.grade}" />
                </p:column>
                <p:column style="width:32px;text-align: center">
                    <p:commandButton update=":userresultform:useredit" oncomplete="PF('userEditDialog').show()" icon="ui-icon-search" title="guncelle">
                        <f:setPropertyActionListener value="#{u}" target="#{userMB.selectedUser}" />
                    </p:commandButton>
                </p:column>
            </p:dataTable>
            <p:dialog header="Guncelleme" widgetVar="userEditDialog" modal="true" showEffect="fade" hideEffect="fade" resizable="false"
                    appendTo="@(body)" dynamic="true">
                <p:outputPanel id="useredit" style="text-align:center;">
                    <p:panelGrid  columns="2" rendered="#{not empty userMB.selectedUser}" columnClasses="label,value">

                        <h:outputText value="Ad" />
                        <h:outputText value="#{userMB.selectedUser.name}" />

                        <h:outputText value="Soyad:" />
                        <h:outputText value="#{userMB.selectedUser.surname}" />

                        <h:outputText value="Unvan" />
                        <h:outputText value="$#{userMB.selectedUser.grade}" />
                    </p:panelGrid>
                </p:outputPanel>
            </p:dialog>
        </h:form>
    </ui:define>
</ui:composition>
Mesut Can
  • 291
  • 2
  • 5
  • 19

2 Answers2

1

You need to add a form inside the dialog if you use append to body is true. But also make sure in you xhtml, you do not have nested forms since they end up nested on the client before the dialog is 'moved' and that is invalid html

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
-1

Think the problem is with appendTo="@(body)"

Please add the process to the commandButton

 <p:commandButton update=":userresultform:useredit" process="@this" oncomplete="PF('userEditDialog').show()" icon="ui-icon-search" title="guncelle">
    <f:setPropertyActionListener value="#{u}" target="#{userMB.selectedUser}" />
</p:commandButton>

and for the p:dialog remove the appendTo and try

<p:dialog header="Guncelleme" widgetVar="userEditDialog" modal="true" showEffect="fade" hideEffect="fade" resizable="false"
                dynamic="true">
Swathi
  • 602
  • 4
  • 17