cvs commit: jakarta-struts/src/share/org/apache/struts/util ModuleUtils.java RequestUtils.java
husted 2004/02/07 07:55:02 Modified:src/share/org/apache/struts/taglib TagUtils.java src/share/org/apache/struts/taglib/bean IncludeTag.java src/share/org/apache/struts/taglib/html ImgTag.java LinkTag.java RewriteTag.java src/share/org/apache/struts/taglib/logic RedirectTag.java src/share/org/apache/struts/util ModuleUtils.java RequestUtils.java Log: Apply #24235 html:link tag, plus module support submitted by Gary Ashley. Revision ChangesPath 1.31 +39 -12jakarta-struts/src/share/org/apache/struts/taglib/TagUtils.java Index: TagUtils.java === RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/TagUtils.java,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- TagUtils.java 19 Jan 2004 04:43:10 - 1.30 +++ TagUtils.java 7 Feb 2004 15:55:02 - 1.31 @@ -311,6 +311,7 @@ String href, String page, String action, + String module, Map params, String anchor, boolean redirect) @@ -321,6 +322,7 @@ href, page, action, + module, params, anchor, redirect, @@ -358,6 +360,7 @@ String href, String page, String action, +String module, Map params, String anchor, boolean redirect, @@ -370,6 +373,7 @@ href, page, action, +module, params, anchor, redirect, @@ -383,6 +387,7 @@ String href, String page, String action, + String module, Map params, String anchor, boolean redirect, @@ -394,6 +399,7 @@ href, page, action, + module, params, anchor, redirect, @@ -439,6 +445,7 @@ String href, String page, String action, +String module, Map params, String anchor, boolean redirect, @@ -471,7 +478,7 @@ } // Look up the module configuration for this request -ModuleConfig config = instance.getModuleConfig(pageContext); +ModuleConfig config = instance.getModuleConfig(module, pageContext); // Calculate the appropriate URL StringBuffer url = new StringBuffer(); @@ -493,7 +500,7 @@ } else if (href != null) { url.append(href); } else if (action != null) { -url.append(instance.getActionMappingURL(action, pageContext)); +url.append(instance.getActionMappingURL(action, module, pageContext, false)); } else /* if (page != null) */ { url.append(request.getContextPath()); @@ -778,18 +785,18 @@ * Return the form action converted into a server-relative URL. */ public String getActionMappingURL(String action, PageContext pageContext) { -return getActionMappingURL(action,pageContext,false); +return getActionMappingURL(action,null,pageContext,false); } /** * Return the form action converted into a server-relative URL. */ -public String getActionMappingURL(String action, PageContext pageContext, boolean contextRelative) { +public String getActionMappingURL(String action, String module, PageContext pageContext, boolean contextRelative) { HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); StringBuffer value = new StringBuffer(request.getContextPath()); -ModuleConfig config = ModuleUtils.getInstance().getModuleConfig(request); +ModuleConfig config = ModuleUtils.getInstance().getModuleConfig(module, request, pageContext.getServletContext()); if ((config != null) (!contextRelative)) {
cvs commit: jakarta-struts/src/share/org/apache/struts/util ModuleUtils.java RequestUtils.java
dgraham 2003/08/02 14:03:41 Modified:src/share/org/apache/struts/util RequestUtils.java Added: src/share/org/apache/struts/util ModuleUtils.java Log: Moved module related methods to new ModuleUtils class. Revision ChangesPath 1.132 +26 -69 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.131 retrieving revision 1.132 diff -u -r1.131 -r1.132 --- RequestUtils.java 2 Aug 2003 20:40:18 - 1.131 +++ RequestUtils.java 2 Aug 2003 21:03:41 - 1.132 @@ -90,7 +90,6 @@ import org.apache.struts.action.ActionServletWrapper; import org.apache.struts.action.DynaActionForm; import org.apache.struts.action.DynaActionFormClass; -import org.apache.struts.action.RequestProcessor; import org.apache.struts.config.ActionConfig; import org.apache.struts.config.FormBeanConfig; import org.apache.struts.config.ForwardConfig; @@ -109,7 +108,6 @@ * @author David Graham * @version $Revision$ $Date$ */ - public class RequestUtils { // --- Static Variables @@ -1261,27 +1259,15 @@ * @param request The servlet request we are processing * @param context The ServletContext for this web application * @since Struts 1.1 + * @deprecated Use ModuleUtils.selectModule() instead. This will be + * removed after Struts 1.2. */ public static void selectModule( String prefix, HttpServletRequest request, ServletContext context) { -// Expose the resources for this module -ModuleConfig config = (ModuleConfig) context.getAttribute(Globals.MODULE_KEY + prefix); -if (config != null) { -request.setAttribute(Globals.MODULE_KEY, config); -} else { -request.removeAttribute(Globals.MODULE_KEY); -} -MessageResources resources = -(MessageResources) context.getAttribute(Globals.MESSAGES_KEY + prefix); -if (resources != null) { -request.setAttribute(Globals.MESSAGES_KEY, resources); -} else { -request.removeAttribute(Globals.MESSAGES_KEY); -} - +ModuleUtils.getInstance().selectModule(prefix, request, context); } /** @@ -1290,13 +1276,11 @@ * * @param request The servlet request we are processing * @param context The ServletContext for this web application + * @deprecated Use ModuleUtils.selectModule() instead. This will be + * removed after Struts 1.2. */ public static void selectModule(HttpServletRequest request, ServletContext context) { -// Compute module name -String prefix = getModuleName(request, context); -// Expose the resources for this module -selectModule(prefix, request, context); - +ModuleUtils.getInstance().selectModule(request, context); } /** @@ -1304,16 +1288,11 @@ * @param request The servlet request we are processing * @param context The ServletContext for this web application * @return The module prefix or + * @deprecated Use ModuleUtils.getModuleName() instead. This will be + * removed after Struts 1.2. */ public static String getModuleName(HttpServletRequest request, ServletContext context) { - -// Acquire the path used to compute the module -String matchPath = (String) request.getAttribute(RequestProcessor.INCLUDE_SERVLET_PATH); - -if (matchPath == null) { -matchPath = request.getServletPath(); -} -return getModuleName( matchPath, context); +return ModuleUtils.getInstance().getModuleName(request, context); } /** @@ -1321,34 +1300,11 @@ * @param matchPath The uri from which we want the module name. * @param context The ServletContext for this web application * @return The module prefix or + * @deprecated Use ModuleUtils.getModuleName() instead. This will be + * removed after Struts 1.2. */ public static String getModuleName(String matchPath, ServletContext context) { -if (log.isDebugEnabled()) { -log.debug(Get module name for path + matchPath); -} - -String prefix = ; // Initialize prefix before we try lookup -String prefixes[] = getModulePrefixes(context); // Get all other possible prefixes -int lastSlash = 0; // Initialize before loop - -while (prefix.equals() ((lastSlash = matchPath.lastIndexOf(/)) 0)) { - -// We may be in a non-default module.