You are viewing a plain text version of this content. The canonical link for it is here.
Posted to adffaces-commits@incubator.apache.org by aw...@apache.org on 2006/11/13 17:44:01 UTC

svn commit: r474412 - in /incubator/adffaces/trunk/trinidad: trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/DialogService.java trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/NavigationHandlerImpl.java

Author: awiner
Date: Mon Nov 13 09:44:00 2006
New Revision: 474412

URL: http://svn.apache.org/viewvc?view=rev&rev=474412
Log:
Add DialogService.getDialogNavigationPrefix() method, so there's a public API to figure out what outcomes are dialog framework related

Modified:
    incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/DialogService.java
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/NavigationHandlerImpl.java

Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/DialogService.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/DialogService.java?view=diff&rev=474412&r1=474411&r2=474412
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/DialogService.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/context/DialogService.java Mon Nov 13 09:44:00 2006
@@ -22,6 +22,7 @@
 import org.apache.myfaces.trinidad.event.ReturnEvent;
 
 
+
 /**
  * The DialogService API defines a number of
  * APIs that are needed to implement Apache Trinidad dialogs,
@@ -32,6 +33,13 @@
 abstract public class DialogService
 {
   /**
+   * Configuration parameter for setting the prefix used in
+   * dialog navigation.
+   */
+  public static final String DIALOG_NAVIGATION_PREFIX_PARAM_NAME =
+    "org.apache.myfaces.trinidad.DIALOG_NAVIGATION_PREFIX";
+
+  /**
    * Create an DialogService.
    */
   protected DialogService()
@@ -167,5 +175,29 @@
     Object returnValue,
     Map<Object, Object> returnParams);
 
+  /**
+   * Returns the prefix that, when used for navigational outcomes,
+   * will trigger the dialog framework.
+   */
+  public String getDialogNavigationPrefix()
+  {
+    if (_dialogPrefix == null)
+    {
+      FacesContext context = FacesContext.getCurrentInstance();
+      _dialogPrefix = context.getExternalContext().getInitParameter(
+                                DIALOG_NAVIGATION_PREFIX_PARAM_NAME);
+      
+      if(_dialogPrefix == null)
+      {
+        _dialogPrefix = _DEFAULT_DIALOG_NAVIGATION_PREFIX;
+      }
+    }
+
+    return _dialogPrefix;
+  }
+
   private UIComponent _currentLaunchSource;
+  private static String _dialogPrefix;
+
+  private static final String _DEFAULT_DIALOG_NAVIGATION_PREFIX = "dialog:";
 }

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/NavigationHandlerImpl.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/NavigationHandlerImpl.java?view=diff&rev=474412&r1=474411&r2=474412
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/NavigationHandlerImpl.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/NavigationHandlerImpl.java Mon Nov 13 09:44:00 2006
@@ -26,7 +26,6 @@
   public NavigationHandlerImpl(NavigationHandler delegate)
   {
     _delegate = delegate;
-    _dialogPrefix = null;
   }
 
   @Override
@@ -42,14 +41,14 @@
     UIViewRoot newRoot = context.getViewRoot();
     if ((outcome != null) && (newRoot != oldRoot))
     {
+      RequestContext afc = RequestContext.getCurrentInstance();
+
       // Handle "dialog:" URLs
-      if (outcome.startsWith(_getDialogPrefix(context)))
+      if (outcome.startsWith(afc.getDialogNavigationPrefix()))
       {
         // Navigate back to the original root
         context.setViewRoot(oldRoot);
 
-        RequestContext afc = RequestContext.getCurrentInstance();
-
         // Give ourselves a new page flow scope
         afc.getPageFlowScopeProvider().pushPageFlowScope(context, true);
         // And ask the component to launch a dialog
@@ -58,21 +57,6 @@
     }
   }
   
-  private String _getDialogPrefix(FacesContext context) {
-    if (_dialogPrefix == null) {
-        _dialogPrefix = context.getExternalContext().getInitParameter(DIALOG_NAVIGATION_PREFIX_PARAM_NAME);
-        
-        if(_dialogPrefix == null) {
-        	_dialogPrefix = DEFAULT_DIALOG_NAVIGATION_PREFIX;
-        }
-    }
-
-    return _dialogPrefix;
-  }
-
-  public static final String DEFAULT_DIALOG_NAVIGATION_PREFIX = "dialog:";
-  public static final String DIALOG_NAVIGATION_PREFIX_PARAM_NAME = "org.apache.myfaces.trinidad.DIALOG_NAVIGATION_PREFIX";
   
   private NavigationHandler _delegate;
-  private static String _dialogPrefix;
 }