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 15:42:04 -0800
On Feb 28, 2007, at 2:39 PM, Peter wrote:
Hi All,
I have developed two components a DialogBox and SimpleButton based on
some new user requirements. The DialogBox is a resuable component
that can be added to other pages (WOComponents) to display a simple
message with info, warning and stop icons. Optionally, one or two
buttons (such as "OK", "Cancel") may appear if bound correctly. I am
using the SimpleSquareButtons for these, as reusable components.
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. :-)
The reusable dialog box component (with its nested optional buttons)
can be placed on the pages of my app and work for simple navigation
actions. However when I attempt to perform a save() method on my
page, for instance, from my the SimpleButton - the form values for
that page are not "taken", and thus nothing saved. The DialogBox is
inside the page's WOForm (mutliple submit = true).
It seems from reading Practical WebObjects that I am missing something
in how to ensure the form values are being that were modified on the
page are being set in the R-R loop .
WOComponent
WOForm
WOTextField (This field is changed)
DialogBox
SimpleButton (fires a save method on the WOComponent)
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:
1. Are the form values in the URL / content of the request?
2. Have you overridden takeValues... someplace and forgotten to call
super?
3. Can you add logging and see if takeValues is getting called on the
top level page?
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.
} catch (NSKeyValueCoding.UnknownKeyException e) {
WOComponent parentComponent = component.parent();
if (parentComponent != null) {
results = findAndExecuteParentAction(parentComponent,
actionName);
}
}
return results;
}
--
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