Java Code Examples for javax.faces.application.FacesMessage#getDetail()

The following examples show how to use javax.faces.application.FacesMessage#getDetail() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JsfUtils.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
public static boolean isNewMessage(List<FacesMessage> facesMessages, FacesMessage messageToCheck)
{
    for (FacesMessage facesMessage : facesMessages)
    {
        if ((facesMessage.getSummary() != null && facesMessage.getSummary().equals(messageToCheck.getSummary()) ||
                facesMessage.getSummary() == null && messageToCheck.getSummary() == null) &&
                (facesMessage.getDetail() != null && facesMessage.getDetail().equals(messageToCheck.getDetail()) ||
                    facesMessage.getDetail() == null && messageToCheck.getDetail() == null))
        {
            return false;
        }
    }
    return true;
}
 
Example 2
Source File: GrowlRenderer.java    From BootsFaces-OSP with Apache License 2.0 4 votes vote down vote up
/**
 * Encode single faces message as growl
 * @param facesContext
 * @param uiGrowl
 * @param msg
 * @throws IOException
 */
private void encodeSeverityMessage(FacesContext facesContext, Growl uiGrowl, FacesMessage msg) 
throws IOException {
    ResponseWriter writer = facesContext.getResponseWriter();

    String summary = msg.getSummary() != null ? msg.getSummary() : "";
    String detail = msg.getDetail() != null ? msg.getDetail() : summary;
    if(uiGrowl.isEscape()) {
    	summary = BsfUtils.escapeHtml(summary);
    	detail = BsfUtils.escapeHtml(detail);
    }
    summary = summary.replace("'", "\\\'");
    detail = detail.replace("'", "\\\'");
    
    // get message type
    String messageType = getMessageType(msg);
    
    // get icon for message
    String icon = uiGrowl.getIcon() != null ? "fa fa-" + uiGrowl.getIcon() : getSeverityIcon(msg);
    
    String template = null;
    if (uiGrowl.getStyle()!= null) {
    		template = TEMPLATE.replace("{8}", "style='" + uiGrowl.getStyle() + "'");
    }
    if (uiGrowl.getStyleClass() != null) {
     	if (null == template) {
     		template = TEMPLATE;
     }
     	template = template.replace("{9}", uiGrowl.getStyleClass());
    }
    if (null == template) {
     	template="";
    }	else {
    		template = ", template: \"" + template.replace("{8}", "").replace("{9}", "").replace("\n", "") + "\"";
    		System.out.println(template);
    }

    writer.writeText("" +
"$.notify({" + 
"	title: '" + (uiGrowl.isShowSummary() ? summary : "") + "', " +
"	message: '" + (uiGrowl.isShowDetail() ? detail : "") + "', " +
"	icon: '" +  icon + "'" +
"}, {" + 
"	position: null, " + 
"	type: '" + messageType + "', " +
"	allow_dismiss: " + uiGrowl.isAllowDismiss() + ", " +
"	newest_on_top: " + uiGrowl.isNewestOnTop() + ", " + 
"     delay: " + uiGrowl.getDelay() + ", " + 
"     timer: " + uiGrowl.getTimer() + ", " + 
"	placement: { " + 
"		from: '" + uiGrowl.getPlacementFrom() + "'," + 
"		align: '" + uiGrowl.getPlacementAlign() + "'" + 
"	}, " + 
"	animate: { " + 
"		enter: '" + uiGrowl.getAnimationEnter() + "', " +
"		exit: '" + uiGrowl.getAnimationExit() + "' " +
"	} " + 
"     " + template +
" }); " +
"", null);
}