Each direction action is called by the performActionNamed method that
takes a String argument, so you can have dynamic whatever you want.
Your dynamic actions are just Strings and you can store them in the
db along with other metadata and write your own custom logic to do
whatever you want wit those Srting "actions".
For example, here is a simple subclass of WODirectAction that
interprets the "action name" as a page name, creates the page and
pushes query dictionaries into those pages if they implement a
specific interface. Note there is only one method taking a String
param and because I never call super, WO never creates a method name
for the String to invoke a method using reflection:
import com.webobjects.appserver.WOActionResults;
import com.webobjects.appserver.WOComponent;
import com.webobjects.appserver.WODirectAction;
import com.webobjects.appserver.WORequest;
/**
* @author kieran
*
*/
public class Show extends WODirectAction {
private static final org.apache.log4j.Logger log =
org.apache.log4j.Logger
.getLogger(Show.class);
/**
* @param aRequest
*/
public Show(WORequest aRequest) {
super(aRequest);
}
/**
* @see com.webobjects.appserver.WODirectAction#performActionNamed
(java.lang.String)
* @override we override this to actually return pages named 'name'
instead of the usual
* behavior of this method which is to determine a action method
name by adding 'Action'
* and invoking through reflection
* Now we can have URLs like
* /wa/Show/MyPage?oid=2345
* Inspired by a Pierce Wetter tip.
* We also pull all the form values and stuff them into the target
component
* if it implements the RailsBehaviour interface
*/
public WOActionResults performActionNamed(String name){
// Create the page
WOComponent page = pageWithName(name);
if (page instanceof RailsBehaviour && request().formValues() !=
null && request().formValues().count() > 0){
((RailsBehaviour)page).takeValuesFromDictionary(request
().formValues());
}
return page;
}
}
On May 4, 2007, at 5:56 AM, Daniele Corti wrote:
Hi list,
A simple question: is there a way to generate Dynamic Direct
Actions?
I mean, I'm thinking about an application really simple: menu
with links, generated by a worepetition, but I wish to use only
directActions (for indexing, don't make me begin...), so I thought,
there's a way to dynamically add a Direct Action to an app, this is
usefull, if i'll add a backend for adding new links!
ah, of course direct action simply call
public WoActionResult homePageAction(){
return pageWithName("HomePage");
}
not strange things ;-)
thank you for any help,
--
Daniele Corti
AIM: S0CR4TE5
Messenger: [EMAIL PROTECTED]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/kieran_lists%
40mac.com
This email sent to [EMAIL PROTECTED]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]