Home » commons-chain-1.2-src » org.apache.commons » chain » web » faces » [javadoc | source]

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *     http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    * Unless required by applicable law or agreed to in writing, software
   12    * distributed under the License is distributed on an "AS IS" BASIS,
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    * See the License for the specific language governing permissions and
   15    * limitations under the License.
   16    */
   17   package org.apache.commons.chain.web.faces;
   18   
   19   
   20   import java.util.Map;
   21   import javax.faces.context.FacesContext;
   22   import org.apache.commons.chain.web.WebContext;
   23   
   24   
   25   /**
   26    * <p>Concrete implementation of {@link WebContext} suitable for use in
   27    * JavaServer Faces apps.  The abstract methods are mapped to the appropriate
   28    * collections of the underlying <code>FacesContext</code> instance
   29    * that is passed to the constructor (or the initialize method).</p>
   30    *
   31    * @author Craig R. McClanahan
   32    * @version $Revision: 480477 $ $Date: 2006-11-29 08:34:52 +0000 (Wed, 29 Nov 2006) $
   33    */
   34   
   35   public class FacesWebContext extends WebContext {
   36   
   37   
   38       // ------------------------------------------------------------ Constructors
   39   
   40   
   41       /**
   42        * <p>Construct an uninitialized {@link FacesWebContext} instance.</p>
   43        */
   44       public FacesWebContext() {
   45       }
   46   
   47   
   48       /**
   49        * <p>Construct a {@link FacesWebContext} instance that is initialized
   50        * with the specified JavaServer Faces API objects.</p>
   51        *
   52        * @param context The <code>FacesContext</code> for this request
   53        */
   54       public FacesWebContext(FacesContext context) {
   55   
   56           initialize(context);
   57   
   58       }
   59   
   60   
   61       // ------------------------------------------------------ Instance Variables
   62   
   63   
   64       /**
   65        * <p>The <code>FacesContext</code> instance for the request represented
   66        * by this {@link WebContext}.</p>
   67        */
   68       private FacesContext context = null;
   69   
   70   
   71       // ---------------------------------------------------------- Public Methods
   72   
   73   
   74       /**
   75        * <p>Return the <code>FacesContext</code> instance for the request
   76        * associated with this {@link FacesWebContext}.</p>
   77        *
   78        * @return The <code>FacesContext</code> for this request
   79        */
   80       public FacesContext getContext() {
   81   
   82       return (this.context);
   83   
   84       }
   85   
   86   
   87       /**
   88        * <p>Initialize (or reinitialize) this {@link FacesWebContext} instance
   89        * for the specified JavaServer Faces API objects.</p>
   90        *
   91        * @param context The <code>FacesContext</code> for this request
   92        */
   93       public void initialize(FacesContext context) {
   94   
   95           this.context = context;
   96   
   97       }
   98   
   99   
  100       /**
  101        * <p>Release references to allocated resources acquired in
  102        * <code>initialize()</code> of via subsequent processing.  After this
  103        * method is called, subsequent calls to any other method than
  104        * <code>initialize()</code> will return undefined results.</p>
  105        */
  106       public void release() {
  107   
  108           context = null;
  109   
  110       }
  111   
  112   
  113   
  114       // ------------------------------------------------------ WebContext Methods
  115   
  116   
  117       /**
  118        * See the {@link WebContext}'s Javadoc.
  119        *
  120        * @return Application scope Map.
  121        */
  122       public Map getApplicationScope() {
  123   
  124       return (context.getExternalContext().getApplicationMap());
  125   
  126       }
  127   
  128   
  129       /**
  130        * See the {@link WebContext}'s Javadoc.
  131        *
  132        * @return Header values Map.
  133        */
  134       public Map getHeader() {
  135   
  136       return (context.getExternalContext().getRequestHeaderMap());
  137   
  138       }
  139   
  140   
  141       /**
  142        * See the {@link WebContext}'s Javadoc.
  143        *
  144        * @return Header values Map.
  145        */
  146       public Map getHeaderValues() {
  147   
  148       return (context.getExternalContext().getRequestHeaderValuesMap());
  149   
  150       }
  151   
  152   
  153       /**
  154        * See the {@link WebContext}'s Javadoc.
  155        *
  156        * @return Initialization parameter Map.
  157        */
  158       public Map getInitParam() {
  159   
  160       return (context.getExternalContext().getInitParameterMap());
  161   
  162       }
  163   
  164   
  165       /**
  166        * See the {@link WebContext}'s Javadoc.
  167        *
  168        * @return Request parameter Map.
  169        */
  170       public Map getParam() {
  171   
  172       return (context.getExternalContext().getRequestParameterMap());
  173   
  174       }
  175   
  176   
  177       /**
  178        * See the {@link WebContext}'s Javadoc.
  179        *
  180        * @return Request parameter Map.
  181        */
  182       public Map getParamValues() {
  183   
  184       return (context.getExternalContext().getRequestParameterValuesMap());
  185   
  186       }
  187   
  188   
  189       /**
  190        * See the {@link WebContext}'s Javadoc.
  191        *
  192        * @return Map of Cookies.
  193        * @since Chain 1.1
  194        */
  195       public Map getCookies() {
  196   
  197           return (context.getExternalContext().getRequestCookieMap());
  198   
  199       }
  200   
  201   
  202       /**
  203        * See the {@link WebContext}'s Javadoc.
  204        *
  205        * @return Request scope Map.
  206        */
  207       public Map getRequestScope() {
  208   
  209       return (context.getExternalContext().getRequestMap());
  210   
  211       }
  212   
  213   
  214       /**
  215        * See the {@link WebContext}'s Javadoc.
  216        *
  217        * @return Session scope Map.
  218        */
  219       public Map getSessionScope() {
  220   
  221       return (context.getExternalContext().getSessionMap());
  222   
  223       }
  224   
  225   
  226   
  227   }

Home » commons-chain-1.2-src » org.apache.commons » chain » web » faces » [javadoc | source]