org.apache.struts2.components
Class URL

java.lang.Object
  extended by org.apache.struts2.components.Component
      extended by org.apache.struts2.components.URL

public class URL
extends Component

This tag is used to create a URL.

You can use the "param" tag inside the body to provide additional request parameters.

NOTE:

When includeParams is 'all' or 'get', the parameter defined in param tag will take precedence and will not be overriden if they exists in the parameter submitted. For example, in Example 3 below, if there is a id parameter in the url where the page this tag is included like http://://editUser.action?id=3333&name=John the generated url will be http://:/context>/editUser.action?id=22&name=John cause the parameter defined in the param tag will take precedence.

Examples

 
 
 <-- Example 1 -->
 <s:url value="editGadget.action">
     <s:param name="id" value="%{selected}" />
 </s:url>

 <-- Example 2 -->
 <s:url action="editGadget">
     <s:param name="id" value="%{selected}" />
 </s:url>
 
 <-- Example 3-->
 <s:url includeParams="get"  >
     <:param name="id" value="%{'22'}" />
 </s:url>
 
 
 

See Also:
Param

Field Summary
protected  java.lang.String action
           
static java.lang.String ALL
           
protected  java.lang.String anchor
           
protected  boolean encode
           
static java.lang.String GET
           
protected  boolean includeContext
           
protected  java.lang.String includeParams
           
protected  java.lang.String method
           
protected  java.lang.String namespace
           
static java.lang.String NONE
          The includeParams attribute may have the value 'none', 'get' or 'all'.
protected  java.lang.String portletMode
           
protected  java.lang.String portletUrlType
           
protected  java.lang.String scheme
           
protected  java.lang.String value
           
protected  java.lang.String windowState
           
 
Fields inherited from class org.apache.struts2.components.Component
COMPONENT_STACK, id, parameters, stack
 
Constructor Summary
URL(com.opensymphony.xwork2.util.OgnlValueStack stack, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
           
 
Method Summary
 boolean end(java.io.Writer writer, java.lang.String body)
          Callback for the end tag of this component.
protected  void mergeRequestParameters(java.lang.String value, java.util.Map parameters, java.util.Map contextParameters)
          Merge request parameters into current parameters.
 void setAction(java.lang.String action)
          The action generate url for, if not using value
 void setAnchor(java.lang.String anchor)
          The anchor for this URL
 void setEncode(boolean encode)
          whether to encode parameters
 void setIncludeContext(boolean includeContext)
          whether actual context should be included in url
 void setIncludeParams(java.lang.String includeParams)
          The includeParams attribute may have the value 'none', 'get' or 'all'.
 void setMethod(java.lang.String method)
          The method of action to use
 void setNamespace(java.lang.String namespace)
          The namespace to use
 void setPortletMode(java.lang.String portletMode)
          The resulting portlet mode
 void setPortletUrlType(java.lang.String portletUrlType)
          Specifies if this should be a portlet render or action url
 void setScheme(java.lang.String scheme)
          Set scheme attribute
 void setValue(java.lang.String value)
          The target value to use, if not using action
 void setWindowState(java.lang.String windowState)
          The resulting portlet window state
 boolean start(java.io.Writer writer)
          Callback for the start tag of this component.
 
Methods inherited from class org.apache.struts2.components.Component
addAllParameters, addParameter, altSyntax, copyParams, determineActionURL, determineNamespace, end, fieldError, findAncestor, findString, findString, findValue, findValue, findValue, getComponentStack, getId, getParameters, getStack, popComponentStack, setId, toString, usesBody
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NONE

public static final java.lang.String NONE
The includeParams attribute may have the value 'none', 'get' or 'all'. It is used when the url tag is used without a value attribute. Its value is looked up on the ValueStack If no includeParams is specified then 'get' is used. none - include no parameters in the URL get - include only GET parameters in the URL (default) all - include both GET and POST parameters in the URL

See Also:
Constant Field Values

GET

public static final java.lang.String GET
See Also:
Constant Field Values

ALL

public static final java.lang.String ALL
See Also:
Constant Field Values

includeParams

protected java.lang.String includeParams

scheme

protected java.lang.String scheme

value

protected java.lang.String value

action

protected java.lang.String action

namespace

protected java.lang.String namespace

method

protected java.lang.String method

encode

protected boolean encode

includeContext

protected boolean includeContext

portletMode

protected java.lang.String portletMode

windowState

protected java.lang.String windowState

portletUrlType

protected java.lang.String portletUrlType

anchor

protected java.lang.String anchor
Constructor Detail

URL

public URL(com.opensymphony.xwork2.util.OgnlValueStack stack,
           javax.servlet.http.HttpServletRequest req,
           javax.servlet.http.HttpServletResponse res)
Method Detail

start

public boolean start(java.io.Writer writer)
Description copied from class: Component
Callback for the start tag of this component. Should the body be evaluated?

Overrides:
start in class Component
Parameters:
writer - the output writer.
Returns:
true if the body should be evaluated

end

public boolean end(java.io.Writer writer,
                   java.lang.String body)
Description copied from class: Component
Callback for the end tag of this component. Should the body be evaluated again?

NOTE: will pop component stack.

Overrides:
end in class Component
Parameters:
writer - the output writer.
body - the rendered body.
Returns:
true if the body should be evaluated again

setIncludeParams

public void setIncludeParams(java.lang.String includeParams)
The includeParams attribute may have the value 'none', 'get' or 'all'.


setScheme

public void setScheme(java.lang.String scheme)
Set scheme attribute


setValue

public void setValue(java.lang.String value)
The target value to use, if not using action


setAction

public void setAction(java.lang.String action)
The action generate url for, if not using value


setNamespace

public void setNamespace(java.lang.String namespace)
The namespace to use


setMethod

public void setMethod(java.lang.String method)
The method of action to use


setEncode

public void setEncode(boolean encode)
whether to encode parameters


setIncludeContext

public void setIncludeContext(boolean includeContext)
whether actual context should be included in url


setPortletMode

public void setPortletMode(java.lang.String portletMode)
The resulting portlet mode


setWindowState

public void setWindowState(java.lang.String windowState)
The resulting portlet window state


setPortletUrlType

public void setPortletUrlType(java.lang.String portletUrlType)
Specifies if this should be a portlet render or action url


setAnchor

public void setAnchor(java.lang.String anchor)
The anchor for this URL


mergeRequestParameters

protected void mergeRequestParameters(java.lang.String value,
                                      java.util.Map parameters,
                                      java.util.Map contextParameters)
Merge request parameters into current parameters. If a parameter is already present, than the request parameter in the current request and value atrribute will not override its value. The priority is as follows:-

Parameters:
value - the value attribute (url to be generated by this component)
parameters - component parameters
contextParameters - request parameters


Copyright © 2000-2006 Apache Software Foundation. All Rights Reserved.