Re: Posting vars programatically from component to Direct Action
Re: Posting vars programatically from component to Direct Action
- Subject: Re: Posting vars programatically from component to Direct Action
- From: Arturo PĂ©rez <email@hidden>
- Date: Fri, 16 Apr 2004 23:50:07 -0400
On Apr 16, 2004, at 11:38 PM, Randall Perry wrote:
I can post form vars from one component to another (or to a Direct
Action)
by simply naming bound form fields.
So if I have a textbox that's bound to userName and I also set the name
property of the textbox to "userName" I can grab the key/value pair
from the
succeeding page from the request using
request().formValueForKey("userName")
because WO 'posts' the vars from form elements to the next page.
So, I'm wondering how to do the same thing in java, without having an
actual
bound textbox on the page. It's the same idea as having an input of
type
'hidden' in an HTML form.
Ah, well, there are lots of different ways to do that. Your technique
is a new
one to me (clever!). You can always do the typical thing of creating a
variable
(public or with appropriate setters/getters) and doing
WOComponent nextPage = pageWithName("theNextPage");
nextPage.takeValueForKey(val, "variableName");
You could go right ahead and use a WOHiddenField. You could store data
into the
WORequest or the WOResponse using takeValueForKey (they're both
subclasses of WOMessage
which supports that API), you could store things in session temporarily
using setObjectForKey,
from within the constructor for a WOComponent you could do
context().page().valueForKey("variableName");
to pull the values from the calling page, you could create a binding on
the component
and bind the values from one component to the other.
Normally, the first thing I described above is what people do. Do you
have any particular
objective besides getting a value from one component to another?
----
WO in philadelphia - wanna cheesesteak with that?
Please visit webobjects.meetup.com.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.