public class ResponseHelper extends Object
Modifier | Constructor and Description |
---|---|
protected |
ResponseHelper(javax.servlet.ServletContext context,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
net.sf.serfj.UrlInfo urlInfo,
String viewsPath)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
doResponse() |
protected void |
forward() |
javax.servlet.ServletContext |
getContext()
Gets
ServletContext object related to this request. |
String |
getExtension()
Gets the URL extension, if any.
|
String |
getId()
Gets the value of an Id for the current resource.
/sessions/1 -> Id: 1, identifier of 'session' /sessions/1/users/2 -> Id: 2, identifier of 'users' |
String |
getId(String resource)
Gets the value of an Id given its resource's name.
/sessions/1 -> Id: 1, Resource: session /sessions/1/users/2 -> Id: 2, Resource: user |
Object |
getParam(String name)
Gets a the value of a parameter that came in the URL or in the request.
|
Map<String,Object> |
getParams()
Gets a Map containing all the parameters in the query string, and all the
attributes in the request.
|
javax.servlet.http.HttpServletRequest |
getRequest()
Gets
HttpServletRequest object related to this request. |
javax.servlet.http.HttpServletResponse |
getResponse()
Gets
HttpServletResponse object related to this request. |
String |
getSerializer()
Gets the Serializer class, if any.
|
void |
notRenderPage(Method method)
If the method is annotated with
DoNotRenderPage , marks the response
as not to render any page. |
void |
renderPage()
Renders the predefined page.
|
void |
renderPage(String page)
Renders some page within 'views' directory.
|
void |
renderPage(String resource,
String page)
Renders a page from a resource.
|
protected void |
sendFile() |
protected void |
serialize() |
void |
serialize(Object object)
Serialize an object.
|
void |
setAttachmentFilename(String filename)
Sets the filename for the file that will be sent.
|
void |
setContentType(String contentType)
Sets the contentType in case there isn't another FileSerializer implementation.
|
void |
setFile(File file)
Sets the file to send to the client.
|
void |
setFile(File file,
String attachmentFilename,
String contentType)
Sets the file to send to the client.
|
protected void |
writeFile(FileSerializer serializer) |
protected void |
writeObject(String contentType,
String serialized) |
protected ResponseHelper(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, net.sf.serfj.UrlInfo urlInfo, String viewsPath)
public javax.servlet.http.HttpServletResponse getResponse()
HttpServletResponse
object related to this request.public javax.servlet.http.HttpServletRequest getRequest()
HttpServletRequest
object related to this request.public javax.servlet.ServletContext getContext()
ServletContext
object related to this request.public void notRenderPage(Method method)
DoNotRenderPage
, marks the response
as not to render any page. If there isn't object to serialize in the
response and notRenderPage flag is set on, the framework will return a
HTTP status code 204 (No content), else a page will be rendered.method
- Method to inspect.public void renderPage() throws IOException
IOException
- if the page doesn't exist.public void renderPage(String page) throws IOException
page
- The page could have an extension or not. If it doesn't have an
extension, the framework first looks for page.jsp, then .html
or .htm extension.IOException
- if the page doesn't exist.public void renderPage(String resource, String page) throws IOException
resource
- The name of the resource (bank, account, etc...). It must
exists below /views directory.page
- The page can have an extension or not. If it doesn't have an
extension, the framework first looks for page.jsp, then with
.html or .htm extension.IOException
- if the page doesn't exist.public void serialize(Object object)
object
- Object to serialize.public void setFile(File file)
file
- The file.public void setAttachmentFilename(String filename)
filename
- File name.public void setContentType(String contentType)
contentType
- Content type for the response header.public void setFile(File file, String attachmentFilename, String contentType)
file
- The file.attachmentFilename
- Name for the file that will be sent.contentType
- Content type for the response header.public String getExtension()
public String getSerializer()
public Map<String,Object> getParams()
public Object getParam(String name)
public String getId()
public String getId(String resource)
protected void doResponse() throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
protected void serialize() throws IOException
IOException
protected void sendFile() throws IOException
IOException
protected void forward() throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
protected void writeObject(String contentType, String serialized) throws IOException
IOException
protected void writeFile(FileSerializer serializer) throws IOException
IOException
Copyright © 2012 ElPaso Software. All Rights Reserved.