Home » Mojarra-2.0.1 » javax » faces » component » [javadoc | source]

    1   /*
    2    * $Id: UIMessages.java,v 1.19 2007/10/18 17:05:24 rlubke Exp $
    3    */
    4   
    5   /*
    6    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    7    * 
    8    * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
    9    * 
   10    * The contents of this file are subject to the terms of either the GNU
   11    * General Public License Version 2 only ("GPL") or the Common Development
   12    * and Distribution License("CDDL") (collectively, the "License").  You
   13    * may not use this file except in compliance with the License. You can obtain
   14    * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
   15    * or glassfish/bootstrap/legal/LICENSE.txt.  See the License for the specific
   16    * language governing permissions and limitations under the License.
   17    * 
   18    * When distributing the software, include this License Header Notice in each
   19    * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
   20    * Sun designates this particular file as subject to the "Classpath" exception
   21    * as provided by Sun in the GPL Version 2 section of the License file that
   22    * accompanied this code.  If applicable, add the following below the License
   23    * Header, with the fields enclosed by brackets [] replaced by your own
   24    * identifying information: "Portions Copyrighted [year]
   25    * [name of copyright owner]"
   26    * 
   27    * Contributor(s):
   28    * 
   29    * If you wish your version of this file to be governed by only the CDDL or
   30    * only the GPL Version 2, indicate your decision by adding "[Contributor]
   31    * elects to include this software in this distribution under the [CDDL or GPL
   32    * Version 2] license."  If you don't indicate a single choice of license, a
   33    * recipient has the option to distribute your version of this file under
   34    * either the CDDL, the GPL Version 2 or to extend the choice of license to
   35    * its licensees as provided above.  However, if you add GPL Version 2 code
   36    * and therefore, elected the GPL Version 2 license, then the option applies
   37    * only if the new code is made subject to such option by the copyright
   38    * holder.
   39    */
   40   
   41   package javax.faces.component;
   42   
   43   import javax.faces.context.FacesContext;
   44   
   45   /**
   46    * <p>The renderer for this component is responsible for obtaining the
   47    * messages from the {@link FacesContext} and displaying them to the
   48    * user.</p>
   49    *
   50    * <p>This component supports the <code>Messages</code> renderer-type.</p>
   51    *
   52    * <p>By default, the <code>rendererType</code> property must be set to
   53    * "<code>javax.faces.Messages</code>".  This value can be changed by
   54    * calling the <code>setRendererType()</code> method.</p>
   55    *
   56    * 
   57    */
   58   
   59   public class UIMessages extends UIComponentBase {
   60   
   61   
   62       // ------------------------------------------------------ Manifest Constants
   63   
   64   
   65       /**
   66        * <p>The standard component type for this component.</p>
   67        */
   68       public static final String COMPONENT_TYPE = "javax.faces.Messages";
   69   
   70   
   71       /**
   72        * <p>The standard component family for this component.</p>
   73        */
   74       public static final String COMPONENT_FAMILY = "javax.faces.Messages";
   75   
   76   
   77       enum PropertyKeys {
   78           forValue("for"),
   79           globalOnly,
   80           showDetail,
   81           showSummary,
   82           redisplay;
   83   
   84           String toString;
   85   
   86           PropertyKeys(String toString) {
   87               this.toString = toString;
   88           }
   89   
   90           PropertyKeys() {
   91           }
   92   
   93           public String toString() {
   94               return ((this.toString != null) ? this.toString : super.toString());
   95           }
   96       }
   97   
   98       // ------------------------------------------------------------ Constructors
   99   
  100   
  101       /**
  102        * <p>Create a new {@link UIMessages} instance with default property
  103        * values.</p>
  104        */
  105       public UIMessages() {
  106   
  107           super();
  108           setRendererType("javax.faces.Messages");
  109   
  110       }
  111   
  112   
  113       // -------------------------------------------------------------- Properties
  114   
  115   
  116       public String getFamily() {
  117   
  118           return (COMPONENT_FAMILY);
  119   
  120       }
  121   
  122       /**
  123        * <p class="changed_added_2_0">Return the client identifier of the
  124        * component for which this component represents associated message(s)
  125        * (if any).</p>
  126        */
  127       public String getFor() {
  128   
  129           return (String) getStateHelper().eval(PropertyKeys.forValue);
  130   
  131       }
  132   
  133   
  134       /**
  135        * <p>Set the client identifier of the component for which this
  136        * component represents associated message(s) (if any).  This
  137        * property must be set before the message is displayed.</p>
  138        *
  139        * @param newFor The new client id
  140        */
  141       public void setFor(String newFor) {
  142   
  143           getStateHelper().put(PropertyKeys.forValue, newFor);
  144   
  145       }
  146   
  147       /**
  148        * <p>Return the flag indicating whether only global messages (that
  149        * is, messages with no associated client identifier) should be
  150        * rendered.  Mutually exclusive with the "for" property which takes
  151   	 * precedence. Defaults to false.</p>
  152        */
  153       public boolean isGlobalOnly() {
  154   
  155           return (Boolean) getStateHelper().eval(PropertyKeys.globalOnly, false);
  156   
  157       }
  158   
  159   
  160       /**
  161        * <p>Set the flag indicating whether only global messages (that is,
  162        * messages with no associated client identifier) should be rendered.</p>
  163        *
  164        * @param globalOnly The new flag value
  165        */
  166       public void setGlobalOnly(boolean globalOnly) {
  167   
  168           getStateHelper().put(PropertyKeys.globalOnly, globalOnly);
  169   
  170       }
  171   
  172       /**
  173        * <p>Return the flag indicating whether the <code>detail</code>
  174        * property of the associated message(s) should be displayed.
  175        * Defaults to false.</p>
  176        */
  177       public boolean isShowDetail() {
  178   
  179           return (Boolean) getStateHelper().eval(PropertyKeys.showDetail, false);
  180   
  181       }
  182   
  183   
  184       /**
  185        * <p>Set the flag indicating whether the <code>detail</code> property
  186        * of the associated message(s) should be displayed.</p>
  187        *
  188        * @param showDetail The new flag
  189        */
  190       public void setShowDetail(boolean showDetail) {
  191   
  192           getStateHelper().put(PropertyKeys.showDetail, showDetail);
  193       }
  194   
  195   
  196       /**
  197        * <p>Return the flag indicating whether the <code>summary</code>
  198        * property of the associated message(s) should be displayed.
  199        * Defaults to true.</p>
  200        */
  201       public boolean isShowSummary() {
  202   
  203           return (Boolean) getStateHelper().eval(PropertyKeys.showSummary, true);
  204   
  205       }
  206   
  207   
  208       /**
  209        * <p>Set the flag indicating whether the <code>summary</code> property
  210        * of the associated message(s) should be displayed.</p>
  211        *
  212        * @param showSummary The new flag value
  213        */
  214       public void setShowSummary(boolean showSummary) {
  215   
  216           getStateHelper().put(PropertyKeys.showSummary, showSummary);
  217   
  218       }
  219   
  220   
  221       /**
  222        * @return <code>true</code> if this <code>UIMessage</code> instance should
  223        *  redisplay {@link javax.faces.application.FacesMessage}s that have already been handled,
  224        *  otherwise returns <code>false</code>.  By default this method will
  225        *  always return <code>true</code> if {@link #setRedisplay(boolean)} has
  226        *  not been called.
  227        *
  228        * @since 2.0
  229        */
  230       public boolean isRedisplay() {
  231   
  232           return (Boolean) getStateHelper().eval(PropertyKeys.redisplay, true);
  233   
  234       }
  235   
  236   
  237       /**
  238        * <p>Set the flag indicating whether the <code>detail</code> property
  239        * of the associated message(s) should be displayed.</p>
  240        *
  241        * @param redisplay flag indicating whether previously handled messages
  242        *  are redisplayed or not
  243        *
  244        * @since 2.0
  245        */
  246       public void setRedisplay(boolean redisplay) {
  247   
  248           getStateHelper().put(PropertyKeys.redisplay, redisplay);
  249   
  250       }
  251   
  252   }

Home » Mojarra-2.0.1 » javax » faces » component » [javadoc | source]