|
WebObjects 5.4.2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.webobjects.appserver.WOAction com.webobjects.appserver.WODirectAction
public class WODirectAction
WODirectAction is an abstract class that defines the interface for direct action classes. You subclass WODirectAction to provide an object that is a repository for action methods.
WODirectAction provides the simplest interface for adding logic and custom
code to your WebObjects application. WODirectAction objects are instantiated
when a URL requested by a client browser is sent to the WebObjects
application. The WODirectActionRequestHandler
determines the proper class
and action to be invoked and then passes control to the WODirectAction
subclass.
In contrast to a WOComponent-based action, a direct action is well-defined
by the URL that invokes it. For example, the following URL will invoke the
method findEmployeeAction
on the subclass of WODirectAction called
Common:
http://localhost/cgi-bin/WebObjects/Myapp.woa/wa/Common/findEmployee
A subclass of WODirectAction is a repository for action methods. New
WebObjects applications contain a default implementation of WODirectAction
subclass called DirectAction
. The DirectAction class is used when no class is
specified in the URL.
In summary, here are some URLs and actions they invoke:
This URL... | Invokes this method... |
.../MyApp.woa/wa/ | defaultAction on class DirectAction |
.../MyApp.woa/wa/find | findAction on class DirectAction, if it exists, or defaultAction on class find otherwise |
.../MyApp.woa/wa/find/ | same as .../MyApp.woa/wa/find |
.../MyApp.woa/wa/Common/find | findAction on class Common |
.../MyApp.woa/wa/Common/ | CommonAction on class DirectAction, if it exists, or defaultAction on class Common otherwise |
WODirectActionRequestHandler only invokes methods on subclasses of WODirectAction. If the specified class or action doesn't exist, WODirectActionRequestHandler throws an exception.
To handle stale session IDs (e.g. session IDs stored in cookies, and those session IDs refer to expired sessions), make sure to do the following at the beginning of your direct action method:
public WOActionResults myAction() { if ( getSessionIDForRequest(request()) != null && existingSession() == null ) { // special behavior, like a returning a login page, e.g. return pageWithName("LoginPage"); } else { // whatever else you'd normally do here } }
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions |
---|
NSKeyValueCodingAdditions.DefaultImplementation, NSKeyValueCodingAdditions.Utility |
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSValidation |
---|
NSValidation.DefaultImplementation, NSValidation.Utility, NSValidation.ValidationException |
Field Summary | |
---|---|
static String |
actionText
String at the end of the WODirectAction name (i.e fetchMovieAction the actionText value is 'Action') |
Fields inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions |
---|
KeyPathSeparator |
Constructor Summary | |
---|---|
WODirectAction(WORequest aRequest)
Subclasses must override to provide any additional initialization. |
Method Summary | |
---|---|
WOActionResults |
defaultAction()
Returns a WOActionResults object that is the result of sending generateResponse() to the page named "Main". |
String |
getSessionIDForRequest(WORequest aRequest)
Returns the session ID, or null if one does not exist. |
WOActionResults |
performActionNamed(String anActionName)
Performs the action with the specified name and returns the result of that action. |
void |
takeFormValueArraysForKeyArray(NSArray aKeyArray)
Performs takeValueForKey on each key in aKeyArray using
values from the receiver's request. |
void |
takeFormValuesForKeyArray(NSArray aKeyArray)
Performs takeValueForKey on the each key in aKeyArray using
values from the receiver's request. |
Methods inherited from class com.webobjects.appserver.WOAction |
---|
canAccessFieldsDirectly, context, debugString, existingSession, handleQueryWithUnboundKey, handleTakeValueForUnboundKey, initializeRequestSessionIDInContext, languages, logString, pageWithName, request, session, setLanguages, takeValueForKey, takeValueForKeyPath, toString, unableToSetNullForKey, validateTakeValueForKeyPath, validateValueForKey, valueForKey, valueForKeyPath |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.webobjects.foundation.NSKeyValueCoding |
---|
takeValueForKey, valueForKey |
Methods inherited from interface com.webobjects.foundation.NSKeyValueCoding.ErrorHandling |
---|
handleQueryWithUnboundKey, handleTakeValueForUnboundKey, unableToSetNullForKey |
Methods inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions |
---|
takeValueForKeyPath, valueForKeyPath |
Methods inherited from interface com.webobjects.foundation.NSKeyValueCoding |
---|
takeValueForKey, valueForKey |
Methods inherited from interface com.webobjects.foundation.NSValidation |
---|
validateTakeValueForKeyPath, validateValueForKey |
Field Detail |
---|
public static final String actionText
Constructor Detail |
---|
public WODirectAction(WORequest aRequest)
aRequest
- the request to be processedMethod Detail |
---|
public String getSessionIDForRequest(WORequest aRequest)
null
if one does not exist.
Searchs for aRequest
's session ID, first in the form values,
then in the cookies.
getSessionIDForRequest
in class WOAction
aRequest
- the request being handled
null
public WOActionResults defaultAction()
generateResponse()
to the page named "Main".
public WOActionResults performActionNamed(String anActionName)
anActionName
and tries to invoke the resulting method name.
Override this method to change how actions are dispatched.
performActionNamed
in class WOAction
anActionName
- name of the action
public void takeFormValueArraysForKeyArray(NSArray aKeyArray)
takeValueForKey
on each key in aKeyArray
using
values from the receiver's request.
This method uses an NSArray for each form value. This is useful
when a user can select multiple items for a form value, such as
a WOBrowser. If a form value contains only one item, this method
uses an NSArray with one object. To use single objects as form
values use takeFormValuesForKeyArray
.
aKeyArray
- an array of keysWOAction.takeValueForKey(Object value, String key)
,
WODirectAction.takeFormValuesForKeyArray(NSArray aKeyArray)
public void takeFormValuesForKeyArray(NSArray aKeyArray)
takeValueForKey
on the each key in aKeyArray
using
values from the receiver's request.
This method uses an a single object for each form value. If a form
value contains more than one item, such as a WOBrowser, this method
uses the first item in the array. To use arrays of objects as form
values, use takeFormValueArraysForKeyArray
.
aKeyArray
- an array of keysWOAction.takeValueForKey(Object value, String key)
,
WODirectAction.takeFormValueArraysForKeyArray(NSArray aKeyArray)
|
Last updated June 2008 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |