struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pbened...@apache.org
Subject svn commit: r552353 - in /struts/struts1/branches/STRUTS_1_3_BRANCH: apps/examples/src/main/webapp/WEB-INF/exercise/struts-config.xml apps/examples/src/main/webapp/exercise/html-img.jsp taglib/src/main/java/org/apache/struts/taglib/html/ImgTag.java
Date Sun, 01 Jul 2007 19:04:13 GMT
Author: pbenedict
Date: Sun Jul  1 12:04:12 2007
New Revision: 552353

URL: http://svn.apache.org/viewvc?view=rev&rev=552353
Log:
STR-3052: Add actionId support

Modified:
    struts/struts1/branches/STRUTS_1_3_BRANCH/apps/examples/src/main/webapp/WEB-INF/exercise/struts-config.xml
    struts/struts1/branches/STRUTS_1_3_BRANCH/apps/examples/src/main/webapp/exercise/html-img.jsp
    struts/struts1/branches/STRUTS_1_3_BRANCH/taglib/src/main/java/org/apache/struts/taglib/html/ImgTag.java

Modified: struts/struts1/branches/STRUTS_1_3_BRANCH/apps/examples/src/main/webapp/WEB-INF/exercise/struts-config.xml
URL: http://svn.apache.org/viewvc/struts/struts1/branches/STRUTS_1_3_BRANCH/apps/examples/src/main/webapp/WEB-INF/exercise/struts-config.xml?view=diff&rev=552353&r1=552352&r2=552353
==============================================================================
--- struts/struts1/branches/STRUTS_1_3_BRANCH/apps/examples/src/main/webapp/WEB-INF/exercise/struts-config.xml
(original)
+++ struts/struts1/branches/STRUTS_1_3_BRANCH/apps/examples/src/main/webapp/WEB-INF/exercise/struts-config.xml
Sun Jul  1 12:04:12 2007
@@ -67,7 +67,9 @@
         <!-- :FIXME: ImageAction should compute module prefix -->
         <action path="/html-img-action"
                 type="org.apache.struts.webapp.exercise.ImageAction"
-                parameter="/exercise/struts-power.gif"/>
+                parameter="/exercise/struts-power.gif">
+            <set-property property="actionId" value="imgAction"/>
+        </action>
         <action path="/html-image" forward="/html-image.jsp"
                 name="testbean" scope="session" validate="false"/>
         <action path="/html-link" forward="/html-link.jsp"/>

Modified: struts/struts1/branches/STRUTS_1_3_BRANCH/apps/examples/src/main/webapp/exercise/html-img.jsp
URL: http://svn.apache.org/viewvc/struts/struts1/branches/STRUTS_1_3_BRANCH/apps/examples/src/main/webapp/exercise/html-img.jsp?view=diff&rev=552353&r1=552352&r2=552353
==============================================================================
--- struts/struts1/branches/STRUTS_1_3_BRANCH/apps/examples/src/main/webapp/exercise/html-img.jsp
(original)
+++ struts/struts1/branches/STRUTS_1_3_BRANCH/apps/examples/src/main/webapp/exercise/html-img.jsp
Sun Jul  1 12:04:12 2007
@@ -50,6 +50,14 @@
     </tr>
     <tr>
     <td>
+    Struts img tag via action attribute and actionId
+    </td>
+    <td>
+    <html:img action="imgAction" />
+    </td>
+    </tr>
+    <tr>
+    <td>
     Struts img tag via page attribute, default module
     </td>
     <td>

Modified: struts/struts1/branches/STRUTS_1_3_BRANCH/taglib/src/main/java/org/apache/struts/taglib/html/ImgTag.java
URL: http://svn.apache.org/viewvc/struts/struts1/branches/STRUTS_1_3_BRANCH/taglib/src/main/java/org/apache/struts/taglib/html/ImgTag.java?view=diff&rev=552353&r1=552352&r2=552353
==============================================================================
--- struts/struts1/branches/STRUTS_1_3_BRANCH/taglib/src/main/java/org/apache/struts/taglib/html/ImgTag.java
(original)
+++ struts/struts1/branches/STRUTS_1_3_BRANCH/taglib/src/main/java/org/apache/struts/taglib/html/ImgTag.java
Sun Jul  1 12:04:12 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,



Mime
View raw message