All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javax.faces.component.UIMessages Maven / Gradle / Ivy

There is a newer version: 4.1.1
Show newest version
/*
 * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v. 2.0, which is available at
 * http://www.eclipse.org/legal/epl-2.0.
 *
 * This Source Code may also be made available under the following Secondary
 * Licenses when the conditions for such availability set forth in the
 * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
 * version 2 with the GNU Classpath Exception, which is available at
 * https://www.gnu.org/software/classpath/license.html.
 *
 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
 */

package javax.faces.component;

import javax.faces.context.FacesContext;

/**
 * 

The renderer for this component is responsible for obtaining the * messages from the {@link FacesContext} and displaying them to the * user.

* *

This component supports the Messages renderer-type.

* *

By default, the rendererType property must be set to * "javax.faces.Messages". This value can be changed by * calling the setRendererType() method.

* * */ public class UIMessages extends UIComponentBase { // ------------------------------------------------------ Manifest Constants /** *

The standard component type for this component.

*/ public static final String COMPONENT_TYPE = "javax.faces.Messages"; /** *

The standard component family for this component.

*/ public static final String COMPONENT_FAMILY = "javax.faces.Messages"; enum PropertyKeys { forValue("for"), globalOnly, showDetail, showSummary, redisplay; String toString; PropertyKeys(String toString) { this.toString = toString; } PropertyKeys() { } @Override public String toString() { return ((this.toString != null) ? this.toString : super.toString()); } } // ------------------------------------------------------------ Constructors /** *

Create a new {@link UIMessages} instance with default property * values.

*/ public UIMessages() { super(); setRendererType("javax.faces.Messages"); } // -------------------------------------------------------------- Properties @Override public String getFamily() { return (COMPONENT_FAMILY); } /** *

Return the client identifier of the * component for which this component represents associated message(s) * (if any).

* * @return the for client identifier. */ public String getFor() { return (String) getStateHelper().eval(PropertyKeys.forValue); } /** *

Set the client identifier of the component for which this * component represents associated message(s) (if any). This * property must be set before the message is displayed.

* * @param newFor The new client id */ public void setFor(String newFor) { getStateHelper().put(PropertyKeys.forValue, newFor); } /** *

Return the flag indicating whether only global messages (that * is, messages with no associated client identifier) should be * rendered. Mutually exclusive with the "for" property which takes * precedence. Defaults to false.

* * @return true if only global messages are to be shown, false otherwise. */ public boolean isGlobalOnly() { return (Boolean) getStateHelper().eval(PropertyKeys.globalOnly, false); } /** *

Set the flag indicating whether only global messages (that is, * messages with no associated client identifier) should be rendered.

* * @param globalOnly The new flag value */ public void setGlobalOnly(boolean globalOnly) { getStateHelper().put(PropertyKeys.globalOnly, globalOnly); } /** *

Return the flag indicating whether the detail * property of the associated message(s) should be displayed. * Defaults to false.

* * @return true if detail is to be shown, false otherwise. */ public boolean isShowDetail() { return (Boolean) getStateHelper().eval(PropertyKeys.showDetail, false); } /** *

Set the flag indicating whether the detail property * of the associated message(s) should be displayed.

* * @param showDetail The new flag */ public void setShowDetail(boolean showDetail) { getStateHelper().put(PropertyKeys.showDetail, showDetail); } /** *

Return the flag indicating whether the summary * property of the associated message(s) should be displayed. * Defaults to true.

* * @return true if the summary is to be shown, false otherwise. */ public boolean isShowSummary() { return (Boolean) getStateHelper().eval(PropertyKeys.showSummary, true); } /** *

Set the flag indicating whether the summary property * of the associated message(s) should be displayed.

* * @param showSummary The new flag value */ public void setShowSummary(boolean showSummary) { getStateHelper().put(PropertyKeys.showSummary, showSummary); } /** * @return true if this UIMessage instance should * redisplay {@link javax.faces.application.FacesMessage}s that have already been handled, * otherwise returns false. By default this method will * always return true if {@link #setRedisplay(boolean)} has * not been called. * * @since 2.0 */ public boolean isRedisplay() { return (Boolean) getStateHelper().eval(PropertyKeys.redisplay, true); } /** *

Set the flag indicating whether the detail property * of the associated message(s) should be displayed.

* * @param redisplay flag indicating whether previously handled messages * are redisplayed or not * * @since 2.0 */ public void setRedisplay(boolean redisplay) { getStateHelper().put(PropertyKeys.redisplay, redisplay); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy