|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectTemplateHelper
public class TemplateHelper
Class for creating URLs from parameterized templates. This mechanism recognizes the following parameters in URL templates:
url:scheme | Scheme | Usage | |||||||
url:domain | Domain | May be set | |||||||
url:port | Port | May be set | |||||||
url:path | Extra path information | Reserved, must be present in a template. | |||||||
url:queryString | Reserved query parameters | Reserved, must be present in a template. |
Field Summary | |
---|---|
static String |
CONTROL_STATE_PARAM
Control state parameter (reserved). |
protected HttpServletRequest |
httpRequest
HTTP request. |
protected HttpServletResponse |
httpResponse
HTTP response<. |
static String |
MODE_PARAM
Window mode query parameter (reserved). |
static String |
PAGE_LABEL_PARAM
Page label query parameter (reserved). |
protected LinkedHashMap |
params
Query parameters |
static String |
POSTBACK_PARAM
Postback request query parameter (reserved). |
static String |
STATE_PARAM
Window state query parameter (reserved). |
static String |
WINDOW_LABEL_PARAM
Window label query parameter (reserved). |
Constructor Summary | |
---|---|
TemplateHelper(HttpServletRequest httpRequest,
HttpServletResponse httpResponse)
Constructs a GenericURL . |
Method Summary | |
---|---|
void |
addParameter(String name,
String value)
Add a parameter. |
Object |
clone()
Returns a deep copy. |
String |
getDomain()
Returns the domain. |
boolean |
getEncodeSession()
Returns true if URL rewriting is enabled. |
String |
getParameter(String name)
Returns the value of the parameter. |
List |
getParameters(String name)
Returns the values of the given parameter. |
String |
getPathPrefix()
Returns the path prefix. |
int |
getPort()
Returns the port. |
String |
getQueryString()
|
String |
getScheme()
Returns the protocol scheme. |
URLTemplate |
getTemplate()
Returns the current template. |
String |
getTemplateName(String templateRef)
|
boolean |
hasTemplateRef(String templateRef)
|
void |
removeParameter(String name)
Removes the given parameter. |
void |
setDomain(String domain)
Sets the domain. |
void |
setEncodeSession(boolean encodeSession)
Enables URL rewriting for encoding a session ID in the URL. |
void |
setPath(String path)
Sets path. |
void |
setPathPrefix(String pathPrefix)
Sets a path prefix. |
void |
setPort(int port)
Sets a port. |
void |
setQueryString(String queryString)
|
void |
setScheme(String scheme)
Sets the protocol scheme. |
void |
setTemplate(String templateName)
Sets a URL template for this URL. |
protected void |
setTemplate(URLTemplate urlTemplate)
|
void |
setUrl(String url)
|
String |
toString()
Returns a string form (fully-quanlfied) of this URL. |
Methods inherited from class Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String POSTBACK_PARAM
Postback request query parameter (reserved).
public static final String WINDOW_LABEL_PARAM
Window label query parameter (reserved).
public static final String STATE_PARAM
Window state query parameter (reserved).
public static final String MODE_PARAM
Window mode query parameter (reserved).
public static final String PAGE_LABEL_PARAM
Page label query parameter (reserved).
public static final String CONTROL_STATE_PARAM
Control state parameter (reserved).
protected HttpServletRequest httpRequest
HTTP request.
protected HttpServletResponse httpResponse
HTTP response<./p>
protected LinkedHashMap params
Query parameters
Constructor Detail |
---|
public TemplateHelper(HttpServletRequest httpRequest, HttpServletResponse httpResponse)
Constructs a GenericURL
.
httpRequest
- HTTP requesthttpResponse
- HTTP responseMethod Detail |
---|
public boolean hasTemplateRef(String templateRef)
public String getTemplateName(String templateRef)
public void setTemplate(String templateName)
Sets a URL template for this URL.
templateName
- name of the url template
IllegalArgumentException
- thrown if the named template does not exist
or if the template is not validprotected void setTemplate(URLTemplate urlTemplate)
public URLTemplate getTemplate()
Returns the current template.
public void setScheme(String scheme)
Sets the protocol scheme. Should be one of "HTTP" or "HTTPS". If a protocol is not specified, the protocol that was used to make the current request will be used.
scheme
- protocol schemepublic String getScheme()
Returns the protocol scheme. If no protocol was previously set, returns the protocol that was used to make the current request.
public void setPort(int port)
Sets a port. If a port is not specified, the port that was used to make the current request will be used.
port
- portpublic int getPort()
Returns the port. If no port was previously set, returns the port that was used to make the current request.
public void setDomain(String domain)
Sets the domain. If a domain is not specified, the domain that was used to make the current request will be used.
domain
- domainpublic String getDomain()
Returns the domain. If no domain was previously set, returns the domain that was used to make the current request.
public void setPath(String path)
Sets path.
path
- pathpublic String getQueryString()
public void setQueryString(String queryString)
public void setPathPrefix(String pathPrefix)
Sets a path prefix.
pathPrefix
- path prefixpublic String getPathPrefix()
Returns the path prefix.
public void setEncodeSession(boolean encodeSession)
Enables URL rewriting for encoding a session ID in the
URL. If not set to true
, does not encode the URL
with the session ID. Default is true
.
encodeSession
- booleanpublic boolean getEncodeSession()
Returns true
if URL rewriting is enabled.
public void setUrl(String url)
public void addParameter(String name, String value)
Add a parameter. Multiple values for the same parameter can be set by calling this method multiple times with the same name.
name
- namevalue
- valuepublic void removeParameter(String name)
Removes the given parameter.
name
- namepublic String getParameter(String name)
Returns the value of the parameter. If the parameter has several values, returns the first value.
name
- name of the parameter
public List getParameters(String name)
Returns the values of the given parameter.
name
- name of the parameter
public Object clone()
Returns a deep copy.
clone
in class Object
public String toString()
Returns a string form (fully-quanlfied) of this URL.
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |