[jboss-cvs] jboss-seam/src/main/org/jboss/seam/core ...
Gavin King
gavin.king at jboss.com
Thu Feb 22 11:03:05 EST 2007
User: gavin
Date: 07/02/22 11:03:05
Modified: src/main/org/jboss/seam/core Manager.java Pages.java
Log:
make s:button and s:link use the scheme
Revision Changes Path
1.148 +2 -40 jboss-seam/src/main/org/jboss/seam/core/Manager.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Manager.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Manager.java,v
retrieving revision 1.147
retrieving revision 1.148
diff -u -b -r1.147 -r1.148
--- Manager.java 22 Feb 2007 15:52:07 -0000 1.147
+++ Manager.java 22 Feb 2007 16:03:05 -0000 1.148
@@ -11,8 +11,6 @@
import java.io.IOException;
import java.io.UnsupportedEncodingException;
-import java.net.MalformedURLException;
-import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
@@ -24,7 +22,6 @@
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.event.PhaseId;
-import javax.servlet.http.HttpServletRequest;
import org.jboss.seam.Component;
import org.jboss.seam.ScopeType;
@@ -45,7 +42,7 @@
*
* @author Gavin King
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision: 1.147 $
+ * @version $Revision: 1.148 $
*/
@Scope(ScopeType.EVENT)
@Name("org.jboss.seam.core.manager")
@@ -968,7 +965,7 @@
url = encodeConversationId(url);
beforeRedirect();
}
- url = encodeScheme(viewId, context, url);
+ url = Pages.instance().encodeScheme(viewId, context, url);
if ( log.isDebugEnabled() )
{
log.debug("redirecting to: " + url);
@@ -990,41 +987,6 @@
context.responseComplete(); //work around MyFaces bug in 1.1.1
}
- private String encodeScheme(String viewId, FacesContext context, String url)
- {
- String scheme = Pages.instance().getScheme(viewId);
- if (scheme != null)
- {
- URL u = getRequestURL(context);
- try
- {
- url = new URL(scheme, u.getHost(), u.getPort(), url).toString();
- }
- catch (MalformedURLException ex)
- {
- throw new RuntimeException(ex);
- }
- }
- return url;
- }
-
- private URL getRequestURL(FacesContext facesContext)
- {
- Object req = facesContext.getExternalContext().getRequest();
-
- if (!(req instanceof HttpServletRequest)) return null;
-
- try
- {
- URL url = new URL(((HttpServletRequest) req).getRequestURL().toString());
- return url;
- }
- catch (MalformedURLException ex)
- {
- throw new RuntimeException(ex);
- }
- }
-
/**
* Called by the Seam Redirect Filter when a redirect is called.
* Appends the conversationId parameter if necessary.
1.95 +43 -3 jboss-seam/src/main/org/jboss/seam/core/Pages.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Pages.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Pages.java,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -b -r1.94 -r1.95
--- Pages.java 22 Feb 2007 15:52:07 -0000 1.94
+++ Pages.java 22 Feb 2007 16:03:05 -0000 1.95
@@ -270,7 +270,31 @@
return result;
}
- private String getRequestScheme(FacesContext facesContext)
+ private static String getRequestScheme(FacesContext facesContext)
+ {
+ URL url = getRequestUrl(facesContext);
+ return url==null ? null : url.getProtocol();
+ }
+
+ public String encodeScheme(String viewId, FacesContext context, String url)
+ {
+ String scheme = getScheme(viewId);
+ if (scheme != null)
+ {
+ URL u = getRequestUrl(context);
+ try
+ {
+ url = new URL(scheme, u.getHost(), u.getPort(), url).toString();
+ }
+ catch (MalformedURLException ex)
+ {
+ throw new RuntimeException(ex);
+ }
+ }
+ return url;
+ }
+
+ private static URL getRequestUrl(FacesContext facesContext)
{
Object req = facesContext.getExternalContext().getRequest();
@@ -278,8 +302,7 @@
try
{
- URL url = new URL(((HttpServletRequest) req).getRequestURL().toString());
- return url.getProtocol();
+ return new URL(((HttpServletRequest) req).getRequestURL().toString());
}
catch (MalformedURLException ex)
{
@@ -624,6 +647,7 @@
Map<String, Object> parameters = getConvertedParameters(facesContext, viewId);
return Manager.instance().encodeParameters(url, parameters);
}
+
/**
* Store the page parameters to the JSF view root
*/
@@ -635,6 +659,7 @@
Contexts.getPageContext().set( param.getKey(), param.getValue() );
}
}
+
/**
* Search for a defined no-conversation-view-id, beginning with
* the most specific view id, then wildcarded view ids, and
@@ -654,6 +679,7 @@
}
return this.noConversationViewId;
}
+
/**
* Search for a defined conversation timeout, beginning with
* the most specific view id, then wildcarded view ids, and
@@ -701,6 +727,7 @@
parse( page, page.attributeValue("view-id") );
}
}
+
/**
* Parse a viewId.page.xml file
*/
@@ -708,6 +735,7 @@
{
parse( getDocumentRoot(stream), viewId );
}
+
/**
* Get the root element of the document
*/
@@ -722,6 +750,7 @@
throw new RuntimeException(de);
}
}
+
/**
* Parse a page element and add a Page to the map
*/
@@ -818,6 +847,7 @@
return page;
}
+
private static Action parseAction(Element element, String actionAtt)
{
Action action = new Action();
@@ -839,6 +869,7 @@
}
return action;
}
+
/**
* Parse end-conversation (and end-task) and begin-conversation (start-task and begin-task)
*
@@ -1015,6 +1046,7 @@
}
}
}
+
/**
* Parse param
*/
@@ -1043,6 +1075,7 @@
}
return param;
}
+
/**
* Parse rule
*/
@@ -1064,8 +1097,10 @@
return rule;
}
+
private static void parseNavigationHandler(Element element, Rule rule)
{
+
Element render = element.element("render");
if (render!=null)
{
@@ -1078,6 +1113,7 @@
getFacesMessageValuesMap().get( severityName.toUpperCase() );
rule.setNavigationHandler( new RenderNavigationHandler(viewId, message, severity) );
}
+
Element redirect = element.element("redirect");
if (redirect!=null)
{
@@ -1096,6 +1132,7 @@
getFacesMessageValuesMap().get( severityName.toUpperCase() );
rule.setNavigationHandler( new RedirectNavigationHandler(viewId, params, message, severity) );
}
+
List<Element> childElements = element.elements("out");
for (Element child: childElements)
{
@@ -1115,6 +1152,7 @@
}
}
+
public static Map<String, Severity> getFacesMessageValuesMap()
{
Map<String, Severity> result = new HashMap<String, Severity>();
@@ -1124,6 +1162,7 @@
}
return result;
}
+
public String getLoginViewId()
{
return loginViewId;
@@ -1132,4 +1171,5 @@
{
this.loginViewId = loginViewId;
}
+
}
More information about the jboss-cvs-commits
mailing list