How to show a warning message to the user (and emphasize the severity of the situation)

I tried to show the warning message to the client in such a way that he finds out that this is a warning or something that he did wrong. But all I know how to do is an informational message. How can I make him look more serious?

if (this.instance.getName().trim().equals("")){ addFacesMessage("You must type a name!"); return null; } 

It looks too friendly.

+4
source share
5 answers

As Sherwin said, you should use StatusMessages instead of FacesMessages. StatusMessages has many good methods, you can also look at them.

 import org.jboss.seam.international.StatusMessages; import org.jboss.seam.international.StatusMessage.Severity; .... StatusMessages.instance().add(Severity.ERROR, "Message"); 

after that you can use errorStyle, fatalStyle, warnStyle to customize the appearance of messages.

 <h:messages errorStyle="yourStyle" /> 
+2
source

Use status messages like this

 StatusMessages.instance().add(Severity.ERROR, "Incorrect answers below."); 

Do not use FacesMessages .

thanks

+1
source

Inject:

 @In FacesMessages facesMessages; facesMessages.add(Severity.WARN, "Your message"); 

Severity is an enumeration containing several warning levels.

0
source

Can you use a registrar?

 logger = Logger.getLogger(getClass().getName()); logger.severe(message); 
0
source

Make sure your import is correct.

 import org.jboss.seam.faces.FacesMessages; import org.jboss.seam.international.StatusMessage.Severity; 

Then add the facesMessages component.

 @In(create = true) FacesMessages facesMessages; 

You can then set the error message and severity as shown below.

 facesMessages.add(Severity.ERROR, "You must type a name!"); 

Now display the message as shown below

 <h:messages errorStyle="color:red"/> 

For Ajax requests, use the rich:messages component.

 <rich:messages errorClass="yourErrClass"/> 
0
source

All Articles