org.opensubsystems.core.www
Class WebUIServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.opensubsystems.core.www.WebSessionServlet
              extended by org.opensubsystems.core.www.WebUIServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
WebUIDispatchServlet

public class WebUIServlet
extends WebSessionServlet

Base class for all servlets developed as part of this project, which perform web form processing or execute an action based on request from the user interface. It's main responsibility is to provide default implementation if functionality for form processing is required.

Version:
$Id: WebUIServlet.java,v 1.16 2007/02/20 04:12:15 bastafidli Exp $
Author:
Miro Halas
See Also:
Serialized Form
Code reviewer:
Miro Halas
Code reviewed:
1.9 2006/02/24 00:19:55 jlegeny

Field Summary
static java.lang.String DATA_ATTRIBUTE_REQUEST_PARAM
          Name of the generic attribute used to pass some data to the rendering page.
static java.lang.String FORCE_MAXIMIZE_PARAM
          Name of the attribute used to pass flag if the dialog has to be maximized.
static int FORM_COUNT_WEBUI
          Constants for number of forms recognized by this servlet
static java.lang.String FORM_NAME_REQUEST_PARAM
          Parameter used to identify form to be processed.
static int FORM_UNKNOWN_ID
          Constants for forms recognized by this servlet
static java.lang.String LOGGEDIN_REQUEST_PARAM
          Name of the attribute used to pass flag if the user is logged in.
protected  java.lang.String m_strMessageStyleSheet
          Style sheet used for message boxes if any.
static java.lang.String ORIGINAL_REQUEST_INFO_REQUEST_PARAM
          Name of the generic attribute used to pass some string representation of the current request to the message box page in case it wants to display some troubleshooting information.
static java.lang.String PAGE_TITLE_REQUEST_PARAM
          Name of the attribute used to pass page title to the rendering pages.
static java.lang.String WEBUI_MESSAGEBOX_PAGE
          Property used to specify page to display messages to user for example in case of error.
static java.lang.String WEBUI_MESSAGEBOX_STYLE_SHEET
          Property used to specify stylesheet used to display messages to user for example in case of error.
 
Fields inherited from class org.opensubsystems.core.www.WebSessionServlet
APPLICATION_SECURE, ATTACH_INTERNAL_SESSION_ID_URL_PARAM, DEFAULT_APPLICATION_SECURE, DEFAULT_LOGIN_SECURE, LOGIN_FORWARD_SESSION_PARAM, LOGIN_SECURE, m_scServletContext, m_sessionValidator, m_strHandshakeURL, s_bApplicationSecure, s_bLoginSecure, SERVLET_PATH_REQUEST_PARAM, SESSION_VALIDATOR_CLASS, WEBSESSION_DISPATCHER_CACHED, WEBSESSION_DISPATCHER_CACHED_DEFAULT, WEBSESSION_HADSHAKE_REQUIRED_DEFAULT, WEBSESSION_HANDSHAKE_REQUIRED, WEBSESSION_HANDSHAKE_URL, WEBSESSION_LOGIN_REQUIRED, WEBSESSION_LOGIN_REQUIRED_DEFAULT, WEBSESSION_LOGIN_URL
 
Constructor Summary
WebUIServlet()
           
 
Method Summary
protected  void cacheDispatcher(java.lang.String strUIID, java.lang.String strUIPath)
          Cache dispatcher to given resource if caching is possible.
protected  void cacheUIPath(javax.servlet.ServletConfig scConfig, java.lang.String strUIID, java.lang.String strErrorMessage)
          Cache path to portion of user interface by first search servlet configuration information and if not found then other predefined locations.
protected  void displayUI(java.lang.String strUIID, javax.servlet.http.HttpServletRequest hsrqRequest, javax.servlet.http.HttpServletResponse hsrpResponse)
          Get handle to resource responsible for rendering of specified part of UI
protected  int getFormToProcess(javax.servlet.http.HttpServletRequest hsrqRequest)
          Examine request and find out what form needs to be processed.
 java.lang.String getServletInfo()
          
 void init(javax.servlet.ServletConfig scConfig)
          
protected  void messageBoxPage(javax.servlet.http.HttpServletRequest hsrqRequest, javax.servlet.http.HttpServletResponse hsrpResponse, java.lang.String strPageTitle, java.lang.String strMessage, java.lang.String strProceedURL, java.lang.Throwable cause)
          Display page with a message to the user.
protected  void messageBoxPage(javax.servlet.http.HttpServletRequest hsrqRequest, javax.servlet.http.HttpServletResponse hsrpResponse, java.lang.String strPageTitle, java.lang.String strMessage, java.lang.String strProceedURL, java.lang.Throwable cause, java.lang.String strUIPage)
          Display page with a message to the user, when there was a file error.
protected  void preservice(javax.servlet.http.HttpSession hsSession, javax.servlet.http.HttpServletRequest hsrqRequest, javax.servlet.http.HttpServletResponse hsrpResponse, boolean bLoginVerified)
          This method gives derived servlets execute common logic which needs to be executed for each request.
protected  void setLoggedInFlag(javax.servlet.http.HttpServletRequest hsrqRequest, javax.servlet.http.HttpServletResponse hsrpResponse)
          If the user has logged in, this method will set necessary flag to mark the page that way.
 
Methods inherited from class org.opensubsystems.core.www.WebSessionServlet
destroy, getLoginRedirect, handleNewSession, isApplicationSecure, isDispatcherCachingEnabled, isLoginSecure, redirect, redirectToHandshake, redirectToLogin, resetLoginRedirect, saveLoginRedirect, service, shouldRequestBeSecure, verifyLogin
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WEBUI_MESSAGEBOX_PAGE

public static final java.lang.String WEBUI_MESSAGEBOX_PAGE
Property used to specify page to display messages to user for example in case of error.

See Also:
Constant Field Values

WEBUI_MESSAGEBOX_STYLE_SHEET

public static final java.lang.String WEBUI_MESSAGEBOX_STYLE_SHEET
Property used to specify stylesheet used to display messages to user for example in case of error.

See Also:
Constant Field Values

ORIGINAL_REQUEST_INFO_REQUEST_PARAM

public static final java.lang.String ORIGINAL_REQUEST_INFO_REQUEST_PARAM
Name of the generic attribute used to pass some string representation of the current request to the message box page in case it wants to display some troubleshooting information.

See Also:
Constant Field Values

DATA_ATTRIBUTE_REQUEST_PARAM

public static final java.lang.String DATA_ATTRIBUTE_REQUEST_PARAM
Name of the generic attribute used to pass some data to the rendering page. Any aditional data can be passed in attributed named "databean2", "databean3", etc.

See Also:
Constant Field Values

PAGE_TITLE_REQUEST_PARAM

public static final java.lang.String PAGE_TITLE_REQUEST_PARAM
Name of the attribute used to pass page title to the rendering pages.

See Also:
Constant Field Values

LOGGEDIN_REQUEST_PARAM

public static final java.lang.String LOGGEDIN_REQUEST_PARAM
Name of the attribute used to pass flag if the user is logged in.

See Also:
Constant Field Values

FORCE_MAXIMIZE_PARAM

public static final java.lang.String FORCE_MAXIMIZE_PARAM
Name of the attribute used to pass flag if the dialog has to be maximized.

See Also:
Constant Field Values

FORM_NAME_REQUEST_PARAM

public static final java.lang.String FORM_NAME_REQUEST_PARAM
Parameter used to identify form to be processed.

See Also:
FORM_UNKNOWN_ID, getFormToProcess(javax.servlet.http.HttpServletRequest), Constant Field Values

FORM_UNKNOWN_ID

public static final int FORM_UNKNOWN_ID
Constants for forms recognized by this servlet

See Also:
FORM_NAME_REQUEST_PARAM, getFormToProcess(javax.servlet.http.HttpServletRequest), Constant Field Values

FORM_COUNT_WEBUI

public static final int FORM_COUNT_WEBUI
Constants for number of forms recognized by this servlet

See Also:
Constant Field Values

m_strMessageStyleSheet

protected java.lang.String m_strMessageStyleSheet
Style sheet used for message boxes if any.

Constructor Detail

WebUIServlet

public WebUIServlet()
Method Detail

init

public void init(javax.servlet.ServletConfig scConfig)
          throws javax.servlet.ServletException

Specified by:
init in interface javax.servlet.Servlet
Overrides:
init in class WebSessionServlet
Throws:
javax.servlet.ServletException

getServletInfo

public java.lang.String getServletInfo()

Specified by:
getServletInfo in interface javax.servlet.Servlet
Overrides:
getServletInfo in class WebSessionServlet

preservice

protected void preservice(javax.servlet.http.HttpSession hsSession,
                          javax.servlet.http.HttpServletRequest hsrqRequest,
                          javax.servlet.http.HttpServletResponse hsrpResponse,
                          boolean bLoginVerified)
                   throws javax.servlet.ServletException,
                          java.io.IOException
This method gives derived servlets execute common logic which needs to be executed for each request. It is executed right before the service itself once handshake was established (if required), login was verified (if required) and identity of user if one is logged in was established. It can also be called if login is required and we are redirecting to the login page.

Overrides:
preservice in class WebSessionServlet
Parameters:
hsSession - - HTTP session object
hsrqRequest - - the servlet request.
hsrpResponse - - the servlet response.
bLoginVerified - - true if login was verified or it is not required, false if we are redirecting to the login page
Throws:
javax.servlet.ServletException - - problems redirecting to login
java.io.IOException - - problems redirecting to login

cacheUIPath

protected final void cacheUIPath(javax.servlet.ServletConfig scConfig,
                                 java.lang.String strUIID,
                                 java.lang.String strErrorMessage)
                          throws javax.servlet.ServletException
Cache path to portion of user interface by first search servlet configuration information and if not found then other predefined locations.

Parameters:
scConfig - - servlet config to read parameters from
strUIID - - unique ID of the configuration parameter used to specify user interface which is URL or path to some kind of rendering page (e.g. JSP page)
strErrorMessage - - error message to display if the path doesn't exist
Throws:
javax.servlet.ServletException - - problem finding the specified UI

cacheDispatcher

protected final void cacheDispatcher(java.lang.String strUIID,
                                     java.lang.String strUIPath)
                              throws javax.servlet.ServletException
Cache dispatcher to given resource if caching is possible.

Parameters:
strUIID - - unique ID of the configuration parameter used to specify this UI
strUIPath - - path to given resource
Throws:
javax.servlet.ServletException - - problem finding the specified UI

displayUI

protected final void displayUI(java.lang.String strUIID,
                               javax.servlet.http.HttpServletRequest hsrqRequest,
                               javax.servlet.http.HttpServletResponse hsrpResponse)
                        throws javax.servlet.ServletException,
                               java.io.IOException
Get handle to resource responsible for rendering of specified part of UI

Parameters:
strUIID - - unique ID of the configuration parameter used to specify UI to display. This is the same ID previously passed into cacheUIPath method.
hsrqRequest - - the servlet request.
hsrpResponse - - the servlet response.
Throws:
javax.servlet.ServletException - - problems displaying UI
java.io.IOException - - problems displaying UI

setLoggedInFlag

protected void setLoggedInFlag(javax.servlet.http.HttpServletRequest hsrqRequest,
                               javax.servlet.http.HttpServletResponse hsrpResponse)
If the user has logged in, this method will set necessary flag to mark the page that way. User is logged in if the session exists and user name is set as session attribute. If user is not logged in, the flag will be set to the flag to false.

Parameters:
hsrqRequest - - the servlet request.
hsrpResponse - - the servlet response.

messageBoxPage

protected void messageBoxPage(javax.servlet.http.HttpServletRequest hsrqRequest,
                              javax.servlet.http.HttpServletResponse hsrpResponse,
                              java.lang.String strPageTitle,
                              java.lang.String strMessage,
                              java.lang.String strProceedURL,
                              java.lang.Throwable cause)
                       throws java.io.IOException,
                              javax.servlet.ServletException
Display page with a message to the user.

Parameters:
hsrqRequest - - the servlet request.
hsrpResponse - - the servlet response.
strPageTitle - - title of the message box
strMessage - - message to display in the message box
strProceedURL - - what URL to proceed to
cause - - what was the cause of the problem if any
Throws:
javax.servlet.ServletException - - an error has occured while displaying message box
java.io.IOException - - error writing response

messageBoxPage

protected void messageBoxPage(javax.servlet.http.HttpServletRequest hsrqRequest,
                              javax.servlet.http.HttpServletResponse hsrpResponse,
                              java.lang.String strPageTitle,
                              java.lang.String strMessage,
                              java.lang.String strProceedURL,
                              java.lang.Throwable cause,
                              java.lang.String strUIPage)
                       throws java.io.IOException,
                              javax.servlet.ServletException
Display page with a message to the user, when there was a file error.

Parameters:
hsrqRequest - - the servlet request.
hsrpResponse - - the servlet response.
strPageTitle - - title of the message box
strMessage - - message to display in the file message box
strProceedURL - - what URL to proceed to
cause - - what was the cause of the problem if any
strUIPage - -
Throws:
javax.servlet.ServletException - - an error has occured while displaying file message box
java.io.IOException - - error writing response

getFormToProcess

protected int getFormToProcess(javax.servlet.http.HttpServletRequest hsrqRequest)
Examine request and find out what form needs to be processed. Unique number assigned to the form will be returned

Parameters:
hsrqRequest - - the servlet request, which is used to find out what form needs to be processed
Returns:
int - one of the FORM_XXX constants


Copyright © 2003 - 2006 OpenSubsystems s.r.o.