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

The following examples show how to use javax.faces.application.FacesMessage#getSummary() . 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: FormLayoutRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
protected void writeErrorSummaryRow(FacesContext context, ResponseWriter w, FormLayout c, FacesMessage m) throws IOException {
    w.startElement("li", c); // $NON-NLS-1$
    
    String title = null;
    if(StringUtil.isNotEmpty(title)) {
        // TODO supposed to use the field label here.
        w.startElement("strong", c); // $NON-NLS-1$
            w.writeText(title,null);
        w.endElement("strong"); // $NON-NLS-1$
    }
    String text = m.getSummary();
    if( StringUtil.isNotEmpty(text) ){
        w.writeText(text,null);
    }
    w.endElement("li"); // $NON-NLS-1$
}
 
Example 2
Source File: MobileFormTableRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
@Override
protected void writeErrorSummaryRow(FacesContext context, ResponseWriter w, FormLayout c, FacesMessage m) throws IOException {
    w.startElement("h2", c); // $NON-NLS-1$
    String style = (String)getProperty(PROP_ERRORSUMMARYITEMSTYLE);
    if(StringUtil.isNotEmpty(style)) {
        w.writeAttribute("style", style, null); // $NON-NLS-1$
    }
    String cls = (String)getProperty(PROP_ERRORSUMMARYITEMCLASS);
    if(StringUtil.isNotEmpty(cls)) {
        w.writeAttribute("class", cls, null); // $NON-NLS-1$
    }
    String title = null;
    if(StringUtil.isNotEmpty(title)) {
        w.startElement("strong", c); // $NON-NLS-1$
            w.writeText(title,null);
        w.endElement("strong"); // $NON-NLS-1$
    }
    String text = m.getSummary();
    w.writeText(text,null);
    w.endElement("h2"); // $NON-NLS-1$
}
 
Example 3
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 4
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);
}