You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shale.apache.org by cr...@apache.org on 2007/01/09 22:15:50 UTC

svn commit: r494583 - /shale/framework/trunk/shale-dialog/src/main/java/org/apache/shale/dialog/faces/DialogVariableResolver.java

Author: craigmcc
Date: Tue Jan  9 13:15:49 2007
New Revision: 494583

URL: http://svn.apache.org/viewvc?view=rev&rev=494583
Log:
[SHALE-389] D'oh ... forgot to commit the new DialogVariableResolver class.

Added:
    shale/framework/trunk/shale-dialog/src/main/java/org/apache/shale/dialog/faces/DialogVariableResolver.java   (with props)

Added: shale/framework/trunk/shale-dialog/src/main/java/org/apache/shale/dialog/faces/DialogVariableResolver.java
URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-dialog/src/main/java/org/apache/shale/dialog/faces/DialogVariableResolver.java?view=auto&rev=494583
==============================================================================
--- shale/framework/trunk/shale-dialog/src/main/java/org/apache/shale/dialog/faces/DialogVariableResolver.java (added)
+++ shale/framework/trunk/shale-dialog/src/main/java/org/apache/shale/dialog/faces/DialogVariableResolver.java Tue Jan  9 13:15:49 2007
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shale.dialog.faces;
+
+import java.util.Map;
+import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
+import javax.faces.el.VariableResolver;
+import org.apache.shale.dialog.Constants;
+import org.apache.shale.dialog.DialogContext;
+
+/**
+ * <p>Variable resolver that provides access to the instance data for a
+ * particular {@link DialogContext} instance with a single symbol.</p>
+ *
+ * @since 1.1
+ */
+public final class DialogVariableResolver extends VariableResolver {
+
+
+    // ------------------------------------------------------------ Constructors
+
+
+    /**
+     * <p>Wrap the specified <code>VariableResolver</code> instance.</p>
+     *
+     * @param original Original instance to be wrapped
+     */
+    public DialogVariableResolver(VariableResolver original) {
+        this.original = original;
+    }
+
+
+    // ------------------------------------------------------ Instance Variables
+
+
+    /**
+     * <p>The <code>VariableResolver</code> to which we should delegate for
+     * variable names other than the one of interest.</p>
+     */
+    private VariableResolver original = null;
+
+
+    // ---------------------------------------------------------- Public Methods
+
+
+    /**
+     * <p>Resolve a reference to our dialog instance data (if requested), or
+     * delegate to the original <code>VariableResolver</code>.</p>
+     *
+     * @param context <code>FacesContext</code> for the current request
+     * @param name Name of the variable to resolve
+     */
+    public Object resolveVariable(FacesContext context, String name)
+      throws EvaluationException {
+
+        // Delegate unless we are after a variable name of interest
+        if (!Constants.DIALOG_SCOPE.equals(name)) {
+            return original.resolveVariable(context, name);
+        }
+
+        // Look up and return our instance data object (if any)
+        Map map = context.getExternalContext().getRequestMap();
+        DialogContext dc = (DialogContext) map.get(Constants.CONTEXT_BEAN);
+        if (dc != null) {
+            return dc.getData();
+        } else {
+            return null;
+        }
+
+
+    }
+
+
+}

Propchange: shale/framework/trunk/shale-dialog/src/main/java/org/apache/shale/dialog/faces/DialogVariableResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: shale/framework/trunk/shale-dialog/src/main/java/org/apache/shale/dialog/faces/DialogVariableResolver.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL