You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by cr...@apache.org on 2006/05/08 11:36:22 UTC

svn commit: r404985 - in /struts/shale/trunk/core-library/src/java/org/apache/shale/dialog: Globals.java faces/DialogNavigationHandler.java

Author: craigmcc
Date: Mon May  8 02:36:19 2006
New Revision: 404985

URL: http://svn.apache.org/viewcvs?rev=404985&view=rev
Log:
Make the logical outcome prefix for selecting a dialog (default="dialog:")
configurable via a context init parameter.

PR:  SHALE-173
Submitted By:  Craig McClanahan <craigmcc AT apache.org>

Modified:
    struts/shale/trunk/core-library/src/java/org/apache/shale/dialog/Globals.java
    struts/shale/trunk/core-library/src/java/org/apache/shale/dialog/faces/DialogNavigationHandler.java

Modified: struts/shale/trunk/core-library/src/java/org/apache/shale/dialog/Globals.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/java/org/apache/shale/dialog/Globals.java?rev=404985&r1=404984&r2=404985&view=diff
==============================================================================
--- struts/shale/trunk/core-library/src/java/org/apache/shale/dialog/Globals.java (original)
+++ struts/shale/trunk/core-library/src/java/org/apache/shale/dialog/Globals.java Mon May  8 02:36:19 2006
@@ -43,6 +43,15 @@
 
 
     /**
+     * <p>Context initialization parameter used to specify the prefix
+     * on a navigation logical outcome, used to identify this as a
+     * request to initiate a dialog.  If not present, the default prefix
+     * value is "dialog:".</p>
+     */
+    public static final String PREFIX = "org.apache.shale.dialog.PREFIX";
+
+
+    /**
      * <p>Default name of the session scope attribute under which a
      * {@link Status} instance for the current user is stored.</p>
      */

Modified: struts/shale/trunk/core-library/src/java/org/apache/shale/dialog/faces/DialogNavigationHandler.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/java/org/apache/shale/dialog/faces/DialogNavigationHandler.java?rev=404985&r1=404984&r2=404985&view=diff
==============================================================================
--- struts/shale/trunk/core-library/src/java/org/apache/shale/dialog/faces/DialogNavigationHandler.java (original)
+++ struts/shale/trunk/core-library/src/java/org/apache/shale/dialog/faces/DialogNavigationHandler.java Mon May  8 02:36:19 2006
@@ -114,8 +114,10 @@
 
 
     /**
-     * <p>The prefix on a logical outcome String that indicates the remainder
-     * of the string is the name of a {@link Dialog} to be entered.</p>
+     * <p>The default prefix on a logical outcome String that indicates the remainder
+     * of the string is the name of a {@link Dialog} to be entered.  The actual value
+     * used can be set by defining a context initialization parameter for key
+     * {@link Globals.PREFIX}.</p>
      */
     public static final String PREFIX = "dialog:";
 
@@ -186,9 +188,10 @@
         // If we are not executing a dialog, delegate to the standard handler
         // unless the outcome starts with our prefix to start a dialog
         Status status = getStatus(context, false);
+        String prefix = prefix(context);
         if (status == null) {
-            if ((outcome != null) && outcome.startsWith(PREFIX)) {
-                start(context, outcome.substring(PREFIX.length()));
+            if ((outcome != null) && outcome.startsWith(prefix)) {
+                start(context, outcome.substring(prefix.length()));
             } else {
                 handler.handleNavigation(context, fromAction, outcome);
             }
@@ -196,8 +199,8 @@
         }
         Status.Position position = status.peek();
         if (position == null) {
-            if ((outcome != null) && outcome.startsWith(PREFIX)) {
-                start(context, outcome.substring(PREFIX.length()));
+            if ((outcome != null) && outcome.startsWith(prefix)) {
+                start(context, outcome.substring(prefix.length()));
             } else {
                 handler.handleNavigation(context, fromAction, outcome);
             }
@@ -357,6 +360,23 @@
                                                new Object[] { state.getName(),
                                                               state.getClass().getName() }));
         }
+
+    }
+
+
+    /**
+     * <p>Return the prefix value to use for determining whether the specified
+     * logical outcome represents a request to initiate a named dialog.</p>
+     *
+     * @param context <code>FacesContext</code> for the current request
+     */
+    private String prefix(FacesContext context) {
+
+        String prefix = context.getExternalContext().getInitParameter(Globals.PREFIX);
+        if (prefix == null) {
+            prefix = this.PREFIX;
+        }
+        return prefix;
 
     }