|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.niggle.servlet.ServletInteraction
An abstract class that encapsulates the various paths of execution involved in fulfilling a servlet request. What is here is meant to be generic to the "typical" web app. Application-specific functionality will be supplied by concrete subclasses. Here are some additional notes about how to extend this class in your application.
Field Summary | |
protected java.lang.String |
action
name of the current action being executed by this ServletInteraction instance |
static java.lang.String |
ACTION_KEY
|
static java.lang.String |
ANON
|
NiggleConfig |
config
The information that contains the niggle servlet config info. |
static java.lang.String |
DEFAULT_TEMPLATE
|
static java.lang.String |
EXEC_PREFIX
|
protected boolean |
hasRedirected
Indicates whether we handled the request by redirecting. |
protected boolean |
isStaticResponse
If this variable is unset, the HTTP response will contain a hint that indicates not to cache the page. |
protected java.util.Locale |
locale
locale associated with this request |
protected Page |
page
The Page template object that we are working with. |
javax.servlet.http.HttpServletRequest |
request
|
javax.servlet.http.HttpServletResponse |
response
Our HTML response back to the user. |
protected javax.servlet.http.HttpSession |
session
Our session, assuming we have one, and we are using the servlet womb's default session-tracking scheme. |
static java.lang.String |
SESSION_ID_KEY
|
protected java.lang.String |
sessionID
The session ID. |
static java.lang.String |
USER_ID_KEY
|
protected java.lang.String |
userID
Login ID of the current user. |
Constructor Summary | |
ServletInteraction(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
NiggleConfig config)
|
Method Summary | |
protected boolean |
checkSessionInfo()
Method to call if a given action requires a valid session. |
protected boolean |
createNewSession()
Method that creates a new session. |
protected void |
deduceAction()
A hook that you might want to override if you want to change the default scheme for how we decide what the current action is. |
protected void |
deduceLocale()
A hook that you might want to override if you want to be more sophisticated about how you decide what the preferred locale for the request is. |
protected void |
deduceSessionInfo()
A hook that you might want to override if you want to change the default scheme for session tracking. |
protected void |
dispatch()
Dispatches the request based on the action This actually delegates to the NiggleConfig object that does some reflective magic to invoke the method this.execFoo() for action "foo". |
void |
execDefault()
A default handler that simply displays the default template, index.nhtml. |
protected void |
exposeActionURL(java.lang.String action)
a convenience for exposing the URL corresponding to an action on the page. |
protected void |
exposeDefaultVariables()
A hook that can be overridden to make sure that certain top-level template variables get exposed. |
void |
fillInFields(Record rec)
Given a record, attempts to fill in the record's fields based on the information in the servlet request. |
OreoDataSource |
getDataSource(java.lang.String name)
convenient wrapper to get a data source by name. |
java.util.Locale |
getLocale()
|
Record |
getNewRecord(java.lang.String type)
convenient wrapper to get a record exemplar data source by name. |
protected Page |
getPage(java.lang.String template)
|
java.lang.String |
getParameter(java.lang.String s)
Check for presence of data field in CGI input. |
static ServletInteraction |
getServletInteraction()
|
java.lang.String |
getURL(java.lang.String action)
Builds the URL that corresponds to a given action. |
static boolean |
hasContent(java.lang.String s)
check for empty strings. |
boolean |
hasParameter(java.lang.String param)
|
protected boolean |
hasSession()
Indicates whether we have a session. |
protected boolean |
hasValidLoginInfo()
Override this method to check whether the servlet request has the info for a login (thus allowing us to create a new session). |
protected java.lang.String |
methodNameFromAction(java.lang.String action)
Override this if you want to change the default execXXX naming scheme. |
protected void |
navigationError()
A convenient method to override if you want to handle this kind of condition more gracefully. |
java.lang.String |
newTransaction(java.lang.String dsName,
java.lang.String lookupName)
convenient wrapper that returns a unique transaction ID for transactions against a datasource that span multiple requests. |
protected void |
output()
Finally output the page as a result of a servlet interaction |
protected void |
recover(java.io.IOException e)
override this method to provide some default exception handling for when an execXXX method fails for whatever reason. |
protected void |
redirectAction(java.lang.String action)
redirects the browser to the URL corresponding to a given action. |
protected void |
reexposeServletParams()
A convenience method to expose all of the servlet request's parameters as template variables |
protected void |
unauthorized()
Override this method to handle this condition more gracefully. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public final javax.servlet.http.HttpServletRequest request
public final javax.servlet.http.HttpServletResponse response
public final NiggleConfig config
protected javax.servlet.http.HttpSession session
protected java.lang.String sessionID
protected java.lang.String userID
protected java.util.Locale locale
protected java.lang.String action
protected Page page
protected boolean hasRedirected
protected boolean isStaticResponse
public static final java.lang.String ACTION_KEY
public static final java.lang.String SESSION_ID_KEY
public static final java.lang.String USER_ID_KEY
public static final java.lang.String EXEC_PREFIX
public static final java.lang.String DEFAULT_TEMPLATE
public static final java.lang.String ANON
Constructor Detail |
public ServletInteraction(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, NiggleConfig config) throws java.io.IOException
Method Detail |
public static ServletInteraction getServletInteraction()
protected void deduceLocale()
protected void deduceAction()
getURL(java.lang.String)
protected void deduceSessionInfo()
protected java.lang.String methodNameFromAction(java.lang.String action)
public final java.util.Locale getLocale()
public java.lang.String getURL(java.lang.String action)
public java.lang.String getParameter(java.lang.String s)
public boolean hasParameter(java.lang.String param)
public static boolean hasContent(java.lang.String s)
protected void output() throws java.io.IOException
java.io.IOException
protected boolean createNewSession() throws java.io.IOException
java.io.IOException
protected boolean checkSessionInfo() throws java.io.IOException
java.io.IOException
protected void exposeDefaultVariables() throws java.io.IOException
java.io.IOException
protected void unauthorized() throws java.io.IOException
java.io.IOException
protected void navigationError() throws java.io.IOException
java.io.IOException
public void execDefault() throws java.io.IOException
java.io.IOException
protected Page getPage(java.lang.String template) throws java.io.IOException
java.io.IOException
protected boolean hasSession()
protected void redirectAction(java.lang.String action) throws java.io.IOException
java.io.IOException
protected void reexposeServletParams()
protected void exposeActionURL(java.lang.String action)
protected boolean hasValidLoginInfo() throws java.io.IOException
java.io.IOException
protected void dispatch() throws java.io.IOException, javax.servlet.ServletException
java.io.IOException
javax.servlet.ServletException
protected void recover(java.io.IOException e) throws java.io.IOException
java.io.IOException
public OreoDataSource getDataSource(java.lang.String name) throws java.io.IOException
java.io.IOException
public java.lang.String newTransaction(java.lang.String dsName, java.lang.String lookupName) throws java.io.IOException
dsName
- the lookup name for the transactional data source we are working against.lookupName
- the name by which to store the txnID in the session context.
If this is null, we do not store it.
java.io.IOException
public Record getNewRecord(java.lang.String type) throws java.io.IOException
java.io.IOException
public void fillInFields(Record rec) throws java.io.IOException
rec
- the record to fill in.
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |