Re: performParentAction and Form Values
Re: performParentAction and Form Values
- Subject: Re: performParentAction and Form Values
- From: Chuck Hill <email@hidden>
- Date: Wed, 28 Feb 2007 16:36:19 -0800
On Feb 28, 2007, at 4:28 PM, Peter wrote:
On 2/28/07, Chuck Hill <email@hidden> wrote:
On Feb 28, 2007, at 2:39 PM, Peter wrote:
> I am using the performParentAction(String) method in my
SimpleButton
> to perform the actual method. Since this is nested on the
DialogBox
> which is placed on a page in my app, I have a recursive pattern to
> check the parents for the matching action, and execute if found.
Not sure what you mean, but it sounds kind of iffy. :-)
Without this recursive pattern, I am not able to perform the parent
action since the action method is not in my DialogBox.java, but on
it's parent, one of my pages say TestPage.java.
If it is on the top level page, you can just do
context().page().valueForKey(actionName);
> I have looked into takeValuesForRequest but no luck getting the
latest
> form values from the browser.
>
> How do I get a subcomponent to ensure that its parent's (or
parent's
> parent's, etc) form value are taken before the
performParentAction is
> excuted.
If a form was submitted, it should "just happen". Things to check:
I am not sure if this means that by invoking an action from within a
form, that is equivalent to submitting the form... even if the action
is being invoked from a subcomponent?
No. You need to submit the form client side. Calling
this.form.submit(); in JavaScript will work, but that is for the
form's action. It sounds like the buttons in your dialog are not
submitting the form.
1. Are the form values in the URL / content of the request?
Maybe this is my problem. Every time I log the
context.request.formValues it is null.
2. Have you overridden takeValues... someplace and forgotten to call
super?
I checked and all takeValuesFromRequest are calling super and not
overridden.
3. Can you add logging and see if takeValues is getting called on the
top level page?
I added takeValuesFromRequest (w/logging) to the top level page, to
its subcomponent (DialogBox.java) and DialogBox.java's subcomponent -
SimpleButton.java. It is not being called anywhere.
All this lead me to think that there is some other "hidden" form. I
am going to look around in the mean time.
I'd look at your buttons and how they render in HTML.
> FYI Here is the heart of the SimpleButton.java logic for
performing
> the action on page in which it is placed.
>
> // since this subcomponent may be place in another subcomponent,
> find first parent
> // that responds to the method name (actionName).
>
> public WOComponent action() {
> WOActionResults results;
> results = findAndExecuteParentAction(this,actionName());
> return (WOComponent)results;
> }
>
> public WOActionResults findAndExecuteParentAction(WOComponent
> component, String actionName) {
> WOActionResults results = null;
> try {
> component.parent().valueForKey(actionName);
> results = component.performParentAction(actionName);
I think those two lines are functionally equivalent.
Agreed. But without it, I am getting
com.webobjects.foundation.NSKeyValueCoding$UnknownKeyException which
does not get caught in my catch statement. I am java-weak :-(
Try just
results = component.parent().valueForKey(actionName);
No need to perform the action twice.
Chuck
--
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
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