shale-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ra...@apache.org
Subject svn commit: r481373 - in /shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml: DialogProperties.java SCXMLDialogContext.java action/ViewAction.java config/ConfigurationParser.java
Date Fri, 01 Dec 2006 20:18:28 GMT
Author: rahul
Date: Fri Dec  1 12:18:28 2006
New Revision: 481373

URL: http://svn.apache.org/viewvc?view=rev&rev=481373
Log:
Introduce the second custom Commons SCXML action available to Shale dialogs out-of-the-box.
The action with local name "view" (and namespace whose URI is defined in Globals.CUSTOM_SCXML_ACTIONS_URI)
may be used to associate the next view state with the identifier of the JSF view to be rendered
while the dialog is in that state.

This provides a declarative alternative to specify a view ID in addition to the procedural
alternative (DialogStateMapper). In presence of both means, the declarative specification
gets priority as one would expect (and allows for special casing, conditionals etc.). This
should cover most application requirements for mapping the SCXML states to views.

SHALE-347

Added:
    shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/action/ViewAction.java
  (with props)
Modified:
    shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/DialogProperties.java
    shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/SCXMLDialogContext.java
    shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/config/ConfigurationParser.java

Modified: shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/DialogProperties.java
URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/DialogProperties.java?view=diff&rev=481373&r1=481372&r2=481373
==============================================================================
--- shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/DialogProperties.java
(original)
+++ shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/DialogProperties.java
Fri Dec  1 12:18:28 2006
@@ -68,6 +68,35 @@
     }
 
 
+    //------------------------------------------------------ View Identifiers
+
+    /**
+     * The JSF view identifier of the next view to be rendered in
+     * this dialog.
+     */
+    private String nextViewId = null;
+
+    /**
+     * Get the JSF view identifier of the next view to be rendered in
+     * this dialog.
+     *
+     * @return The JSF view identifier
+     */
+    public String getNextViewId() {
+        return nextViewId;
+    }
+
+    /**
+     * Set the JSF view identifier of the next view to be rendered in
+     * this dialog.
+     *
+     * @param viewId The JSF view identifier
+     */
+    public void setNextViewId(String nextViewId) {
+        this.nextViewId = nextViewId;
+    }
+
+
     //---------------------------------------------- Other instance variables
 
     /**

Modified: shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/SCXMLDialogContext.java
URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/SCXMLDialogContext.java?view=diff&rev=481373&r1=481372&r2=481373
==============================================================================
--- shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/SCXMLDialogContext.java
(original)
+++ shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/SCXMLDialogContext.java
Fri Dec  1 12:18:28 2006
@@ -345,10 +345,17 @@
      * @param dp The <code>DialogProperties</code> for the current dialog
      */
     private void navigateTo(String stateId, FacesContext context, DialogProperties dp) {
-        ValueBinding vb = context.getApplication().createValueBinding
-            ("#{" + Globals.STATE_MAPPER + "}");
-        DialogStateMapper dsm = (DialogStateMapper) vb.getValue(context);
-        String viewId = dsm.mapStateId(name, stateId, context);
+        // Determine the view identifier
+        String viewId = dp.getNextViewId();
+        if (viewId == null) {
+            ValueBinding vb = context.getApplication().createValueBinding
+                ("#{" + Globals.STATE_MAPPER + "}");
+            DialogStateMapper dsm = (DialogStateMapper) vb.getValue(context);
+            viewId = dsm.mapStateId(name, stateId, context);
+        } else {
+            dp.setNextViewId(null); // one time use
+        }
+
         // Navigate to the requested view identifier (if any)
         if (viewId == null) {
             return;

Added: shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/action/ViewAction.java
URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/action/ViewAction.java?view=auto&rev=481373
==============================================================================
--- shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/action/ViewAction.java
(added)
+++ shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/action/ViewAction.java
Fri Dec  1 12:18:28 2006
@@ -0,0 +1,88 @@
+/*
+ * 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.scxml.action;
+
+import java.util.Collection;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.scxml.ErrorReporter;
+import org.apache.commons.scxml.EventDispatcher;
+import org.apache.commons.scxml.SCInstance;
+import org.apache.commons.scxml.SCXMLExpressionException;
+import org.apache.commons.scxml.model.Action;
+import org.apache.commons.scxml.model.ModelException;
+import org.apache.shale.dialog.scxml.DialogProperties;
+import org.apache.shale.dialog.scxml.Globals;
+
+/**
+ * <p>Custom Commons SCXML action to set the JSF view identifier of the
+ * next view to be rendered by this dialog.</p>
+ *
+ * @since 1.0.4
+ *
+ * $Id$
+ */
+public class ViewAction extends Action {
+
+    /**
+     * <p>Set nextViewId in dialog properties, which will be the next view
+     * rendered by this dialog.</p>
+     *
+     * @param evtDispatcher The EventDispatcher for this execution instance
+     * @param errRep        The ErrorReporter
+     * @param scInstance    The state machine execution instance information
+     * @param appLog        The application log
+     * @param derivedEvents The collection of internal events
+     * @throws ModelException If execution causes a non-deterministic state
+     * @throws SCXMLExpressionException Bad expression
+     */
+    public void execute(EventDispatcher evtDispatcher, ErrorReporter errRep,
+            SCInstance scInstance, Log appLog, Collection derivedEvents)
+    throws ModelException, SCXMLExpressionException {
+
+        DialogProperties dp = (DialogProperties) scInstance.getRootContext().
+            get(Globals.DIALOG_PROPERTIES);
+        dp.setNextViewId(viewId);
+
+    }
+
+    /**
+     * The JSF view identifier for the next view to be rendered by
+     * this dialog.
+     */
+    private String viewId = null;
+
+    /**
+     * Get the view identifier.
+     *
+     * @return The view identifier
+     */
+    public String getViewId() {
+        return viewId;
+    }
+
+    /**
+     * Set the view identifier.
+     *
+     * @param viewId The view identifier
+     */
+    public void setViewId(String viewId) {
+        this.viewId = viewId;
+    }
+
+}

Propchange: shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/action/ViewAction.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Modified: shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/config/ConfigurationParser.java
URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/config/ConfigurationParser.java?view=diff&rev=481373&r1=481372&r2=481373
==============================================================================
--- shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/config/ConfigurationParser.java
(original)
+++ shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/config/ConfigurationParser.java
Fri Dec  1 12:18:28 2006
@@ -34,6 +34,7 @@
 import org.apache.commons.scxml.model.SCXML;
 import org.apache.shale.dialog.scxml.Globals;
 import org.apache.shale.dialog.scxml.action.RedirectAction;
+import org.apache.shale.dialog.scxml.action.ViewAction;
 import org.xml.sax.Attributes;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
@@ -234,14 +235,21 @@
 
         Iterator iterator = metadata.entrySet().iterator();
 
-        // Define the custom Commons SCXML actions used by Shale dialogs
+        // Define the custom Commons SCXML actions used by Shale dialogs and
+        // create a list of custom actions as needed by the SCXMLDigester API
+        List customDialogActions = new ArrayList();
+
+        // <shale:redirect>
         CustomAction redirectAction =
             new CustomAction(Globals.CUSTOM_SCXML_ACTIONS_URI,
                 "redirect", RedirectAction.class);
-
-        // Create a list of custom actions as needed by the SCXMLDigester API
-        List customDialogActions = new ArrayList();
         customDialogActions.add(redirectAction);
+
+        // <shale:view>
+        CustomAction viewAction =
+            new CustomAction(Globals.CUSTOM_SCXML_ACTIONS_URI,
+                "view", ViewAction.class);
+        customDialogActions.add(viewAction);
 
         while (iterator.hasNext()) {
 



Mime
View raw message