0
votes

Does anybody know how to change the behaviour of JSF component messages such as validator messages, converter messages ? The project iam working on, it allows user to configure the behaviour of (whether a primeface growl message or normal jsf p:message) custom messages with the severity level. We have separate util class to manage it. But we cant find a solution to configure the behaviour of jsf component messages. We want to show them to user according to the way the user has configured it, Eg: if the user wants to see all messages as growl, all messages including jsf component messages should be shown as growl messages. Any idea? We user primeface 4, jee7, java 1.7

update:

This is an enterprise application. We have one <p:growl id="growlMessageId" for="growlMessage" globalOnly="false" sticky="false" autoUpdate="true" redisplay="true" escape="false"/> and one <p:messages id="messages" globalOnly="false" showDetail="false" autoUpdate="true" closable="true" redisplay="false" escape="false" rendered="#{empty param['showMessageInGlobal'] or param['showMessageInGlobal']}"/> at header and all pages (more than 50) use these 2 components to show all messages. So other than jsf component error messages we have this util method (part of it) to change the behaviour of the message.

FacesMessage fm = new FacesMessage(messageDescriptor);
        fm.setSeverity(this.getFacesMessageSeverity(messageSeverity));
        fm.setDetail("");
        switch (severityDisplayType) {
            case NOTIFICATION:
                this.facesContext.addMessage(componentClientId, fm);
                break;
            case GROWL:
                this.facesContext.addMessage("growlMessage", fm);
                break;
            default:
        }

We want to change jsf component messages behaviour same as above. Keeping 2 messages type in every page is not an option

1
what abt keeping the p:growl and p:message both in your page, but using and el in the rendered attribute can let the user see the mesg in the way he has set it.ZEE
@ZeeshanurRahman i ve updated the original question. We already have both types. Problem is the change the behavior od validation messages such as required field validation in jsp component, it always shows in <p:message component, we want user to configure the behaviour of those messages as well.bluelabel

1 Answers

0
votes

I would keep both component with autoUpdate="true". Something like this:

<p:messages autoUpdate="true" rendered="#{userPreferenceBean.showMessages}" />
<p:growl autoUpdate="true" rendered="#{userPreferenceBean.showGrowl}" />