FileDocCategorySizeDatePackage
URLBean.javaAPI DocExample2813Mon Jul 23 13:26:56 BST 2007org.apache.struts2.util

URLBean

public class URLBean extends Object
A bean that can generate a URL.

Fields Summary
HashMap
params
HttpServletRequest
request
HttpServletResponse
response
String
page
Constructors Summary
Methods Summary
public org.apache.struts2.util.URLBeanaddParameter(java.lang.String name, java.lang.Object value)

        if (params == null) {
            params = new HashMap();
        }

        if (value == null) {
            params.remove(name);
        } else {
            params.put(name, value.toString());
        }

        return this;
    
public java.lang.StringgetURL()

        // all this trickier with maps is to reduce the number of objects created
        Map fullParams = null;

        if (params != null) {
            fullParams = new HashMap();
        }

        if (page == null) {
            // No particular page requested, so go to "same page"
            // Add query params to parameters
            if (fullParams != null) {
                fullParams.putAll(request.getParameterMap());
            } else {
                fullParams = request.getParameterMap();
            }
        }

        // added parameters override, just like in URLTag
        if (params != null) {
            fullParams.putAll(params);
        }

        return UrlHelper.buildUrl(page, request, response, fullParams);
    
public org.apache.struts2.util.URLBeansetPage(java.lang.String page)

        this.page = page;
        return this;
    
public voidsetRequest(javax.servlet.http.HttpServletRequest request)

        this.request = request;
    
public voidsetResponse(javax.servlet.http.HttpServletResponse response)

        this.response = response;
    
public java.lang.StringtoString()

        return getURL();