DirectAction Creation On The Fly
DirectAction Creation On The Fly
- Subject: DirectAction Creation On The Fly
- From: "Jonathan Fleming" <email@hidden>
- Date: Thu, 21 Oct 2004 13:10:45 +0100
Is it possible to create a direct action on the fly? Probably yes which'll
mean I'm doing things back to front as usual.
At the moment anytime the user wants to add a navigational page to their app
I have to do it by adding the directAction and then rebuild the app so they
can then use it but this defeats the purpose of object orientation doesn't
it?
What I have managed so far, is to create one directAction called navPage_
and I was hoping I could then do a database find to get the name of the page
it should pull out and show, only I'm stuck on finding a way to get that
name in to or out of the request - any ideas.
Here's what I am trying to do so far:
In the direct action I have a programmatic find and what I have been trying
to do is send in a url similar to this:
http://silver-back/wo-scripts/WebObjects.exe/UKCHP.woa/-9797/wa/navPage_###courseYear1Certificate
of which I was hoping to extract "courseYear1Certificate" from the url, this
would be the page name. I use the 3 ### signs because I can get the direct
action to work as navPage_ without it reading beyond the ### signs. I was
therefore hoping that using a subString method would allow me to get
anything after the 3 hash signs which could include a proper anchor name
link.
Only I can not seem to get the full url into the request so I can read the
full url.
The code in the directAction below works on a
StringIndexOutOfBoundsException because It has a name to get from the
database, if I can get this from the url all would be well.
public WOActionResults navPage_Action () {
NavPage_General aPage = (NavPage_General)pageWithName
("NavPage_General");
String urlQuery = context().request().uri();
NSLog.out.appendln("===\r The urlQueryString is = " + urlQuery +
"");
String extractedDA;
int urlStartOfDA=0;
int urlEndOfDA=0;
try {
urlStartOfDA = urlQuery.lastIndexOf("_"); //ignore code pertaining
to this for now
urlEndOfDA = urlQuery.lastIndexOf("###" );
extractedDA = urlQuery.substring(urlEndOfDA).trim();
NSLog.out.appendln(" extractedDA: " + extractedDA+"\r"+
" urlStartOfDA: " + urlEndOfDA+"
urlStartOfDA: " + urlEndOfDA);
}
catch (StringIndexOutOfBoundsException siofbEx) {
extractedDA = "About UKCHP";
NSLog.out.appendln(" failed extractedDA: " +
extractedDA+"\r"+
" urlStartOfDA: " + urlEndOfDA+"
urlEndOfDA: " + urlEndOfDA);
NSLog.out.appendln( "===\r StringIndexOutOfBoundsException
message: "+ siofbEx.getMessage() );
}
/*-------------------------------------------------------------------------------*/
/*---------------- Start Of Progmatically Created Fetch Spec
----------------*/
String navPageName = extractedDA;
String visibility = "On";
/*------------- end local variables & start qualifier bindings
--------------*/
NSArray bindings = new NSArray( new Object [] { navPageName,
visibility } );
EOQualifier qualifier =
EOQualifier.qualifierWithQualifierFormat("((tbNavPage.navPageName = %@) and
(visibility= %@))", bindings );
NSLog.out.appendln("\n*** bindings = " + bindings + "\n" + "
qualifier " + qualifier);
..... rest of programmatic fetch and other statements
}
TIA
Jonathan :^)
_________________________________________________________________
It's fast, it's easy and it's free. Get MSN Messenger today!
http://www.msn.co.uk/messenger
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden