My theory is that the performParentAction() changes the context's current component with the intention to restore it afterwards. But an exception may be occurring in a section of the code in performParentAction() which is not properly wrapped with an exception handler and so we end up with the wrong current component in the context.

Does it make sense?

With that theory in mind I wrote the following workaround which seems to be working. The method below is the invokeAction() method in my component that detects it should call the action method. Calling that action method goes through a whole lot of stuff and eventually calls performParentAction() which seems to be messing up the current component in the context because it's not catching an exception. And the exception may be getting caught at a higher level but at this point we have a messed up current component. The workaround is to read the current component before calling the action and then restore it afterwards as shown here in my component's invokeAction(). Notice the finally clause restoring the current component :


public WOActionResults invokeAction(WORequest worequest, WOContext wocontext)
{               

... some code omitted here which detects whether this component is the one that should call the action
        ...  if so the shouldInvokeAction flag gets set

        if (shouldInvokeAction) {
                // Makes sure calling the action does not mess up the current
                // component which should remain as this component otherwise
                // WebObjects runs into a null pointer exception eventually
                // in _popComponentFromContext().

                WOComponent current = wocontext.component();
                WOActionResults obj = null;
                try {
                        obj = (WOActionResults) 
valueForBinding(ACTION_BINDING_KEY);
                } finally {
                        wocontext._setCurrentComponent(current);
                        // Tell context that an action was performed.  If this 
is
                        // not done, the form's default action will be called 
also.
                        wocontext.setActionInvoked(true);
                }
                                
                if (obj == null) {
                        obj = wocontext.page();
                }
                                
                return obj;
        }

        // The action wasn't for us so try the child components
WOActionResults childActionResults = super.invokeAction(worequest, wocontext);
                
        return childActionResults;
}



On Jun 26, 2009, at 8:59 AM, Ricardo J. Parada wrote:


On Jun 26, 2009, at 12:55 AM, Chuck Hill wrote:


On Jun 25, 2009, at 8:49 PM, Ricardo J. Parada wrote:


Let me correct something I said: the action method is getting called!!! –– I was just confused the first time I looked.

Anyways, the action method gets called and then that action method is calling performParentAction as follows:

     return performParentAction(s);

I did not write that component and I rarely use the performParentAction. But that is returning null. And that is the value my component gets at line#113 and returns the page instead (is that bad? should I return the null value instead?).

Returning context.page is best.

Thanks... it's good to know.




Then if I resume execution I get the null pointer exception in _popComponentFromContext() in WebObjects.

Any chance the code called by performParentAction(s); is doing something bad?

I just noticed that the context().component() right before calling performParentAction(s) is my component that triggered the action. BUT then, after I call performParentAction(s) I check the context().component() again and I noticed it has changed. Shouldn't it be the same? Anyways, I'm suspecting that's my problem. Because if I call context()._setCurrentComponent() to set the current component back to the one before calling performParentAction(s) then the exception no longer happens.

Anyways, this is good progress... If the context current component was not supposed to change then I need to find out why it's changing. That may require a subclass of the editing context (which Wonder may already have) and then implement the _setCurrentComponent() and set a breakpoint so that I can see what's changing it.




Chuck



Still investigating...



On Jun 25, 2009, at 10:59 PM, Ricardo J. Parada wrote:


Well here's what I'm seeing... my component determines that it is the one that should invoke the action and goes through this code:

        // Tell context that an action was performed.  If this is
        // not done, the form's default action will be called also.
111:    wocontext.setActionInvoked(true);
112:
113: WOActionResults obj = (WOActionResults) valueForBinding(ACTION_BINDING_KEY);
114:    if (obj == null) obj = wocontext.page();
115:                            
116:    return obj;

Line # 113 should be calling the action method that is bound to the action binding. That is the method on which I set the breakpoint that I was referring to earlier. The one I never hit. So if I don't hit the breakpoint then it's not calling it. But it is calling something else because I see stuff show on the console every time I evaluate the expression valueForBinding(ACTION_BINDING_KEY).

Anyways, I'll try to investigate what is getting called... or maybe take a look at valueForBinding to find out why it's not calling the right thing.

If I evaluate the expression _associationWithName(ACTION_BINDING_KEY) in the debugger right after line #113 I get the following:

(ognl.helperfunction.WOHelperFunctionBindingNameAssociation) <ognl.helperfunction.WOHelperFunctionBindingNameAssociation: keyPath=^action>





On Jun 25, 2009, at 10:19 PM, Chuck Hill wrote:


On Jun 25, 2009, at 7:10 PM, Ricardo J. Parada wrote:


On Jun 25, 2009, at 9:53 PM, Chuck Hill wrote:

Sigh...

Does anybody see anything obvious in this stack trace? I used to have this exception ages ago and it was obscure. I don't recall what ended up fixing it exactly but now that I moved my application to Wonder I'm running into this again and haven't figured out yet why or how to fix it. Any ideas?? Pleeeassee!! :-)

I have seen this before. It is caused by the context not knowing the current component. This is hitting some action method. What is it returning?

I see in the stack trace that it's going through the invokeAction phase. But the action method that is supposed to get called has not been called yet. I set a breakpoint in the method that it's supposed to get called but I hit the exception first and the action method never gets called.

I'll set a breakpoint in the invokeAction() method of the component that is supposed to call the action to see how things look from there.

From what I can tell the _popComponentFromContext() gets the current component from the context and then to message it and throws the null pointer exception because the current component is null for some obscure reason.

Anyways, I'm taking a look at the invokeAction in my component.

I really ought to take better notes when I hit things like this.

Chuck

--
Chuck Hill             Senior Consultant / VP Development

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 protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/rparada%40mac.com

This email sent to [email protected]


--
Chuck Hill             Senior Consultant / VP Development

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 protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/rparada %40mac.com

This email sent to [email protected]

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to