Messages could inform if there are error messages added #157

Closed
ramonchiara opened this Issue Aug 8, 2015 · 5 comments

Projects

None yet

2 participants

@ramonchiara

Sometimes I have to do some validation in action method.
So, after validations, I'd like to know if there were any messages added.
The feature could check globally or for some specific cliendId.

@BalusC
Member
BalusC commented Aug 10, 2015

The <o:messages> already supports it.

Check the "Displaying single message" case in http://showcase.omnifaces.org/components/messages

Note that the client ID can be the form itself for a "global" check.

@BalusC BalusC closed this Aug 10, 2015
@ramonchiara

Probably I didn't make myself clear...
The problem is when I have to test if there were some message added in the action method of a back bean.
Example:

pubic void action() {
   if (...) {
      Messages.add...
   }
   if (...) {
      Messages.add...
   }
   ...

   // problem is here
   if (!Faces.getContext().getMessageList().isEmpty()) {
      return null;
   }

  ...
}

I would like to do something like:

if (Messages.isNotEmpty()) {
    return null;
}
@BalusC
Member
BalusC commented Aug 12, 2015

I see. Thank you for clarifying.

@BalusC BalusC reopened this Aug 12, 2015
@BalusC BalusC closed this in 15a5705 Aug 12, 2015
@BalusC
Member
BalusC commented Aug 12, 2015

New methods are available in today's snapshot.

@ramonchiara

Cool!!! :-)

@BalusC BalusC added the question label Oct 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment