Author: schultz
Date: Wed Jul 27 22:26:19 2011
New Revision: 1151655
URL: http://svn.apache.org/viewvc?rev=1151655&view=rev
Log:
Added StrutsLinkTool.action and StrutsLinkTool.forward to match new LinkTool
API.
Modified:
velocity/tools/branches/2.0.x/src/main/java/org/apache/velocity/tools/struts/StrutsLinkTool.java
velocity/tools/branches/2.0.x/xdocs/changes.xml
Modified:
velocity/tools/branches/2.0.x/src/main/java/org/apache/velocity/tools/struts/StrutsLinkTool.java
URL:
http://svn.apache.org/viewvc/velocity/tools/branches/2.0.x/src/main/java/org/apache/velocity/tools/struts/StrutsLinkTool.java?rev=1151655&r1=1151654&r2=1151655&view=diff
==============================================================================
---
velocity/tools/branches/2.0.x/src/main/java/org/apache/velocity/tools/struts/StrutsLinkTool.java
(original)
+++
velocity/tools/branches/2.0.x/src/main/java/org/apache/velocity/tools/struts/StrutsLinkTool.java
Wed Jul 27 22:26:19 2011
@@ -80,11 +80,11 @@ public class StrutsLinkTool extends Link
StrutsLinkTool sub = null;
if ("action".equalsIgnoreCase(this.get))
{
- sub = setAction(getme);
+ sub = action(getme);
}
else if ("forward".equalsIgnoreCase(this.get))
{
- sub = setForward(getme);
+ sub = forward(getme);
}
else
{
@@ -110,7 +110,7 @@ public class StrutsLinkTool extends Link
*
* @return a new instance of StrutsLinkTool
*/
- public StrutsLinkTool setAction(String action)
+ public StrutsLinkTool action(String action)
{
String url =
StrutsUtils.getActionMappingURL(application, request, action);
@@ -123,6 +123,21 @@ public class StrutsLinkTool extends Link
return (StrutsLinkTool)absolute(url);
}
+ /**
+ * <p>Returns a copy of the link with the given action name
+ * converted into a server-relative URI reference. This method
+ * does not check if the specified action really is defined.
+ * This method will overwrite any previous URI reference settings
+ * but will copy the query string.</p>
+ *
+ * @param action an action path as defined in struts-config.xml
+ *
+ * @return a new instance of StrutsLinkTool
+ */
+ public StrutsLinkTool setAction(String action)
+ {
+ return action(action);
+ }
/**
* <p>Returns a copy of the link with the given global or local forward
@@ -137,7 +152,7 @@ public class StrutsLinkTool extends Link
*
* @return a new instance of StrutsLinkTool
*/
- public StrutsLinkTool setForward(String forward)
+ public StrutsLinkTool forward(String forward)
{
String url = StrutsUtils.getForwardURL(request, application, forward);
if (url == null)
@@ -148,4 +163,22 @@ public class StrutsLinkTool extends Link
}
return (StrutsLinkTool)absolute(url);
}
+
+ /**
+ * <p>Returns a copy of the link with the given global or local forward
+ * name converted into a server-relative URI reference. If the parameter
+ * does not map to an existing global forward name, <code>null</code>
+ * is returned. This method will overwrite any previous URI reference
+ * settings but will copy the query string.</p>
+ *
+ * @param forward a forward name as defined in struts-config.xml
+ * in either global-forwards or in the currently executing
+ * action mapping.
+ *
+ * @return a new instance of StrutsLinkTool
+ */
+ public StrutsLinkTool setForward(String forward)
+ {
+ return forward(forward);
+ }
}
Modified: velocity/tools/branches/2.0.x/xdocs/changes.xml
URL:
http://svn.apache.org/viewvc/velocity/tools/branches/2.0.x/xdocs/changes.xml?rev=1151655&r1=1151654&r2=1151655&view=diff
==============================================================================
--- velocity/tools/branches/2.0.x/xdocs/changes.xml (original)
+++ velocity/tools/branches/2.0.x/xdocs/changes.xml Wed Jul 27 22:26:19 2011
@@ -40,6 +40,7 @@
<li>fixed VELTOOLS-145 changed StrutsLinkTool's parent class to
restore API backward-compatibility (schultz)</li>
<li>fixed VELTOOLS-148 - fixed a LinkTool bug with parametersToIgnore
management (schultz)</li>
<li>fixed VELTOOLS-149 - changed LinkTool.addRequestParams to accept
Object[] (schultz)</li>
+ <li>Added StrutsLinkTool.action and StrutsLinkTool.forward methods as
replacements for StrutsLinkTool.setAction ant StrutsLinkTool.setForward to
match other new LinkTool methods like LinkTool.relative and LinkTool.absolute
(schultz)
</ul>
</subsection>