3
votes

I have added component to my xhtml, to catch dateSelect event on p:calendar component. It also uses my custom validator, which throws exception if date is from the wrong range. I want to display error message in p:message, but it is displayed in both p:message and growl. How can I disable displaying this message in growl?

I tried different things. I tried to somehow disable p:growl component, but with no result.

Here is my calendar component with ajax:

                    <p:calendar id="dbstartdate" tabindex="3"
                                styleClass="calrequested" style="width:99px;"
                                showButtonPanel="true">

                        <p:ajax event="dateSelect"
                                listener="#{MyBean.saveDateRange}"
                                update=":dashboard_frameset"/>
                    </p:calendar>

I tried e.g. something like this:

<p:growl for="dbstartdate" rendered="false"/>

and the same for p:ajax (I added id there).

Unfortunately, it was unsuccessful. Does anyone of you has idea how to disable growl from p:ajax? Thanks in advance!

1
You have a for="dbstartdate" that explicitly references the p:calendar. Why not just remove it? But what is your 'custom validator'? A real validator should not throw exceptions. But maybe a 'global only' would help?Kukeltje
You best use global only on the growl or play with the severity attribute of the growl and message components.Jasper de Vries

1 Answers

1
votes

To solve this issue, you have two options to choose from as far as I can see;

Only allow global message in p:growl

The first option is to do <p:growl globalOnly="true"/>. This will put the PrimeFaces growl into a mode where it only listens for AJAX events and messages that do not have a specific client-id. With this method, adding for=id to a component/request will cause it to only be shown in the destination (for example inside a p:message and not in the growl.

<p:calendar id="calendar">
    <p:ajax global="false" event="dateSelect" />
</p:calendar>

<p:message for="calendar" />
<p:growl globalOnly="true" />

Explicitly use <p:growl for="id"/>

The second route is to make the growl only listen to messages with a specific client-id. This would look something like this;

<p:calendar id="calendar">
    <p:ajax event="dateSelect" />
</p:calendar>

<p:message for="calendar" />
<p:growl for="someotherId" />

Depending on your design goals, you will be prefering one or the other as you main solution. The second solution will filter and ignore faces message without any destination, as there is no component to receive them. This may or may not be desirable.