/** * Copyright 2014-2017 Riccardo Massera (TheCoder4.Eu) and Stephan Rauh (http://www.beyondjava.net). * * This file is part of BootsFaces. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package net.bootsfaces.component.message; import javax.el.ValueExpression; import javax.faces.component.FacesComponent; import javax.faces.component.UIMessage; import net.bootsfaces.C; import net.bootsfaces.listeners.AddResourcesListener; import net.bootsfaces.render.IResponsive; import net.bootsfaces.utils.BsfUtils; /** This class holds the attributes of <b:message />. */ @FacesComponent(Message.COMPONENT_TYPE) public class Message extends UIMessage implements IResponsive { public static final String COMPONENT_TYPE = C.BSFCOMPONENT + ".message.Message"; public static final String COMPONENT_FAMILY = C.BSFCOMPONENT; public static final String DEFAULT_RENDERER = "net.bootsfaces.component.message.Message"; public Message() { setRendererType(DEFAULT_RENDERER); AddResourcesListener.addThemedCSSResource("core.css"); //!bs-less//AddResourcesListener.addThemedCSSResource("alerts.css"); //AddResourcesListener.addThemedCSSResource("bsf.css"); AddResourcesListener.addResourceToHeadButAfterJQuery(C.BSF_LIBRARY, "js/alert.js"); } public void setValueExpression(String name, ValueExpression binding) { name = BsfUtils.snakeCaseToCamelCase(name); super.setValueExpression(name, binding); } public String getFamily() { return COMPONENT_FAMILY; } protected enum PropertyKeys { colLg, colMd, colSm, colXs, dir, display, errorClass, errorStyle, escape, fatalClass, fatalStyle, hidden, infoClass, infoStyle, largeScreen, lineBreak, lineBreakTag, mediumScreen, offset, offsetLg, offsetMd, offsetSm, offsetXs, onlyMostSevere, redisplay, showDetail, showIcon, showSummary, smallScreen, span, style, styleClass, tinyScreen, visible, warnClass, warnStyle; String toString; PropertyKeys(String toString) { this.toString = toString; } PropertyKeys() { } public String toString() { return ((this.toString != null) ? this.toString : super.toString()); } } /** * Integer value to specify how many columns to span on large screens (≥1200 pixels wide). The number may optionally be followed by "column" or "columns". Alternative legal values: half, one-third, two-thirds, one-fourth, three-fourths. <P> * @return Returns the value of the attribute, or "-1", if it hasn't been set by the JSF file. */ public String getColLg() { return (String) getStateHelper().eval(PropertyKeys.colLg, "-1"); } /** * Integer value to specify how many columns to span on large screens (≥1200 pixels wide). The number may optionally be followed by "column" or "columns". Alternative legal values: half, one-third, two-thirds, one-fourth, three-fourths. <P> * Usually this method is called internally by the JSF engine. */ public void setColLg(String _colLg) { getStateHelper().put(PropertyKeys.colLg, _colLg); } /** * Integer value to specify how many columns to span on medium screens (≥992 pixels wide). The number may optionally be followed by "column" or "columns". Alternative legal values: half, one-third, two-thirds, one-fourth, three-fourths. <P> * @return Returns the value of the attribute, or "-1", if it hasn't been set by the JSF file. */ public String getColMd() { return (String) getStateHelper().eval(PropertyKeys.colMd, "-1"); } /** * Integer value to specify how many columns to span on medium screens (≥992 pixels wide). The number may optionally be followed by "column" or "columns". Alternative legal values: half, one-third, two-thirds, one-fourth, three-fourths. <P> * Usually this method is called internally by the JSF engine. */ public void setColMd(String _colMd) { getStateHelper().put(PropertyKeys.colMd, _colMd); } /** * Integer value to specify how many columns to span on small screens (≥768p pixels wide). The number may optionally be followed by "column" or "columns". Alternative legal values: half, one-third, two-thirds, one-fourth, three-fourths. <P> * @return Returns the value of the attribute, or "-1", if it hasn't been set by the JSF file. */ public String getColSm() { return (String) getStateHelper().eval(PropertyKeys.colSm, "-1"); } /** * Integer value to specify how many columns to span on small screens (≥768p pixels wide). The number may optionally be followed by "column" or "columns". Alternative legal values: half, one-third, two-thirds, one-fourth, three-fourths. <P> * Usually this method is called internally by the JSF engine. */ public void setColSm(String _colSm) { getStateHelper().put(PropertyKeys.colSm, _colSm); } /** * Integer value to specify how many columns to span on tiny screens (≤ 767 pixels wide). The number may optionally be followed by "column" or "columns". Alternative legal values: half, one-third, two-thirds, one-fourth, three-fourths. <P> * @return Returns the value of the attribute, or "-1", if it hasn't been set by the JSF file. */ public String getColXs() { return (String) getStateHelper().eval(PropertyKeys.colXs, "-1"); } /** * Integer value to specify how many columns to span on tiny screens (≤ 767 pixels wide). The number may optionally be followed by "column" or "columns". Alternative legal values: half, one-third, two-thirds, one-fourth, three-fourths. <P> * Usually this method is called internally by the JSF engine. */ public void setColXs(String _colXs) { getStateHelper().put(PropertyKeys.colXs, _colXs); } /** * HTML: The direction of text display, either 'ltr' (left-to-right) or 'rtl' (right-to-left). <P> * @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file. */ public String getDir() { return (String) getStateHelper().eval(PropertyKeys.dir); } /** * HTML: The direction of text display, either 'ltr' (left-to-right) or 'rtl' (right-to-left). <P> * Usually this method is called internally by the JSF engine. */ public void setDir(String _dir) { getStateHelper().put(PropertyKeys.dir, _dir); } /** * If you use the "visible" attribute, the value of this attribute is added. Legal values: block, inline, inline-block. Default: block. <P> * @return Returns the value of the attribute, or "block", if it hasn't been set by the JSF file. */ public String getDisplay() { return (String) getStateHelper().eval(PropertyKeys.display, "block"); } /** * If you use the "visible" attribute, the value of this attribute is added. Legal values: block, inline, inline-block. Default: block. <P> * Usually this method is called internally by the JSF engine. */ public void setDisplay(String _display) { getStateHelper().put(PropertyKeys.display, _display); } /** * CSS class to be used for messages with severity "ERROR". <P> * @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file. */ public String getErrorClass() { return (String) getStateHelper().eval(PropertyKeys.errorClass); } /** * CSS class to be used for messages with severity "ERROR". <P> * Usually this method is called internally by the JSF engine. */ public void setErrorClass(String _errorClass) { getStateHelper().put(PropertyKeys.errorClass, _errorClass); } /** * CSS style to be used for messages with severity "ERROR". <P> * @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file. */ public String getErrorStyle() { return (String) getStateHelper().eval(PropertyKeys.errorStyle); } /** * CSS style to be used for messages with severity "ERROR". <P> * Usually this method is called internally by the JSF engine. */ public void setErrorStyle(String _errorStyle) { getStateHelper().put(PropertyKeys.errorStyle, _errorStyle); } /** * By default, error messages encode HTML and JavaScript code. Instead of being executed, the source code is displayed. This protects you against hacker attacks. By setting escape=false, you deactivate the protection, and allow HTML and JavaScript code to be rendered. <P> * @return Returns the value of the attribute, or true, if it hasn't been set by the JSF file. */ public boolean isEscape() { return (boolean) (Boolean) getStateHelper().eval(PropertyKeys.escape, true); } /** * By default, error messages encode HTML and JavaScript code. Instead of being executed, the source code is displayed. This protects you against hacker attacks. By setting escape=false, you deactivate the protection, and allow HTML and JavaScript code to be rendered. <P> * Usually this method is called internally by the JSF engine. */ public void setEscape(boolean _escape) { getStateHelper().put(PropertyKeys.escape, _escape); } /** * CSS class to be used for messages with severity "FATAL". <P> * @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file. */ public String getFatalClass() { return (String) getStateHelper().eval(PropertyKeys.fatalClass); } /** * CSS class to be used for messages with severity "FATAL". <P> * Usually this method is called internally by the JSF engine. */ public void setFatalClass(String _fatalClass) { getStateHelper().put(PropertyKeys.fatalClass, _fatalClass); } /** * CSS style to be used for messages with severity "FATAL". <P> * @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file. */ public String getFatalStyle() { return (String) getStateHelper().eval(PropertyKeys.fatalStyle); } /** * CSS style to be used for messages with severity "FATAL". <P> * Usually this method is called internally by the JSF engine. */ public void setFatalStyle(String _fatalStyle) { getStateHelper().put(PropertyKeys.fatalStyle, _fatalStyle); } /** * This column is hidden on a certain screen size and below. Legal values: lg, md, sm, xs. <P> * @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file. */ public String getHidden() { return (String) getStateHelper().eval(PropertyKeys.hidden); } /** * This column is hidden on a certain screen size and below. Legal values: lg, md, sm, xs. <P> * Usually this method is called internally by the JSF engine. */ public void setHidden(String _hidden) { getStateHelper().put(PropertyKeys.hidden, _hidden); } /** * CSS class to be used for messages with severity "INFO". <P> * @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file. */ public String getInfoClass() { return (String) getStateHelper().eval(PropertyKeys.infoClass); } /** * CSS class to be used for messages with severity "INFO". <P> * Usually this method is called internally by the JSF engine. */ public void setInfoClass(String _infoClass) { getStateHelper().put(PropertyKeys.infoClass, _infoClass); } /** * CSS style to be used for messages with severity "INFO". <P> * @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file. */ public String getInfoStyle() { return (String) getStateHelper().eval(PropertyKeys.infoStyle); } /** * CSS style to be used for messages with severity "INFO". <P> * Usually this method is called internally by the JSF engine. */ public void setInfoStyle(String _infoStyle) { getStateHelper().put(PropertyKeys.infoStyle, _infoStyle); } /** * Alternative spelling to col-lg. Integer value to specify how many columns to span on large screens (≥1200 pixels wide). The number may optionally be followed by "column" or "columns". Alternative legal values: half, one-third, two-thirds, one-fourth, three-fourths. <P> * @return Returns the value of the attribute, or "-1", if it hasn't been set by the JSF file. */ public String getLargeScreen() { return (String) getStateHelper().eval(PropertyKeys.largeScreen, "-1"); } /** * Alternative spelling to col-lg. Integer value to specify how many columns to span on large screens (≥1200 pixels wide). The number may optionally be followed by "column" or "columns". Alternative legal values: half, one-third, two-thirds, one-fourth, three-fourths. <P> * Usually this method is called internally by the JSF engine. */ public void setLargeScreen(String _largeScreen) { getStateHelper().put(PropertyKeys.largeScreen, _largeScreen); } /** * If there's more than one message, they can optionally be separated by a line break. By default, the separator is a br tag. <P> * @return Returns the value of the attribute, or true, if it hasn't been set by the JSF file. */ public boolean isLineBreak() { return (boolean) (Boolean) getStateHelper().eval(PropertyKeys.lineBreak, true); } /** * If there's more than one message, they can optionally be separated by a line break. By default, the separator is a br tag. <P> * Usually this method is called internally by the JSF engine. */ public void setLineBreak(boolean _lineBreak) { getStateHelper().put(PropertyKeys.lineBreak, _lineBreak); } /** * If there's more than one message, they can optionally be separated by a line break. By default, the separator is a br tag. You can replace if with an arbitrary HTML snippet. <P> * @return Returns the value of the attribute, or "<br />", if it hasn't been set by the JSF file. */ public String getLineBreakTag() { return (String) getStateHelper().eval(PropertyKeys.lineBreakTag, "<br />"); } /** * If there's more than one message, they can optionally be separated by a line break. By default, the separator is a br tag. You can replace if with an arbitrary HTML snippet. <P> * Usually this method is called internally by the JSF engine. */ public void setLineBreakTag(String _lineBreakTag) { getStateHelper().put(PropertyKeys.lineBreakTag, _lineBreakTag); } /** * Alternative spelling to col-md. Integer value to specify how many columns to span on medium screens (≥992 pixels wide). The number may optionally be followed by "column" or "columns". Alternative legal values: half, one-third, two-thirds, one-fourth, three-fourths. <P> * @return Returns the value of the attribute, or "-1", if it hasn't been set by the JSF file. */ public String getMediumScreen() { return (String) getStateHelper().eval(PropertyKeys.mediumScreen, "-1"); } /** * Alternative spelling to col-md. Integer value to specify how many columns to span on medium screens (≥992 pixels wide). The number may optionally be followed by "column" or "columns". Alternative legal values: half, one-third, two-thirds, one-fourth, three-fourths. <P> * Usually this method is called internally by the JSF engine. */ public void setMediumScreen(String _mediumScreen) { getStateHelper().put(PropertyKeys.mediumScreen, _mediumScreen); } /** * Integer value to specify how many columns to offset. <P> * @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file. */ public String getOffset() { return (String) getStateHelper().eval(PropertyKeys.offset); } /** * Integer value to specify how many columns to offset. <P> * Usually this method is called internally by the JSF engine. */ public void setOffset(String _offset) { getStateHelper().put(PropertyKeys.offset, _offset); } /** * Integer value to specify how many columns to offset. <P> * @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file. */ public String getOffsetLg() { return (String) getStateHelper().eval(PropertyKeys.offsetLg); } /** * Integer value to specify how many columns to offset. <P> * Usually this method is called internally by the JSF engine. */ public void setOffsetLg(String _offsetLg) { getStateHelper().put(PropertyKeys.offsetLg, _offsetLg); } /** * Integer value to specify how many columns to offset. <P> * @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file. */ public String getOffsetMd() { return (String) getStateHelper().eval(PropertyKeys.offsetMd); } /** * Integer value to specify how many columns to offset. <P> * Usually this method is called internally by the JSF engine. */ public void setOffsetMd(String _offsetMd) { getStateHelper().put(PropertyKeys.offsetMd, _offsetMd); } /** * Integer value to specify how many columns to offset. <P> * @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file. */ public String getOffsetSm() { return (String) getStateHelper().eval(PropertyKeys.offsetSm); } /** * Integer value to specify how many columns to offset. <P> * Usually this method is called internally by the JSF engine. */ public void setOffsetSm(String _offsetSm) { getStateHelper().put(PropertyKeys.offsetSm, _offsetSm); } /** * Integer value to specify how many columns to offset. <P> * @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file. */ public String getOffsetXs() { return (String) getStateHelper().eval(PropertyKeys.offsetXs); } /** * Integer value to specify how many columns to offset. <P> * Usually this method is called internally by the JSF engine. */ public void setOffsetXs(String _offsetXs) { getStateHelper().put(PropertyKeys.offsetXs, _offsetXs); } /** * By default, b:message shows every message reported for the component. You can limit it to one message by setting this flag to true. In this case, BootsFaces shows only the most important message (measured by the severity level). <P> * @return Returns the value of the attribute, or false, if it hasn't been set by the JSF file. */ public boolean isOnlyMostSevere() { return (boolean) (Boolean) getStateHelper().eval(PropertyKeys.onlyMostSevere, false); } /** * By default, b:message shows every message reported for the component. You can limit it to one message by setting this flag to true. In this case, BootsFaces shows only the most important message (measured by the severity level). <P> * Usually this method is called internally by the JSF engine. */ public void setOnlyMostSevere(boolean _onlyMostSevere) { getStateHelper().put(PropertyKeys.onlyMostSevere, _onlyMostSevere); } /** * Flag indicating whether previously handled messages are redisplayed or not <P> * @return Returns the value of the attribute, or true, if it hasn't been set by the JSF file. */ public boolean isRedisplay() { return (boolean) (Boolean) getStateHelper().eval(PropertyKeys.redisplay, true); } /** * Flag indicating whether previously handled messages are redisplayed or not <P> * Usually this method is called internally by the JSF engine. */ public void setRedisplay(boolean _redisplay) { getStateHelper().put(PropertyKeys.redisplay, _redisplay); } /** * Specifies whether the detailed information from the message should be shown. Default to true. <P> * @return Returns the value of the attribute, or true, if it hasn't been set by the JSF file. */ public boolean isShowDetail() { return (boolean) (Boolean) getStateHelper().eval(PropertyKeys.showDetail, true); } /** * Specifies whether the detailed information from the message should be shown. Default to true. <P> * Usually this method is called internally by the JSF engine. */ public void setShowDetail(boolean _showDetail) { getStateHelper().put(PropertyKeys.showDetail, _showDetail); } /** * If false, the icon of the message is not show. Default = true. <P> * @return Returns the value of the attribute, or true, if it hasn't been set by the JSF file. */ public boolean isShowIcon() { return (boolean) (Boolean) getStateHelper().eval(PropertyKeys.showIcon, true); } /** * If false, the icon of the message is not show. Default = true. <P> * Usually this method is called internally by the JSF engine. */ public void setShowIcon(boolean _showIcon) { getStateHelper().put(PropertyKeys.showIcon, _showIcon); } /** * Specifies whether the summary information from the message should be shown. Defaults to true. <P> * @return Returns the value of the attribute, or true, if it hasn't been set by the JSF file. */ public boolean isShowSummary() { return (boolean) (Boolean) getStateHelper().eval(PropertyKeys.showSummary, true); } /** * Specifies whether the summary information from the message should be shown. Defaults to true. <P> * Usually this method is called internally by the JSF engine. */ public void setShowSummary(boolean _showSummary) { getStateHelper().put(PropertyKeys.showSummary, _showSummary); } /** * Alternative spelling to col-sm. Integer value to specify how many columns to span on small screens (≥768p pixels wide). The number may optionally be followed by "column" or "columns". Alternative legal values: half, one-third, two-thirds, one-fourth, three-fourths. <P> * @return Returns the value of the attribute, or "-1", if it hasn't been set by the JSF file. */ public String getSmallScreen() { return (String) getStateHelper().eval(PropertyKeys.smallScreen, "-1"); } /** * Alternative spelling to col-sm. Integer value to specify how many columns to span on small screens (≥768p pixels wide). The number may optionally be followed by "column" or "columns". Alternative legal values: half, one-third, two-thirds, one-fourth, three-fourths. <P> * Usually this method is called internally by the JSF engine. */ public void setSmallScreen(String _smallScreen) { getStateHelper().put(PropertyKeys.smallScreen, _smallScreen); } /** * Integer value to specify how many columns to span on medium screens (≥992 pixels). The number may optionally be followed by "column" or "columns". Alternative legal values: half, one-third, two-thirds, one-fourth, three-fourths. <P> * @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file. */ public String getSpan() { return (String) getStateHelper().eval(PropertyKeys.span); } /** * Integer value to specify how many columns to span on medium screens (≥992 pixels). The number may optionally be followed by "column" or "columns". Alternative legal values: half, one-third, two-thirds, one-fourth, three-fourths. <P> * Usually this method is called internally by the JSF engine. */ public void setSpan(String _span) { getStateHelper().put(PropertyKeys.span, _span); } /** * HTML: CSS styling instructions. <P> * @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file. */ public String getStyle() { return (String) getStateHelper().eval(PropertyKeys.style); } /** * HTML: CSS styling instructions. <P> * Usually this method is called internally by the JSF engine. */ public void setStyle(String _style) { getStateHelper().put(PropertyKeys.style, _style); } /** * The CSS class for this element. Corresponds to the HTML 'class' attribute. <P> * @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file. */ public String getStyleClass() { return (String) getStateHelper().eval(PropertyKeys.styleClass); } /** * The CSS class for this element. Corresponds to the HTML 'class' attribute. <P> * Usually this method is called internally by the JSF engine. */ public void setStyleClass(String _styleClass) { getStateHelper().put(PropertyKeys.styleClass, _styleClass); } /** * Alternative spelling to col-xs. Integer value to specify how many columns to span on tiny screens (≤ 767 pixels wide). The number may optionally be followed by "column" or "columns". Alternative legal values: half, one-third, two-thirds, one-fourth, three-fourths. <P> * @return Returns the value of the attribute, or "-1", if it hasn't been set by the JSF file. */ public String getTinyScreen() { return (String) getStateHelper().eval(PropertyKeys.tinyScreen, "-1"); } /** * Alternative spelling to col-xs. Integer value to specify how many columns to span on tiny screens (≤ 767 pixels wide). The number may optionally be followed by "column" or "columns". Alternative legal values: half, one-third, two-thirds, one-fourth, three-fourths. <P> * Usually this method is called internally by the JSF engine. */ public void setTinyScreen(String _tinyScreen) { getStateHelper().put(PropertyKeys.tinyScreen, _tinyScreen); } /** * This column is shown on a certain screen size and above. Legal values: lg, md, sm, xs. <P> * @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file. */ public String getVisible() { return (String) getStateHelper().eval(PropertyKeys.visible); } /** * This column is shown on a certain screen size and above. Legal values: lg, md, sm, xs. <P> * Usually this method is called internally by the JSF engine. */ public void setVisible(String _visible) { getStateHelper().put(PropertyKeys.visible, _visible); } /** * CSS class to be used for messages with severity "WARN". <P> * @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file. */ public String getWarnClass() { return (String) getStateHelper().eval(PropertyKeys.warnClass); } /** * CSS class to be used for messages with severity "WARN". <P> * Usually this method is called internally by the JSF engine. */ public void setWarnClass(String _warnClass) { getStateHelper().put(PropertyKeys.warnClass, _warnClass); } /** * CSS style to be used for messages with severity "WARN". <P> * @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file. */ public String getWarnStyle() { return (String) getStateHelper().eval(PropertyKeys.warnStyle); } /** * CSS style to be used for messages with severity "WARN". <P> * Usually this method is called internally by the JSF engine. */ public void setWarnStyle(String _warnStyle) { getStateHelper().put(PropertyKeys.warnStyle, _warnStyle); } }