|
Version 4.10.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object hirondelle.web4j.action.ResponsePage
public final class ResponsePage
Response page served to the user at the end of an Action
.
Identifies the page as a resource. Does not include its content, but is rather a reference to the page.
The Controller
will either redirect or forward to the
resource identified by toString()
, according to the value of getIsRedirect()
.
The default value of getIsRedirect()
varies according to constructor:
ResponsePage(String)
defaults to a redirect
These defaults are almost always the desired values. They can be changed, if
necessary, by calling setIsRedirect(java.lang.Boolean)
. It's important to note that that method
returns a brand new object - it doesn't change the state of an existing object.
See the forward-versus-redirect topic on javapractices.com for more information.
Constructor Summary | |
---|---|
ResponsePage(String aURL)
Constructor for a non-templated response. |
|
ResponsePage(String aJsp,
Class<?> aClass)
Constructor for a non-templated response located under /WEB-INF/. |
|
ResponsePage(String aTitle,
String aBodyJsp,
Class aRepresentativeClass)
Constructor which uses the WEB4J template mechanism, with a conventional template. |
|
ResponsePage(String aTitle,
String aBodyJsp,
String aTemplateURL)
Constructor which uses the WEB4J template mechanism. |
|
ResponsePage(String aTitle,
String aBodyJsp,
String aTemplateURL,
Class<?> aClass)
Constructor which uses the WEB4J template mechanism. |
Method Summary | |
---|---|
ResponsePage |
appendQueryParam(String aParamName,
String aParamValue)
Append a query parameter to the URL of a ResponsePage. |
boolean |
equals(Object aThat)
|
Boolean |
getIsRedirect()
See class comment. |
Boolean |
hasBinaryData()
Return true only if withBinaryData() was called. |
int |
hashCode()
|
ResponsePage |
setIsRedirect(Boolean aValue)
Return a new ResponsePage, having the specified forward/redirect behavior. |
String |
toString()
Return the URL passed to the constructor, with any query parameters added by appendQueryParam(java.lang.String, java.lang.String) appended on the end. |
static ResponsePage |
withBinaryData()
Factory method for binary responses. |
Methods inherited from class Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ResponsePage(String aTitle, String aBodyJsp, String aTemplateURL)
aTitle
- text of the <TITLE> tag to be presented in the
template page ; appended to aTemplateURL as a query parameteraBodyJsp
- body of the templated page, where most of the content of interest
lies ; appended to aTemplateURL as a query parameteraTemplateURL
- identifies the templated page which dynamically includes
aBodyJsp in its content. Some applications will have only a single
template for the entire application.public ResponsePage(String aTitle, String aBodyJsp, Class aRepresentativeClass)
As in ResponsePage(String, String, String, Class)
,
but with the template URL taking the conventional value of '../Template.jsp'.
public ResponsePage(String aTitle, String aBodyJsp, String aTemplateURL, Class<?> aClass)
This constructor allows for an unusual but useful policy : placing JSPs in the same directory as related code, under WEB-INF/classes, instead of under the document root of the application. Such a style is beneficial since it allows all (or nearly all) items related to a given feature to be placed in the same directory - JSPs, Action, Model Objects, Data Access Objects, and .sql files. This is the recommended style. It allows package-by-feature.
aTitle
- text of the <TITLE> tag to be presented in the
template page ; appended to aTemplateURL as a query parameteraBodyJsp
- body of the templated page, where most of the content of interest
lies ; appended to aTemplateURL as a query parameteraTemplateURL
- identifies the templated page which dynamically includes
aBodyJsp in its contentaClass
- class literal of any java class related to the given feature; the
package of this class will be used to construct the 'real' path to aBodyJsp,
as in 'WEB-INF/classes/<package-as-directory-path>/<aBodyJsp>'. These
paths are completely internal, are known only to the Controller
, and are
never visible to the user in the URL.public ResponsePage(String aURL)
This constructor does not use the WEB4J template mechanism. This constructor is used both for response pages that require a redirect, and for serving pages that do not use the templating mechanism.
aURL identifies the resource which will be used by an Action
as its destination page.
Example values for aURL :
This constructor returns a redirect. If a forward is desired, call setIsRedirect(Boolean)
.
public ResponsePage(String aJsp, Class<?> aClass)
This constructor allows for an unusual but useful policy : placing JSPs in the same directory as related code, under WEB-INF/classes, instead of under the document root of the application. Such a style is beneficial since it allows all (or nearly all) items related to a given feature to be placed in the same directory - JSPs, Action, Model Objects, Data Access Objects, and .sql files. This is the recommended style. It allows package-by-feature.
This constructor defaults the response to a forward operation.
aJsp
- simple name of a JSP, as in 'view.jsp'aClass
- class literal of any java class in the same package as the given JSP.
The package of this class will be used to construct the 'real' path to the JSP,
as in WEB-INF/classes/<package-as-directory-path>/<aJsp>These paths are completely internal, are known only to the
Controller
, and are
never visible to the user in the URL.Method Detail |
---|
public static ResponsePage withBinaryData()
With such ResponsePages, the normal templating mechanism is not available (since it is based on text), and no forward/redirect is performed by the Controller. In essence, the Action becomes entirely responsible for generating the response.
When serving a binary response, your Action will typically :
public Boolean hasBinaryData()
withBinaryData()
was called.
public String toString()
appendQueryParam(java.lang.String, java.lang.String)
appended on the end.
toString
in class Object
public Boolean getIsRedirect()
public ResponsePage setIsRedirect(Boolean aValue)
This method returns a new ResponsePage having the updated URL. (This will ensure that ResponsePage objects are immutable.)
public ResponsePage appendQueryParam(String aParamName, String aParamValue)
This method returns a new ResponsePage having the updated URL. (This will ensure that ResponsePage objects are immutable.)
This method uses WebUtil.setQueryParam(java.lang.String, java.lang.String, java.lang.String)
.
public boolean equals(Object aThat)
equals
in class Object
public int hashCode()
hashCode
in class Object
|
Version 4.10.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |