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

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

Go to download

Jakarta Faces defines an MVC framework for building user interfaces for web applications, including UI components, state management, event handing, input validation, page navigation, and support for internationalization and accessibility.

There is a newer version: 4.1.0
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;


/**
 * 

This component is * responsible for displaying messages for a specific {@link * UIComponent}, identified by a clientId or component id relative to the * closest ancestor NamingContainer. The component * obtains the messages from the {@link FacesContext}.

* *

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

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

The standard component type for this component.

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

The standard component family for this component.

*/ public static final String COMPONENT_FAMILY = "javax.faces.Message"; enum PropertyKeys { forValue("for"), 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 UIMessage} instance with default property * values.

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

Return the Identifier * of the component for which to render error messages. If this * component is within the same NamingContainer as the target * component, this must be the component identifier. Otherwise, it * must be an absolute component identifier (starting with ":"). See * the {@link UIComponent#findComponent} for more * information.

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

Set the * 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 the detail * property of the associated message(s) should be displayed. * Defaults to true.

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

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 false.

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

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