[OmniFaces utilities] The
isEmpty()
method returns true
if there are no faces messages, otherwise false
[OmniFaces utilities] The
isEmpty(String clientId)
method returns true
if there are no faces messages for the given client ID, otherwise false
[OmniFaces utilities] The
isGlobalEmpty()
method returns true
if there are no global faces messages, otherwise false
Methods:
- Messages#isEmpty() - returns true if there are no faces messages, otherwise false
See also: Faces#getContext()
- Messages#isEmpty(String clientId) - returns true if there are no faces messages for the given client ID, otherwise false
See also: Faces#getContext()
- Messages#isGlobalEmpty() - returns true if there are no global faces messages, otherwise false
Usage:
We can use some simple logs to understand how each of the above methods works. We suppose that we have a clientId, myForm:myInput:
We can use some simple logs to understand how each of the above methods works. We suppose that we have a clientId, myForm:myInput:
LOG.log(Level.INFO,
"Messages list is empty ? {0}", Messages.isEmpty());
LOG.log(Level.INFO,
"Global messages list is empty ? {0}", Messages.isEmpty(null));
LOG.log(Level.INFO,
"Messages list for client Id myForm:myInput is empty ? {0}", Messages.isEmpty("myForm:myInput"));
·
no messages
Outputs:
Messages
list is empty ? true
Global
messages list is empty ? true
Messages
list for client Id myForm:myInput is empty ? true
·
have some global messages, no clientId specific message (no messages for myForm:myInput)
FacesContext.getCurrentInstance().addMessage(null,
new FacesMessage(FacesMessage.SEVERITY_INFO,"Global Info","Dummy info message!"));
new FacesMessage(FacesMessage.SEVERITY_INFO,"Global Info","Dummy info message!"));
Outputs:
Messages
list is empty ? false
Global
messages list is empty ? false
Messages
list for client Id myForm:myInput is empty ? true
·
have some messages for clientId, myForm:myInput, but no global messages
FacesContext.getCurrentInstance().addMessage("myForm:myInput",
new FacesMessage(FacesMessage.SEVERITY_INFO,"Not Global Info","Dummy info message!"));
new FacesMessage(FacesMessage.SEVERITY_INFO,"Not Global Info","Dummy info message!"));
Outputs:
Messages
list is empty ? false
Global
messages list is empty ? true
Messages
list for client Id myForm:myInput is empty ? false
·
have some messages for clientId, myForm:myInput and some global messages
FacesContext.getCurrentInstance().addMessage(null,
new FacesMessage(FacesMessage.SEVERITY_INFO,"Global Info","Dummy info message!"));
new FacesMessage(FacesMessage.SEVERITY_INFO,"Global Info","Dummy info message!"));
FacesContext.getCurrentInstance().addMessage("myForm:myInput",
new FacesMessage(FacesMessage.SEVERITY_INFO,"Not Global Info","Dummy info message!"));
new FacesMessage(FacesMessage.SEVERITY_INFO,"Not Global Info","Dummy info message!"));
Outputs:
Messages
list is empty ? false
Global
messages list is empty ? false
Messages
list for client Id myForm:myInput is empty ? false
Niciun comentariu :
Trimiteți un comentariu