Author: pbenedict
Date: Fri Sep  1 21:46:01 2006
New Revision: 439533

URL: http://svn.apache.org/viewvc?rev=439533&view=rev
Log:
STR-2864: FormTag to recognize actionId, plus any tags that can build URLs from 
an action

Modified:
    
struts/struts1/trunk/taglib/src/main/java/org/apache/struts/taglib/TagUtils.java
    
struts/struts1/trunk/taglib/src/main/java/org/apache/struts/taglib/html/FormTag.java

Modified: 
struts/struts1/trunk/taglib/src/main/java/org/apache/struts/taglib/TagUtils.java
URL: 
http://svn.apache.org/viewvc/struts/struts1/trunk/taglib/src/main/java/org/apache/struts/taglib/TagUtils.java?rev=439533&r1=439532&r2=439533&view=diff
==============================================================================
--- 
struts/struts1/trunk/taglib/src/main/java/org/apache/struts/taglib/TagUtils.java
 (original)
+++ 
struts/struts1/trunk/taglib/src/main/java/org/apache/struts/taglib/TagUtils.java
 Fri Sep  1 21:46:01 2006
@@ -24,6 +24,7 @@
 import org.apache.struts.action.ActionErrors;
 import org.apache.struts.action.ActionMessage;
 import org.apache.struts.action.ActionMessages;
+import org.apache.struts.action.ActionServlet;
 import org.apache.struts.config.ForwardConfig;
 import org.apache.struts.config.ModuleConfig;
 import org.apache.struts.taglib.html.Constants;
@@ -388,8 +389,16 @@
         } else if (href != null) {
             url.append(href);
         } else if (action != null) {
-            url.append(instance.getActionMappingURL(action, module,
-                    pageContext, false));
+            ActionServlet servlet = (ActionServlet) 
pageContext.getServletContext().getAttribute(Globals.ACTION_SERVLET_KEY);
+            String actionIdPath = RequestUtils.actionIdURL(action, 
moduleConfig, servlet);
+            if (actionIdPath != null) {
+                action = actionIdPath;
+                url.append(request.getContextPath());
+                url.append(actionIdPath);
+            } else {
+                url.append(instance.getActionMappingURL(action, module,
+                        pageContext, false));
+            }
         } else /* if (page != null) */
          {
             url.append(request.getContextPath());

Modified: 
struts/struts1/trunk/taglib/src/main/java/org/apache/struts/taglib/html/FormTag.java
URL: 
http://svn.apache.org/viewvc/struts/struts1/trunk/taglib/src/main/java/org/apache/struts/taglib/html/FormTag.java?rev=439533&r1=439532&r2=439533&view=diff
==============================================================================
--- 
struts/struts1/trunk/taglib/src/main/java/org/apache/struts/taglib/html/FormTag.java
 (original)
+++ 
struts/struts1/trunk/taglib/src/main/java/org/apache/struts/taglib/html/FormTag.java
 Fri Sep  1 21:46:01 2006
@@ -1,7 +1,7 @@
 /*
  * $Id$
  *
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
 import org.apache.struts.action.ActionForm;
 import org.apache.struts.action.ActionMapping;
 import org.apache.struts.action.ActionServlet;
+import org.apache.struts.config.ActionConfig;
 import org.apache.struts.config.FormBeanConfig;
 import org.apache.struts.config.ModuleConfig;
 import org.apache.struts.taglib.TagUtils;
@@ -764,6 +765,13 @@
                 postbackAction = postbackAction.substring(prefix.length());
             }
             calcAction = postbackAction;
+        } else {
+            // Translate the action if it is an actionId
+            ActionConfig actionConfig = 
moduleConfig.findActionConfigId(this.action);
+            if (actionConfig != null) {
+                this.action = actionConfig.getPath();
+                calcAction = this.action;
+            }
         }
 
         servlet =


Reply via email to