Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.struts2.components
Class URL

    java.lang.Object
      org.apache.struts2.components.Component
          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.

- action (String) - (value or action choose either one, if both exist value takes precedence) action's name (alias)
- value (String) - (value or action choose either one, if both exist value takes precedence) the url itself
- scheme (String) - http scheme (http, https) default to the scheme this request is in
- namespace - action's namespace
- method (String) - action's method, default to execute()
- encode (Boolean) - url encode the generated url. Default is true
- includeParams (String) - The includeParams attribute may have the value 'none', 'get' or 'all'. Default is 'get'. 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
- includeContext (Boolean) - determine wheather to include the web app context path. Default is true.

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`

Nested Class Summary
`static interface` | `URL.ExtraParameterProvider`

Field Summary
`protected String` | `action`
`static String` | `ALL`
`protected String` | `anchor`
`protected boolean` | `encode`
`protected URL.ExtraParameterProvider` | `extraParameterProvider`
`static String` | `GET`
`protected boolean` | `includeContext`
`protected String` | `includeParams`
`private static Log` | `LOG`
`protected String` | `method`
`protected String` | `namespace`
`static String` | `NONE` The includeParams attribute may have the value 'none', 'get' or 'all'.
`protected String` | `portletMode`
`protected String` | `portletUrlType`
`private HttpServletRequest` | `req`
`private HttpServletResponse` | `res`
`protected String` | `scheme`
`protected String` | `urlIncludeParams`
`protected String` | `value`
`protected String` | `windowState`

Fields inherited from class org.apache.struts2.components.Component
`actionMapper, COMPONENT_STACK, id, parameters, stack`

Constructor Summary
`URL(ValueStack stack, HttpServletRequest req, HttpServletResponse res)`

Method Summary
`boolean` | `end(Writer writer, String body)` Callback for the end tag of this component.
`private String` | `extractQueryString()`
`private void` | `includeExtraParameters()`
`private void` | `includeGetParameters()`
`protected void` | `mergeRequestParameters(String value, Map parameters, Map contextParameters)` Merge request parameters into current parameters.
`void` | `setAction(String action)`
`void` | `setAnchor(String anchor)`
`void` | `setEncode(boolean encode)`
`void` | `setExtraParameterProvider(URL.ExtraParameterProvider provider)`
`void` | `setIncludeContext(boolean includeContext)`
`void` | `setIncludeParams(String includeParams)`
`void` | `setMethod(String method)`
`void` | `setNamespace(String namespace)`
`void` | `setPortletMode(String portletMode)`
`void` | `setPortletUrlType(String portletUrlType)`
`void` | `setScheme(String scheme)`
`void` | `setUrlIncludeParams(String urlIncludeParams)`
`void` | `setValue(String value)`
`void` | `setWindowState(String windowState)`
`boolean` | `start(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, setActionMapper, setId, toString, usesBody`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### LOG

    private static final Log LOG

### NONE

    public static final 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 String GET

See Also:
  Constant Field Values

### ALL

    public static final String ALL

See Also:
  Constant Field Values

### req

    private HttpServletRequest req

### res

    private HttpServletResponse res

### includeParams

    protected String includeParams

### scheme

    protected String scheme

### value

    protected String value

### action

    protected String action

### namespace

    protected String namespace

### method

    protected String method

### encode

    protected boolean encode

### includeContext

    protected boolean includeContext

### portletMode

    protected String portletMode

### windowState

    protected String windowState

### portletUrlType

    protected String portletUrlType

### anchor

    protected String anchor

### urlIncludeParams

    protected String urlIncludeParams

### extraParameterProvider

    protected URL.ExtraParameterProvider extraParameterProvider

Constructor Detail

### URL

    public URL(ValueStack stack,
               HttpServletRequest req,
               HttpServletResponse res)

Method Detail

### setUrlIncludeParams

    public void setUrlIncludeParams(String urlIncludeParams)

### setExtraParameterProvider

    public void setExtraParameterProvider(URL.ExtraParameterProvider provider)

### start

    public boolean start(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

### includeExtraParameters

    private void includeExtraParameters()

### includeGetParameters

    private void includeGetParameters()

### extractQueryString

    private String extractQueryString()

### end

    public boolean end(Writer writer,
                       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(String includeParams)

### setScheme

    public void setScheme(String scheme)

### setValue

    public void setValue(String value)

### setAction

    public void setAction(String action)

### setNamespace

    public void setNamespace(String namespace)

### setMethod

    public void setMethod(String method)

### setEncode

    public void setEncode(boolean encode)

### setIncludeContext

    public void setIncludeContext(boolean includeContext)

### setPortletMode

    public void setPortletMode(String portletMode)

### setWindowState

    public void setWindowState(String windowState)

### setPortletUrlType

    public void setPortletUrlType(String portletUrlType)

### setAnchor

    public void setAnchor(String anchor)

### mergeRequestParameters

    protected void mergeRequestParameters(String value,
                                          Map parameters,
                                          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:-
  - parameter from the current request (least priority)
  - parameter form the value attribute (more priority)
  - parameter from the param tag (most priority)

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

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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