Re: Direct Action Multiple Parameters
Re: Direct Action Multiple Parameters
- Subject: Re: Direct Action Multiple Parameters
- From: Colin Clark <email@hidden>
- Date: Wed, 2 Mar 2005 16:38:38 -0500
Hi Janice,
It sounds like what you're saying is that your request form keys and
values can change depending on the request. If so, you can always pull
out the request form values as an NSDictionary and process them
yourself by doing something like:
NSDictionary allFormValues = request().formValues()
for (int x = 0; x < allFormValues.keys().count(); x++) {
String formKey = (String) allFormValues.keys().objectAtIndex(x);
String formValue = (String) allFormValues.objectForKey(formKey);
doSomethingWithFormValue(formKey, formValue);
}
Does that help? You may want to look at the Javadocs for WORequest to
see all the options available to you for processing form values using
Direct Actions.
Colin
On Wednesday, March 2, 2005, at 04:22 PM, Janice Cheung wrote:
Hi David,
I was actually hoping to see how I could process all those
parameters ..
They are reading from an XSL file and retrieving XML data, so these
multiple parameters cannot be hardcoded, as they oscillate between
search requests. How would I handle variable, multiple parameters?
For example, in this particular instance, "formValues" include
values
x, y, Language, BatchSize, SessionId, and BatchIndex, but another
request will include x, y, Insurance, Lastname, Criteria,
Specialty, and
BatchIndex, BatchSize, and SessionId.
I really appreciate your help. Thanks very much!
Best regards,
Janice
David LeBer wrote:
On Mar 2, 2005, at 3:04 PM, Janice Cheung wrote:
Hi David,
I did come across your page when I was searching on Google.
:).
Can I see some sample code to better understand how to
implement this?
<snip>
My NSLog.out.appendln("request=" +request) statement shows that
my request contains this:
formValues={SessionID = ("Q3ftncuOduDgpJtI7tA1q0"); x = ("9");
Language = ("Spanish"); y = ("7"); BatchSize = ("20"); BatchIndex =
("1"); }
How do I get them out for my Direct Action?
Is this what you are looking for?
public WOActionResults demoAction() {
WOComponent page = pageWithName("PageName");
String xValue =
(String)this.request().formValueForKey("x");
String languageValue =
(String)this.request().formValueForKey("Language");
String yValue = (String)this.request().formValueForKey("y");
String batchSizeValue =
(String)this.request().formValueForKey("batchSize");
String batchIndexValue =
(String)this.request().formValueForKey("batchIndex");
// Do something with all these values
return page;
}
;david
--
David LeBer
Codebase Software Systems
site: http://www.codebase.ca
blog: http://david.codebase.ca
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
---
Colin Clark
Dynamic Web and Database Development Lead,
Resource Centre for Academic Technology,
University of Toronto
_______________________________________________
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