2
votes

I am building a Webapp using JSF2.2 Majorra & Primefaces 5.1.

I have a dialog, wich i need to validate, when valid, do action.

In that action-method i call, i may or may not send some p:growl messages. They show up, i see them:

if (conflict >= 1) {
    try {
        if (!user.getId().equals(projektLeiter.getId())) {
            logger.info("CONFLICT.........................sending notification email to "
                    + projektLeiter.getFullName() + " with email " + projektLeiter.getEmail());
            EMailUtil.sendMailForOverlap(projektLeiter, currentProject, absence);
            MessageUtil.showGrowlWarn("Eventkonflikt festgestellt!<br/><br/>Leiter des Projekts '"
                    + currentProject.getNameShort() + "' wurde informiert.");
            RequestContext.getCurrentInstance().update("btnForm:growl");
        } else {
            MessageUtil.showGrowlWarn(
                    "Eventkonflikt mit Projekt '" + currentProject.getNameShort() + "' festgestellt!");
        }
    } catch (MessagingException e) {
        logger.catching(e);
        MessageUtil.showGrowlError(
                "Fehler: Kann keine Emails verschicken! Bitte informieren Sie den Administrator.");
    }
}

However, in the oncomplete of the submit button, i tell the dialog to disappear when validation didnt fail, like so:

<p:commandButton value="Speichern" process="detailsBookingDlg"
    update=":dialogForm:detailsBookingInner :dataTableForm:absenceTable"
    action="#{absenceController.onSaveButtonClick}"
    oncomplete="if (!args.validationFailed) {PF('detailsBookingWdgt').hide()}" />

I used a network package explorer to find the problem. There is an extra POST for closing the dialog:

http://s21.postimg.org/6f0nylbs7/close.png

This POST is making my messages disappear. So there lied the problem. When i take out the oncomplete, they stay.

I tried closing the dialog from the action-method using RequestContext BEFORE i show the messages, but that didnt work eighter since the close-POST always seems to be the last one.

I use a template wich involves a navigation.xhtml, that includes the p:growl:

<h:form id="btnForm">
    <div id="welcomeMessage">
        <h:outputText value="#{sessionBean.welcome}" escape="false" />
    </div>
    <p:growl id="growl" showDetail="false" life="10000" autoUpdate="true" redisplay="true" globalOnly="true"
        escape="false" />
</h:form>

I fiddled around with the attributes on both the button and the growl, but when i close the dialog the messages keep disappearing. I dont seem to be able to figure this out.

Any ideas?

1
I don't see any growl in your code.... Please create an minimal reproducible example. You most likely have something like 'autoupdate' on the growl?Kukeltje
Tried removing autoUpdate="true"?Kukeltje
its not the only page that makes use of the growl container so i relie on having set autoUpdate to true sadlyMaster Azazel
T R Y . . . please. If it plays a role, you have more info…Kukeltje

1 Answers

1
votes

One of my colleagues has found the answer:

In the problematic dialog, i had a p:ajax event:

 <p:ajax event="close" immediate="true" update=":mainForm:timeline"
                listener="#{absenceAdministrationController.onCancelButtonClick}" />

Which got called every time i was hiding the dialog. This event was intended to only be fired when clicking the little 'x' in the upper right corner, wich i got completely rid off.

I added a 'Cancel'-button to my dialog and made it closable="false".

That solved the problems i had with it hiding some of my messages.