rleland 2004/03/11 22:03:56
Modified: src/share/org/apache/struts/util RequestUtils.java
Log:
Provide a forwardURL that is compatable with Struts 1.1
Revision Changes Path
1.147 +55 -9
jakarta-struts/src/share/org/apache/struts/util/RequestUtils.java
Index: RequestUtils.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/util/RequestUtils.java,v
retrieving revision 1.146
retrieving revision 1.147
diff -u -r1.146 -r1.147
--- RequestUtils.java 13 Feb 2004 11:07:54 -0000 1.146
+++ RequestUtils.java 12 Mar 2004 06:03:56 -0000 1.147
@@ -753,7 +753,52 @@
return sb.toString();
}
-
+ /**
+ * <p>Return the context-relative URL that corresponds to the specified
+ * <code>ForwardConfig</code>. The URL is calculated based on the properties
+ * of the [EMAIL PROTECTED] ForwardConfig} instance as follows:</p>
+ * <ul>
+ * <li>If the <code>contextRelative</code> property is set, it is
+ * assumed that the <code>path</code> property contains a path
+ * that is already context-relative:
+ * <ul>
+ * <li>If the <code>path</code> property value starts with a slash,
+ * it is returned unmodified.</li>
+ * <li>If the <code>path</code> property value does not start
+ * with a slash, a slash is prepended.</li>
+ * </ul></li>
+ * <li>Acquire the <code>forwardPattern</code> property from the
+ * <code>ControllerConfig</code> for the application module used
+ * to process this request. If no pattern was configured, default
+ * to a pattern of <code>$M$P</code>, which is compatible with the
+ * hard-coded mapping behavior in Struts 1.0.</li>
+ * <li>Process the acquired <code>forwardPattern</code>, performing the
+ * following substitutions:
+ * <ul>
+ * <li><strong>$M</strong> - Replaced by the module prefix for the
+ * application module processing this request.</li>
+ * <li><strong>$P</strong> - Replaced by the <code>path</code>
+ * property of the specified [EMAIL PROTECTED] ForwardConfig}, prepended
+ * with a slash if it does not start with one.</li>
+ * <li><strong>$$</strong> - Replaced by a single dollar sign
+ * character.</li>
+ * <li><strong>$x</strong> (where "x" is any charater not listed
+ * above) - Silently omit these two characters from the result
+ * value. (This has the side effect of causing all other
+ * $+letter combinations to be reserved.)</li>
+ * </ul></li>
+ * </ul>
+ *
+ * @param request The servlet request we are processing
+ * @param forward ForwardConfig to be evaluated
+ *
+ * @return context-relative URL
+ * @since Struts 1.1
+ */
+ public static String forwardURL(HttpServletRequest request, ForwardConfig
forward) {
+ return forwardURL(request,forward,null);
+ }
+
/**
* <p>Return the context-relative URL that corresponds to the specified
* <code>ForwardConfig</code>. The URL is calculated based on the properties
@@ -792,9 +837,10 @@
*
* @param request The servlet request we are processing
* @param forward ForwardConfig to be evaluated
+ * @param moduleConfig Base forward on this module config.
*
* @return context-relative URL
- * @since Struts 1.1
+ * @since Struts 1.2
*/
public static String forwardURL(HttpServletRequest request, ForwardConfig
forward, ModuleConfig moduleConfig) {
//load the current moduleConfig, if null
@@ -1251,7 +1297,7 @@
* @exception MalformedURLException if a URL cannot be created
* for the specified parameters
* @deprecated This will be removed after Struts 1.2.
- * Use [EMAIL PROTECTED]
org.apache.struts.taglib.TagUtils#computeURL(PageContext,String,String,String,String,Map,String,boolean)}
instead.
+ * Use [EMAIL PROTECTED]
org.apache.struts.taglib.TagUtils#computeURL(PageContext,String,String,String,String,String,Map,String,
boolean)} instead.
*/
public static String computeURL(
PageContext pageContext,
@@ -1305,7 +1351,7 @@
* @exception MalformedURLException if a URL cannot be created
* for the specified parameters
* @deprecated This will be removed after Struts 1.2.
- * Use [EMAIL PROTECTED]
org.apache.struts.taglib.TagUtils#computeURL(PageContext,String,String,String,String,Map,String,boolean,boolean)}
instead.
+ * Use [EMAIL PROTECTED]
org.apache.struts.taglib.TagUtils#computeURL(PageContext,String,String,String,String,String,Map,String,boolean,boolean)}
instead.
*/
public static String computeURL(
PageContext pageContext,
@@ -1576,7 +1622,7 @@
* @return context-relative URL
* @since Struts 1.1
- * @deprecated Use [EMAIL PROTECTED]
org.apache.struts.taglib.TagUtils#pageURL(HttpServletRequest,String)} instead.
+ * @deprecated Use [EMAIL PROTECTED]
org.apache.struts.taglib.TagUtils#pageURL(HttpServletRequest request, String page,
ModuleConfig moduleConfig)} instead.
* This will be removed after Struts 1.2.
*/
public static String pageURL(HttpServletRequest request, String page) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]