[seam-commits] Seam SVN: r7422 - in trunk/src/main/org/jboss/seam: navigation and 1 other directory.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Thu Feb 14 15:35:48 EST 2008


Author: norman.richards at jboss.com
Date: 2008-02-14 15:35:48 -0500 (Thu, 14 Feb 2008)
New Revision: 7422

Modified:
   trunk/src/main/org/jboss/seam/faces/FacesManager.java
   trunk/src/main/org/jboss/seam/faces/Navigator.java
   trunk/src/main/org/jboss/seam/navigation/Pages.java
   trunk/src/main/org/jboss/seam/navigation/RedirectNavigationHandler.java
Log:
JBSEAM-2386

Modified: trunk/src/main/org/jboss/seam/faces/FacesManager.java
===================================================================
--- trunk/src/main/org/jboss/seam/faces/FacesManager.java	2008-02-14 07:57:43 UTC (rev 7421)
+++ trunk/src/main/org/jboss/seam/faces/FacesManager.java	2008-02-14 20:35:48 UTC (rev 7422)
@@ -135,6 +135,14 @@
       }
    }
 
+   public void redirectToExternalURL(String url) {
+       try {
+           FacesContext.getCurrentInstance().getExternalContext().redirect(url);
+       } catch (IOException e) {
+          throw new RedirectException(e);
+       }
+   }
+   
    /**
     * Redirect to the given view id, after encoding parameters and conversation  
     * id into the request URL.
@@ -185,7 +193,7 @@
       url = encodeConversationId(url, viewId, conversationId);
       redirect(viewId, context, url);
    }
-
+   
    private void redirect(String viewId, FacesContext context, String url)
    {
       url = Pages.instance().encodeScheme(viewId, context, url);

Modified: trunk/src/main/org/jboss/seam/faces/Navigator.java
===================================================================
--- trunk/src/main/org/jboss/seam/faces/Navigator.java	2008-02-14 07:57:43 UTC (rev 7421)
+++ trunk/src/main/org/jboss/seam/faces/Navigator.java	2008-02-14 20:35:48 UTC (rev 7422)
@@ -1,5 +1,6 @@
 package org.jboss.seam.faces;
 
+import java.io.IOException;
 import java.util.Map;
 
 import javax.faces.application.FacesMessage.Severity;
@@ -33,6 +34,10 @@
       }
    }
 
+   protected void redirectExternal(String url) {
+       FacesManager.instance().redirectToExternalURL(url);
+   }
+   
    /**
     * Redirect to the view id.
     */

Modified: trunk/src/main/org/jboss/seam/navigation/Pages.java
===================================================================
--- trunk/src/main/org/jboss/seam/navigation/Pages.java	2008-02-14 07:57:43 UTC (rev 7421)
+++ trunk/src/main/org/jboss/seam/navigation/Pages.java	2008-02-14 20:35:48 UTC (rev 7422)
@@ -1365,8 +1365,7 @@
          Severity severity = severityName==null ? 
                   FacesMessage.SEVERITY_INFO : 
                   getFacesMessageValuesMap().get( severityName.toUpperCase() );
-         rule.addNavigationHandler( new RenderNavigationHandler(viewId == null ? null : 
-            Expressions.instance().createValueExpression(viewId, String.class), message, severity, control) );
+         rule.addNavigationHandler( new RenderNavigationHandler(stringValueExpressionFor(viewId), message, severity, control) );
       }
       
       Element redirect = element.element("redirect");
@@ -1379,6 +1378,8 @@
             params.add( parseParam(child) );
          }
          final String viewId = redirect.attributeValue("view-id");
+         final String url    = redirect.attributeValue("url");
+
          Element messageElement = redirect.element("message");
          String control = messageElement==null ? null : messageElement.attributeValue("for");
          String message = messageElement==null ? null : messageElement.getTextTrim();
@@ -1386,8 +1387,9 @@
          Severity severity = severityName==null ? 
                   FacesMessage.SEVERITY_INFO : 
                   getFacesMessageValuesMap().get( severityName.toUpperCase() );
-         rule.addNavigationHandler( new RedirectNavigationHandler(viewId == null ? null : 
-            Expressions.instance().createValueExpression(viewId, String.class), params, message, severity, control) );
+         rule.addNavigationHandler(new RedirectNavigationHandler(stringValueExpressionFor(viewId), 
+                                                                 stringValueExpressionFor(url),
+                                                                 params, message, severity, control) );
       }
       
       List<Element> childElements = element.elements("out");
@@ -1410,6 +1412,10 @@
       
    }
    
+   private static ValueExpression<String> stringValueExpressionFor(String expr) {
+       return (ValueExpression<String>) ((expr == null) ? expr : Expressions.instance().createValueExpression(expr, String.class));
+   }
+   
    public static Map<String, Severity> getFacesMessageValuesMap()
    {
       Map<String, Severity> result = new HashMap<String, Severity>();

Modified: trunk/src/main/org/jboss/seam/navigation/RedirectNavigationHandler.java
===================================================================
--- trunk/src/main/org/jboss/seam/navigation/RedirectNavigationHandler.java	2008-02-14 07:57:43 UTC (rev 7421)
+++ trunk/src/main/org/jboss/seam/navigation/RedirectNavigationHandler.java	2008-02-14 20:35:48 UTC (rev 7422)
@@ -1,5 +1,6 @@
 package org.jboss.seam.navigation;
 
+import java.io.IOException;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -18,14 +19,17 @@
 public final class RedirectNavigationHandler extends NavigationHandler
 {
    private final ValueExpression<String> viewId;
+   private final ValueExpression<String> url;
    private final List<Param> params;
    private final String message;
    private final Severity severity;
    private final String control;
 
-   public RedirectNavigationHandler(ValueExpression<String> viewId, List<Param> params, String message, Severity severity, String control)
+   public RedirectNavigationHandler(ValueExpression<String> viewId, ValueExpression<String> url,
+                                    List<Param> params, String message, Severity severity, String control)
    {
       this.viewId = viewId;
+      this.url    = url;
       this.params = params;
       this.message = message;
       this.severity = severity;
@@ -50,7 +54,12 @@
          //}
       }
       
-      redirect(viewId == null ? null : viewId.getValue(), parameters);
+      if (url != null) {
+          redirectExternal(url.getValue());
+      } else {
+          redirect(viewId == null ? null : viewId.getValue(), parameters);
+      }
+
       return true;
    }
 




More information about the seam-commits mailing list