Author: pbenedict Date: Sun Jul 1 12:03:59 2007 New Revision: 552352 URL: http://svn.apache.org/viewvc?view=rev&rev=552352 Log: STR-3052: Add actionId support
Modified: struts/struts1/trunk/taglib/src/main/java/org/apache/struts/taglib/html/ImgTag.java Modified: struts/struts1/trunk/taglib/src/main/java/org/apache/struts/taglib/html/ImgTag.java URL: http://svn.apache.org/viewvc/struts/struts1/trunk/taglib/src/main/java/org/apache/struts/taglib/html/ImgTag.java?view=diff&rev=552352&r1=552351&r2=552352 ============================================================================== --- struts/struts1/trunk/taglib/src/main/java/org/apache/struts/taglib/html/ImgTag.java (original) +++ struts/struts1/trunk/taglib/src/main/java/org/apache/struts/taglib/html/ImgTag.java Sun Jul 1 12:03:59 2007 @@ -20,6 +20,7 @@ */ package org.apache.struts.taglib.html; +import org.apache.struts.config.ActionConfig; import org.apache.struts.config.ModuleConfig; import org.apache.struts.taglib.TagUtils; import org.apache.struts.util.MessageResources; @@ -473,6 +474,12 @@ * @throws JspException if an error occurs */ protected String src() throws JspException { + ModuleConfig moduleConfig = + ModuleUtils.getInstance().getModuleConfig(this.module, + (HttpServletRequest) pageContext.getRequest(), + pageContext.getServletContext()); + + // Deal with a direct context-relative page that has been specified if (this.page != null) { if ((this.src != null) || (this.srcKey != null) @@ -480,18 +487,13 @@ throwImgTagSrcException(); } - ModuleConfig config = - ModuleUtils.getInstance().getModuleConfig(this.module, - (HttpServletRequest) pageContext.getRequest(), - pageContext.getServletContext()); - HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); String pageValue = this.page; - if (!srcDefaultReference(config)) { + if (!srcDefaultReference(moduleConfig)) { pageValue = - TagUtils.getInstance().pageURL(request, this.page, config); + TagUtils.getInstance().pageURL(request, this.page, moduleConfig); } return (request.getContextPath() + pageValue); @@ -503,20 +505,15 @@ throwImgTagSrcException(); } - ModuleConfig config = - ModuleUtils.getInstance().getModuleConfig(this.module, - (HttpServletRequest) pageContext.getRequest(), - pageContext.getServletContext()); - HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); String pageValue = TagUtils.getInstance().message(pageContext, getBundle(), getLocale(), this.pageKey); - if (!srcDefaultReference(config)) { + if (!srcDefaultReference(moduleConfig)) { pageValue = - TagUtils.getInstance().pageURL(request, pageValue, config); + TagUtils.getInstance().pageURL(request, pageValue, moduleConfig); } return (request.getContextPath() + pageValue); @@ -525,6 +522,12 @@ if (this.action != null) { if ((this.src != null) || (this.srcKey != null)) { throwImgTagSrcException(); + } + + // Translate the action if it is an actionId + ActionConfig actionConfig = moduleConfig.findActionConfigId(this.action); + if (actionConfig != null) { + action = actionConfig.getPath(); } return TagUtils.getInstance().getActionMappingURL(action, module,