use of javax.faces.application.FacesMessage in project rubia-forums by flashboss.
the class JSFUtil method setErrorMessage.
/**
* @param id
* the id of the error message to create
* @param msg
* the text of the error message to create
*/
public static void setErrorMessage(String id, String msg) {
FacesMessage message = new // severity
FacesMessage(// severity
FacesMessage.SEVERITY_ERROR, // summary
msg, // detail
msg);
getCurrentInstance().addMessage(id, message);
}
use of javax.faces.application.FacesMessage in project rubia-forums by flashboss.
the class JSFUtil method getMessage.
/**
* @param id
* the id of the message to find
*
* @return the text of the message
*/
public static String getMessage(String id) {
String msg = null;
Iterator<FacesMessage> msgs = getCurrentInstance().getMessages(id);
if (msgs != null) {
if (msgs.hasNext()) {
FacesMessage message = msgs.next();
msg = message.getDetail();
}
}
return msg;
}
use of javax.faces.application.FacesMessage in project rubia-forums by flashboss.
the class JSFUtil method handleException.
/**
* @author sshah
*
* @param e
* the exception to handle
*
* @return the navigation state of the application
*/
public static String handleException(Exception e) {
String genericNavState = ERROR;
String msg = e.toString();
FacesMessage message = new // severity
FacesMessage(// severity
FacesMessage.SEVERITY_ERROR, // summary
msg, // detail
msg);
getCurrentInstance().addMessage(ERROR, message);
return genericNavState;
}
use of javax.faces.application.FacesMessage in project tutorials by eugenp.
the class MemberController method register.
public void register() throws Exception {
try {
memberRegistration.register(newMember);
FacesMessage m = new FacesMessage(FacesMessage.SEVERITY_INFO, "Registered!", "Registration successful");
facesContext.addMessage(null, m);
initNewMember();
} catch (Exception e) {
String errorMessage = getRootErrorMessage(e);
FacesMessage m = new FacesMessage(FacesMessage.SEVERITY_ERROR, errorMessage, "Registration unsuccessful");
facesContext.addMessage(null, m);
}
}
use of javax.faces.application.FacesMessage in project core by weld.
the class CommentBoard method post.
public Boolean post() {
if (comment == null || blog == null) {
return null;
}
BlogEntry entry = repository.getEntry(blog.getEntryId());
if (entry == null) {
return null;
}
comment.checkAuthor();
repository.addComment(comment, entry);
FacesContext ctx = FacesContext.getCurrentInstance();
ctx.addMessage(null, new FacesMessage("Thanks for leaving a comment!"));
// FIXME doesn't seem to be working; must investigate
ctx.getExternalContext().getFlash().setKeepMessages(true);
return true;
}
Aggregations