Re: invokeAction Question
Re: invokeAction Question
- Subject: Re: invokeAction Question
- From: Chuck Hill <email@hidden>
- Date: Tue, 6 Feb 2007 14:33:28 -0800
Hi Andrew,
On Feb 6, 2007, at 12:41 PM, Andrew Lindesay wrote:
Hello;
In general my apps are wrapped in a switch component so many
invokeActions are finally returning 'null' to get back to the same
"page-wrapper",
return context().page() is probably the better choice.
but (possibly for the first time in a long while) I am trying to
get one of my re-usable components to fire an action, the result of
which is non-null and this seems to be causing me an issue which I
don't _entirely_ understand.
The component in question is a java-script pop-up component which
works like WOPopUpButton except that it 'fires an action' when
somebody changes the selection. To do this, I make a hidden field
called by the name of the elementID and populate it with "YES"
using java-script when the pop-up is changed. Here is the
invokeAction(...) method from this custom component...
public WOActionResults invokeAction(WORequest request, WOContext
context)
{
String elementId = context.elementID();
I think you are missing an important check here. You are assuming
that the action is for this component, but it might not be.
if (context.senderID().equals(context.elementID()( {
String elementIdFV = (String) request.formValueForKey(elementId);
if(LEStringHelper.booleanForString(elementIdFV))
{
if(!hasBinding("action"))
throw new LEError("missing binding 'action' on a javascript
popup button.");
WOActionResults ar = (WOActionResults) valueForBinding("action");
if(null!=ar)
return ar;
}
}
return super.invokeAction(request,context);
}
This mechanism is working 100% except that I am somehow loosing the
returned value from this method further up the component heirachy.
If you have code like the above elsewhere, that may explain what you
are seeing.
The problem is that elements/components that encapsulate this one
(where I have not overidden invokeAction(...)) are then appearing
to ignore this non-null value and are instead sending back the top-
level (page) element instead as if this method had returned null.
My understanding was that an element will descend the component
tree during the invokeAction phase, invoking invokeAction(...) on
all elements until it gets a non-null value. Upon getting a non-
null value it will return it up the chain and if the top-level
(page) element gets back a null value then it will render itself.
Is that not correct?
I think so. I suspect that you have perhaps taken a short-cut or two
and caused yourself some misery.
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