PATH |
Inherits from: Object
Implements: NSKeyValueCodingNSKeyValueCoding.ErrorHandlingNSKeyValueCodingAdditionsNSValidation
Package: com.webobjects.appserver
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 your WebObjects application. The WODirectActionRequestHandler determines the proper class and action to be invoked and then passes control to your 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 WODirectAtion 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 the WODirectAction subclass called DirectAction. The DirectAction class is used when no class is specified in the URL.
In summary, here are some URLs and the actions they invoke:
This URL... | Invokes this method... |
../MyApp.woa/wa/ | defaultAction on class DirectAction |
../MyApp.woa/wa/ find | findAction on classDirectAction , if it exists defaultAction on class find , otherwise |
../MyApp.woa/wa/Common/find | findAction on class Common |
WODirectActionRequestHandler invokes methods only on subclasses on WODirectAction. If the specified class or action doesn't exist, WODirectActionRequestHandler throws an exception.
NSKeyValueCoding takeValueForKeyvalueForKeyNSKeyValueCodingAdditions takeValueForKeyPathvalueForKeyPathNSKeyValueCoding.ErrorHandling handleQueryWithUnboundKeyhandleTakeValueForUnboundKeyunableToSetNullForKeyNSValidation validateTakeValueForKeyPathvalidateValueForKey
ConstructorsWODirectActionObtaining attributescanAccessFieldsDirectlyrequestObtaining a contextcontextObtaining a sessionexistingSessionsessionObtaining a pagepageWithNamePerforming an actionperformActionNamedValue assignmenttakeFormValueArraysForKeyArraytakeFormValuesForKeyArrayDebuggingdebugStringlogStringOtherdefaultAction
public WODirectAction(WORequest aWORequest)
Subclasses must override to provide any additional initialization.
public static boolean canAccessFieldsDirectly()
WODirectAction's implementation of this static method returns true
, indicating that key/value coding is allowed to access fields in this object if an appropriate method isn't present.
public static void debugString(String aString)
This method is similar to logString except that you can control whether it displays output with the WODebuggingEnabled user default option. If WODebuggingEnabled is true, then the debugString messages display their output. If WODebuggingEnabled is false, the debugString messages don't display their output.
public static void logString(String aString)
Prints a message to the standard error device (stderr). The message can include formatted variable data using String's concatenation feature, for example:
int i = 500; float f = 2.045; WOComponent.logString("Amount = " + i + ", Rate = " + f ", Total = " + i*f);
public WOContext context()
Returns the WODirectAction's context.
public WOActionResults defaultAction()
Returns a WOActionResults object that is the result of sending generateResponse() to the page named "Main".
public WOSession existingSession()
Restores the session based on the request. If the request did not have a session ID or the session ID referred to a non-existent session, then this method returns null. To determine if a session failed to restore, check the request's session ID to see if it non-null and if so, call this method to check its result.
See Also: session
public Object handleQueryWithUnboundKey(String key)
Conformance to NSKeyValueCoding.ErrorHandling.
public void handleTakeValueForUnboundKey(Object value, String key)
Conformance to NSKeyValueCoding.ErrorHandling.
public WOComponent pageWithName(String aComponentName)
Returns the WOComponent with the specified name.
public WOActionResults performActionNamed(String anActionName)
Performs the action with the specified name and returns the result of that action. The default implementation appends "Action" to anActionName and tries to invoke resulting method name. Override this method to change how actions are dispatched.
public WORequest request()
Returns the WORequest object that initiated the action.
public WOSession session()
Returns the current session. If there is no session, this method first tries to restore the session that the request's session ID refers to. If the request has no session ID-which is a possibility if the application is written entirely with direct actions-this method creates a new session and returns it. If the session ID refers to a session that doesn't exist or cannot be restored, this method throws an exception.
See Also: existingSession
public void takeFormValueArraysForKeyArray(NSArray aKeyArray)
Performs 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.
public void takeFormValuesForKeyArray(NSArray aKeyArray)
Performs 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.
public void takeValueForKey(Object value, String key)
Conformance to NSKeyValueCoding.
public void takeValueForKeyPath(Object value, String keyPath)
Conformance to NSKeyValueCodingAdditions.
public String toString()
Returns a String containing a string representation of the receiver.
public void unableToSetNullForKey(String key)
Conformance to NSKeyValueCoding.ErrorHandling.
public Object validateTakeValueForKeyPath( Object value, String keyPath) throws NSValidation.ValidationException
Conformance to NSValidation.
public Object validateValueForKey( Object value, String key) throws NSValidation.ValidationException
Conformance to NSValidation.
public Object valueForKey(String key)
Conformance to NSKeyValueCoding.
public Object valueForKeyPath(String keyPath)
Conformance to NSKeyValueCodingAdditions.
© 2001 Apple Computer, Inc. (Last Published April 15, 2001)