Direct Actions are action methods that can be called without a WOSession. As opposed to Component Actions, where a WOSession is required and various form values are bound as objects, Direct Actions perform much more like traditional web frameworks where the form values are accessed via WORequest's formValues dictionary and cookies. Direct Actions are very useful for building stateless, high-performing websites, though you lose some of the easy-of-development that makes WebObjects provides with Component Actions.
Direct Actions would also be good to use if you don't need the additional convenience of the Component Actions, simply because they come without any of its disadvantages. However, it's quite difficult to create a whole WO application without creating a WOSession and most of the time, you're going to need it anyway.
David LeBer's Articles
David LeBer has a great series of articles on using Direct Actions:
- Using WebObjects DirectActions pt. 1
- Using WebObjects DirectActions pt. 2
- Calling a DirectAction with values from a form
- Calling a DirectAction with values from a WOHyperlink
- Calling a DirectAction with values from a WORedirect
This page is a place to put notes and tips you've found useful when using direct actions.
- For a quick tour using direct actions see (on Mac OS X, WO 5.x): /Developer/Examples/JavaWebObjects/ThinkMovies
- When using direct actions in conjunction with a form that contains WOText or textarea elements you'll have to remove any \r\n (soft returns) that are sent back from the client yourself. In a component action page the WOText element takes care of this for you, but when you pull the value from the request's form values yourself you need to handle the soft returns on your own. You should likely just convert them to \n.