Forum OpenACS Development: Symbolic names instead of return_url

Collapse
Posted by Lee Denison on

I've been thinking about a feature of the Apache Struts framework that I like which might suggest a better alternative to using return_url everywhere.

Whenever a page performs some kind of action, allowing the referring page some way to specify where to go after the action makes things much more flexible. Hence return_url.

Struts recognises that each action can have more than one outcome, and that you might want to go to different pages depending on the outcome. The 'action' page specifies a symbolic name for each outcome and the referring page assigns a url to each symbolic name.

For example, a page which creates a document might have the following outcomes represented by symbolic names of the form <type>.<detail>:

  • cancel - the user cancelled the action
  • failure.permission - the user doesn't have permission
  • failure.locked - this folder is currently locked
  • success.set_permission - the document was created and the user selected to set permissions on the document before finishing
  • success.created - the document was created and the user is finished

The referring page can assign a default url for all outcomes, a default url for a type (cancel,failure,success) or a url for a specific outcome. The action page can also set local defaults.

Collapse
Posted by Don Baccus on
This could be implemented using the session variables feature of the core - a feature much underused by us IMO.
Collapse
Posted by Andrew Piskorski on
Don, you mean the ad get and set client_property procs?
Collapse
Posted by Joel Aufrecht on
Would somebody mind explaining how to use session variables for return_url and other properties?  I offer vocab::conn as probably an example of the Wrong Way.  It looks for passed-in variables, then checks cookies, then tries to get default values.  Could it also handle return_url so that I could simply use it in any page that called vocab::conn, without putting it in the page contract?

http://cvs.openacs.org/cvs/openacs-4/contrib/packages/vocabulary/tcl/util-procs.tcl?view=auto&rev=1.2

Collapse
Posted by Lee Denison on
I like the idea of using session variables although you do hit up against the problem that you need to tie the urls to a particular browser window, not just the users session.  What is the api in OACS to manage session variables?