performParentAction and Form Values
performParentAction and Form Values
- Subject: performParentAction and Form Values
- From: Peter <email@hidden>
- Date: Wed, 28 Feb 2007 17:39:00 -0500
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.
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.
Thanks,
Pete
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);
} catch (NSKeyValueCoding.UnknownKeyException e) {
WOComponent parentComponent = component.parent();
if (parentComponent != null) {
results = findAndExecuteParentAction(parentComponent,
actionName);
}
}
return results;
}
_______________________________________________
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