Documentation Archive Developer
Search
[an error occurred while processing this directive] PATH  Documentation > WebObjects 4.5 > WebObjects Reference

Table of Contents

WODirectAction


Inherits from: NSObject
Conforms to: NSObject
(NSObject)
Declared in: WebObjects/WODirectAction.h




Class Description


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 addig 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 raises an exception.




Method Types


Creation
- initWithRequest:
Obtaining attributes
- request
Obtaining a session
- existingSession
- session
Obtaining a page
- pageWithName:
Performing an action
- performActionNamed:
Value assignment
- takeFormValueArraysForKeyArray:
- takeFormValueArraysForKeys:
- takeFormValuesForKeyArray:
- takeFormValuesForKeys:
Debugging
- debugWithFormat:
- logWithFormat:


Instance Methods



debugWithFormat:

- (void)debugWithFormat:(NSString *)aFormatString,...

This method is similar to logWithFormat: except that you can control whether it displays output with the WODebuggingEnabled user default option. If WODebuggingEnabled is YES, then the debugWithFormat: messages display their output. If WODebuggingEnabled is NO, the debugWithFormat: messages don't display their output.

See Also: - debugWithFormat: ( - WOApplication)



existingSession

- (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 nil. To determine if a session failed to restore, check the request's session ID to see if it non-nil and if so, call this method to check its result.

See Also: - session



initWithRequest:

- initWithRequest:(WORequest *)aRequest

This is the designated initializer for all subclasses of WODirectAction. Whne you create a subclass, you must override this method to provide any additional initialization.

logWithFormat:

- (void)logWithFormat:(NSString *)aFormatString,...

Prints a message to the standard error device (stderr). The message can include formatted variable data using printf-style conversion specifiers, for example:
id i = 500;
id f = 2.045;
[self logWithFormat:@"Amount = %@, Rate = %@, Total = %@", i, f, i*f];

Note that in WebScript, all variables are objects, so the only conversion specifier allowed is %@ as shown above. In compiled Objective-C code, all printf conversion specifiers are allowed. The equivalent method in Java is logString.

See Also: - logWithFormat: ( - WOApplication)



pageWithName:

- (WOComponent *)pageWithName:(NSString *)aComponentName

Returns the WOComponent with the specified name.

performActionNamed:

- (id <WOActionResults>)performActionNamed:(NSString *)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.

request

- (WORequest *)request

Returns the WORequest object that initiated the action.

session

- (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 raises an exception.

See Also: - existingSession



takeFormValueArraysForKeyArray:

- (void)takeFormValueArraysForKeyArray:(NSArray *)aKeyArray

Performs takeValue:forKey: 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:.

See Also: takeFormValueArraysForKeys:



takeFormValueArraysForKeys:

- (void)takeFormValueArraysForKeys:(NSString *)aFirstKey,...

Performs takeValue:forKey: on the specified keys using values from the receiver's request. The last key must be nil.

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 takeFormValuesForKeys:.

See Also: takeFormValueArraysForKeyArray:



takeFormValuesForKeyArray:

- (void)takeFormValuesForKeyArray:(NSArray *)aKeyArray

Performs takeValue:forKey: 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:.

See Also: takeFormValuesForKeys:



takeFormValuesForKeys:

- (void)takeFormValuesForKeys:(NSString *)aFirstKey,...

Performs takeValue:forKey: on the specified keys using values from the receiver's request. The last key must be nil.

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 takeFormValueArraysForKeys:.

See Also: takeFormValuesForKeyArray:




Table of Contents