pl.aislib.fm
Class Page

java.lang.Object
  extended bypl.aislib.fm.Page
Direct Known Subclasses:
StaticPage

public abstract class Page
extends java.lang.Object

Abstract class representing one page of application.

Since:
AISLIB 0.1
Version:
$Revision: 1.6 $
Author:
Tomasz Pik, AIS.PL
Michal Jastak, AIS.PL

Field Summary
protected  Application application
          Contains Application description to which this Page belongs.
protected  org.apache.commons.logging.Log log
          Contains Logging Component.
protected  PageInfo pageInfo
          Contains additional information about this Page.
protected  java.util.Map properties
          Map of properties of the page.
protected  javax.servlet.http.HttpServletRequest request
          Contains HTTP request description.
protected  javax.servlet.http.HttpServletResponse response
          Contains HTTP response description.
protected  javax.servlet.http.HttpServlet servlet
          Contains Servlet description, part of which is this Page.
protected  javax.servlet.http.HttpSession session
          HTTP Session object describing session corresponding to current request.
 
Constructor Summary
Page()
           
 
Method Summary
protected  void cleanSession()
          Cleans all session objects associated with this application.
protected  java.lang.String getConfigParameter(java.lang.String paramName)
          Gets configuration parameter.
protected  Form getForm(java.lang.String formName)
          Gets form.
protected  Message getMessage(int messageCode)
          Gets message for given code.
protected  Page getPage(java.lang.String actionKey)
          Gets new Page object corresponding to given actionKey.
abstract  PageResponse getPageResponse()
          Method which every subclass of Page must implement.
protected  java.lang.String getParameter(java.lang.String paramName)
          Gets request parameter with a given name.
protected  java.lang.String[] getParameterValues(java.lang.String paramName)
          Gets request parameters with a given name.
 java.lang.Object getProperty(java.lang.String propertyName)
          Gets property with given name.
 java.lang.Object getProperty(java.lang.String propertyName, java.lang.Object defaultValue)
          Gets property with given name.
protected  java.lang.Object getRequestAttribute(java.lang.String attrName)
          Gets the request attribute for application.
protected  java.lang.Object getSessionAttribute(java.lang.String attrName)
          Gets session attribute for application.
protected  java.util.Iterator getSessionAttributeNames()
          Gets an Iterator of String objects containing the names of all the session objects of application.
protected  boolean hasImageParameter(java.lang.String paramName)
          Checks if there is a request parameter with given name.
protected  boolean hasParameter(java.lang.String paramName)
          Checks if there is a request parameter with given name.
 boolean hasProperty(java.lang.String propertyName)
          Check if a given property exists.
protected  boolean hasRequestAttribute(java.lang.String attrName)
          Check if there is a session attribute for the application.
protected  boolean hasSessionAttribute(java.lang.String attrName)
          Checks if there is a session attribute for application.
protected  java.lang.Object loadTemplate(java.lang.String templateName)
          Loads application-specific template using TemplateEngine object.
protected  void onLoad()
          Trigger method is called afer the initialization of the internal strucures for page instance (request, response, application).
 java.util.Iterator propertyNames()
          Gets names of properties of the page.
protected  void removeRequestAttribute(java.lang.String attrName)
          Removes the session attribute for application.
protected  void removeSessionAttribute(java.lang.String attrName)
          Removes session attribute for the application.
protected  void setRequestAttribute(java.lang.String attrName, java.lang.Object attrValue)
          Sets the request attribute for application.
protected  void setSessionAttribute(java.lang.String attrName, java.lang.Object attrValue)
          Sets session attribute for the application.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

session

protected javax.servlet.http.HttpSession session
HTTP Session object describing session corresponding to current request.


request

protected javax.servlet.http.HttpServletRequest request
Contains HTTP request description.


response

protected javax.servlet.http.HttpServletResponse response
Contains HTTP response description.


servlet

protected javax.servlet.http.HttpServlet servlet
Contains Servlet description, part of which is this Page.


pageInfo

protected PageInfo pageInfo
Contains additional information about this Page.


application

protected Application application
Contains Application description to which this Page belongs.


log

protected org.apache.commons.logging.Log log
Contains Logging Component.


properties

protected java.util.Map properties
Map of properties of the page.

Constructor Detail

Page

public Page()
Method Detail

getPageResponse

public abstract PageResponse getPageResponse()
                                      throws java.io.IOException,
                                             javax.servlet.ServletException
Method which every subclass of Page must implement.

Returns:
PageResponse or null if the given Page handles request internally.
Throws:
javax.servlet.ServletException - in case of invalid execution.
java.io.IOException - in case of I/O errors.

getProperty

public java.lang.Object getProperty(java.lang.String propertyName)
Gets property with given name.

Parameters:
propertyName - name of a property.
Returns:
the property or null if it does not exist.

getProperty

public java.lang.Object getProperty(java.lang.String propertyName,
                                    java.lang.Object defaultValue)
Gets property with given name.

Parameters:
propertyName - name of a property.
defaultValue - default value for the property.
Returns:
the property.

hasProperty

public boolean hasProperty(java.lang.String propertyName)
Check if a given property exists.

Parameters:
propertyName - name of the property.
Returns:
true if the property exists, false otherwise.

propertyNames

public java.util.Iterator propertyNames()
Gets names of properties of the page.

Returns:
Iterator object.

getParameter

protected java.lang.String getParameter(java.lang.String paramName)
Gets request parameter with a given name.

Parameters:
paramName - name of request parameter.
Returns:
parameter value if the parameter exists, null otherwise.
See Also:
ServletRequest.getParameter(java.lang.String)

getParameterValues

protected java.lang.String[] getParameterValues(java.lang.String paramName)
Gets request parameters with a given name.

Parameters:
paramName - name of request parameter.
Returns:
array of string values of the parameter.
See Also:
ServletRequest.getParameterValues(java.lang.String)

hasParameter

protected boolean hasParameter(java.lang.String paramName)
Checks if there is a request parameter with given name.

Parameters:
paramName - name for requested parameter.
Returns:
true if the request contains the parameter, false otherwise.

hasImageParameter

protected boolean hasImageParameter(java.lang.String paramName)
Checks if there is a request parameter with given name.

Parameters:
paramName - name for requested parameter.
Returns:
true if the request contains parameter with the given name or the given name with .x or .y suffix, false otherwise.

onLoad

protected void onLoad()
Trigger method is called afer the initialization of the internal strucures for page instance (request, response, application). Subclasses may owerride this method for their own use.


getSessionAttribute

protected java.lang.Object getSessionAttribute(java.lang.String attrName)
Gets session attribute for application.

Parameters:
attrName - name for an attribute.
Returns:
session attribute or null.

hasSessionAttribute

protected boolean hasSessionAttribute(java.lang.String attrName)
Checks if there is a session attribute for application.

Parameters:
attrName - name of the attribute.
Returns:
true if there is an attribute with the given key, false otherwise.

removeSessionAttribute

protected void removeSessionAttribute(java.lang.String attrName)
Removes session attribute for the application.

Parameters:
attrName - attribute name to remove.

setSessionAttribute

protected void setSessionAttribute(java.lang.String attrName,
                                   java.lang.Object attrValue)
Sets session attribute for the application.

Parameters:
attrName - name of the attribute.
attrValue - value of the attribute.

getSessionAttributeNames

protected java.util.Iterator getSessionAttributeNames()
Gets an Iterator of String objects containing the names of all the session objects of application.

Returns:
Iterator object.

cleanSession

protected void cleanSession()
Cleans all session objects associated with this application.


getRequestAttribute

protected java.lang.Object getRequestAttribute(java.lang.String attrName)
Gets the request attribute for application.

Parameters:
attrName - name of the attribute for the application.
Returns:
attribute with the name or null.

hasRequestAttribute

protected boolean hasRequestAttribute(java.lang.String attrName)
Check if there is a session attribute for the application.

Parameters:
attrName - name of the attribute for the application.
Returns:
true if there is an attribute with the given key, false otherwise.

removeRequestAttribute

protected void removeRequestAttribute(java.lang.String attrName)
Removes the session attribute for application.

Parameters:
attrName - name of the attribute to remove.

setRequestAttribute

protected void setRequestAttribute(java.lang.String attrName,
                                   java.lang.Object attrValue)
Sets the request attribute for application.

Parameters:
attrName - name of the attribute.
attrValue - value of the attribute.

getConfigParameter

protected java.lang.String getConfigParameter(java.lang.String paramName)
Gets configuration parameter.

Parameters:
paramName - name of the parameter.
Returns:
value of the parameter.

loadTemplate

protected java.lang.Object loadTemplate(java.lang.String templateName)
                                 throws java.io.IOException,
                                        javax.servlet.ServletException
Loads application-specific template using TemplateEngine object.

Parameters:
templateName - TemplateEngine-specific template name.
Returns:
template or null.
Throws:
java.io.IOException - if an error occurs while loading.
javax.servlet.ServletException - if an error occurs while loading.

getPage

protected Page getPage(java.lang.String actionKey)
                throws javax.servlet.ServletException
Gets new Page object corresponding to given actionKey.

Parameters:
actionKey - action key describing which Page Object should be created.
Returns:
initialized Page object or null if Page cannot be found.
Throws:
javax.servlet.ServletException - if an error occurs.

getMessage

protected Message getMessage(int messageCode)
Gets message for given code.

Parameters:
messageCode - identification code for the message.
Returns:
message with specified language content.
See Also:
Application.getMessage(int, String)

getForm

protected Form getForm(java.lang.String formName)
Gets form.

Parameters:
formName - name of the form.
Returns:
the form.


Copyright © 2002-2005 AIS.PL. All Rights Reserved.