0

I have a decent-sized application where Primefaces takes care of the GUI. But I am having trouble trying to use the Dialog Framework.

I believe I have follwed all the guidelines in the doc. The dialog shows up as it should, but the 'dialogReturn'-event does not seem to fire (or get caught). At least I do not get any activity in my listener-routine specified in the html-file

<p:commandLink title="Remove user" actionListener="#{ctrlUsersBean.pbDeleteUserPrepare(user)}" 
          styleClass="ui-icon ui-icon-trash">
    <p:ajax event="dialogReturn" listener="#{ctrlUsersBean.pbDeleteUser}" />
</p:commandLink>

In the Dialog I only have a couple of commandButtons. In the actionListener which I trigger (and I actually get there) from the Dialog, I do a CloseDialog call:

    MyObject w = new MyObject(1);
    RequestContext.getCurrentInstance().closeDialog(w);

where I pass an object back to the parent page, and I expect to pick it up in my listener-routine

    public void pbDeleteUser(SelectEvent ev) {
        MyObject w =(MyObject)ev.getObject();
        ...

but I never get to this code.

I am using a SessionBean to run all the code involved.

I am running the Primefaces version 5.2

I have include the specified 3 lines in the 'application'-section in the faces-config.xml file.

As a start I am only running it in Netbeans (v. 7.4), but I think that should work ok.

If anybody have a tip about where I went wrong, I would greatly appreciate it.

Regards, Erik

Due to questions, I add some more of my code.

Here is more from the xhtml-file, showing the origin of the variable 'user':

           <p:dataTable id="showUsersList" var="user" value="#{ctrlUsersBean.showUsersList}" 
                     scrollable="true" scrollHeight="200" liveResize="true"
                     rowKey="#{user.usrEcid}" selection="#{ctrlUsersBean.showUserDetail}" selectionMode="single" 
                     resizableColumns="true" 
                     emptyMessage="No users">
            <p:ajax event="rowSelect" process="@this" listener="#{ctrlUsersBean.onSpreadRowSelect}" update=":showEditUsersForm"/>
                <p:column headerText="ecid" sortBy="#{user.usrEcid}"><h:outputText value="#{user.usrEcid}" /></p:column>
                    ...
                <p:column headerText="#{sessionUser.doTekst('html_users_Aksjon')}">
                    <h:panelGrid columns="1" styleClass="actions" cellpadding="0">
                        <p:commandLink title="Delete user" actionListener="#{ctrlUsersBean.pbDeleteUserPrepare(user)}" 
                                       styleClass="ui-icon ui-icon-trash">
                            <p:ajax event="dialogReturn" listener="#{ctrlUsersBean.pbDeleteUser}" />
                        </p:commandLink>

                    </h:panelGrid>
                </p:column>
        </p:dataTable>

And the pbDeleteuserPrepare() routine

    public void pbDeleteUserPrepare(WlCdUser user) {
    // called from the user-spread
    setDeleteUser(user);    // Set the (global) user-to-delete
        ...
    try {
        RequestContext.getCurrentInstance().openDialog("deleteUser");
    } catch (Exception e) {
        logger.log(Level.SEVERE, "pbDeleteUserPrepare(), unable to open Dialog, Error=" + e.getMessage());
    }
}

The deleteUser.xhtml file is very simple

    <head>
    <title>Delete user</title>
    <meta name="viewport" content="width=device-width"/>
</head>
<h:body>
    <h:form id="deleteFrom" >
        <p:panel id="deleteConfirmation" widgetVar="deleteConfirmation" header="Confirm deletion="height:100px;vertical-align: center" >
            <p:outputLabel value="Full Delete, or just Deactivate user?"/>
            <p:panelGrid columns="3">
                <p:commandButton value="Yes, Full Delete" actionListener="#{ctrlUsersBean.pbDeleteUser(1)}"/>
                <p:commandButton value="No, just Deactivate" actionListener="#{ctrlUsersBean.pbDeactivateUser(0)}"/>
            </p:panelGrid>
         </p:panel>
    </h:form>
</h:body>

And the routines behind the buttons:

    public void pbDeleteUser(int operation) {
    // called from the delete dialog
    logger.log(Level.INFO, "Called pbDeleteUser(), operation = " + operation);
    WlCdUser w = DoUserOperation(getDeleteUser(), operation);
    RequestContext.getCurrentInstance().closeDialog(w);
}

public void pbDeactivateUser(int operation) {
    // called from the delete dialog
    logger.log(Level.INFO, "Called pbDeactivateUser(), operation = " + operation);
    WlCdUser w = DoUserOperation(getDeleteUser(), operation);
    RequestContext.getCurrentInstance().closeDialog(w);

}
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Erik Ruud
  • 13
  • 3
  • Seems fine. Though you didn't post the code for `pbDeleteUserPrepare`, which, I assume, opens the dialog. Do you really need to use Dialog Framework? http://stackoverflow.com/questions/26492247/will-primefaces-opendialog-break-viewscope/26507691#26507691 – Vsevolod Golovanov Apr 24 '15 at 16:18
  • From where are you getting the user in #{ctrlUsersBean.pbDeleteUserPrepare(user)} – user1433804 Apr 25 '15 at 18:33
  • I added some more of my code to the original Question. Please remember also that the main idea was to get the Dialog Framework to work. The code is very simple and a bit cumbersome. – Erik Ruud Apr 27 '15 at 09:08
  • I changed my code into using and explicit calls to Javascript. This works perfectly, but I did not achieve the knowledge of using Dialog Framework. Thanks to Vsolvolod for pushing me a bit. – Erik Ruud Apr 29 '15 at 07:34

0 Answers0