2009/05/20 - Apache Shale has been retired.

For more information, please explore the Attic.

Coverage Report - org.apache.shale.dialog.faces.DialogVariableResolver
 
Classes in this File Line Coverage Branch Coverage Complexity
DialogVariableResolver
0%
0/11
0%
0/2
3
 
 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  
 
 18  
 package org.apache.shale.dialog.faces;
 19  
 
 20  
 import java.util.Map;
 21  
 import javax.faces.context.FacesContext;
 22  
 import javax.faces.el.EvaluationException;
 23  
 import javax.faces.el.VariableResolver;
 24  
 import org.apache.shale.dialog.Constants;
 25  
 import org.apache.shale.dialog.DialogContext;
 26  
 
 27  
 /**
 28  
  * <p>Variable resolver that provides access to the instance data for a
 29  
  * particular {@link DialogContext} instance with a single symbol.</p>
 30  
  *
 31  
  * @since 1.1
 32  
  */
 33  
 public final class DialogVariableResolver extends VariableResolver {
 34  
 
 35  
 
 36  
     // ------------------------------------------------------------ Constructors
 37  
 
 38  
 
 39  
     /**
 40  
      * <p>Wrap the specified <code>VariableResolver</code> instance.</p>
 41  
      *
 42  
      * @param original Original instance to be wrapped
 43  
      */
 44  0
     public DialogVariableResolver(VariableResolver original) {
 45  0
         this.original = original;
 46  0
     }
 47  
 
 48  
 
 49  
     // ------------------------------------------------------ Instance Variables
 50  
 
 51  
 
 52  
     /**
 53  
      * <p>The <code>VariableResolver</code> to which we should delegate for
 54  
      * variable names other than the one of interest.</p>
 55  
      */
 56  0
     private VariableResolver original = null;
 57  
 
 58  
 
 59  
     // ---------------------------------------------------------- Public Methods
 60  
 
 61  
 
 62  
     /**
 63  
      * <p>Resolve a reference to our dialog instance data (if requested), or
 64  
      * delegate to the original <code>VariableResolver</code>.</p>
 65  
      *
 66  
      * @param context <code>FacesContext</code> for the current request
 67  
      * @param name Name of the variable to resolve
 68  
      */
 69  
     public Object resolveVariable(FacesContext context, String name)
 70  
       throws EvaluationException {
 71  
 
 72  
         // Delegate unless we are after a variable name of interest
 73  0
         if (!Constants.DIALOG_SCOPE.equals(name)) {
 74  0
             return original.resolveVariable(context, name);
 75  
         }
 76  
 
 77  
         // Look up and return our instance data object (if any)
 78  0
         Map map = context.getExternalContext().getRequestMap();
 79  0
         DialogContext dc = (DialogContext) map.get(Constants.CONTEXT_BEAN);
 80  0
         if (dc != null) {
 81  0
             return dc.getData();
 82  
         } else {
 83  0
             return null;
 84  
         }
 85  
 
 86  
 
 87  
     }
 88  
 
 89  
 
 90  
 }