Hi Faizel,

On Wed, Feb 18, 2009 at 7:49 PM, Faizel Dakri <[email protected]> wrote:
>
> Just a thought, but you might try posting a notification from your
> clearState() method in the parent component, using the parent as the
> notification object. Then in your switched component you can listen for that
> notification from the parent object and handle appropriately.
>

Good idea.

> Obviously, you'd have to handle registration appropriately in the child
> component so that you have access to the parent component when registering
> for the notification--I'm thinking maybe during awake() or during
> appendToResponse(), and then unregistering during sleep()? Either that, or
> just register for the notification blindly and check the notification object
> before clearing the state.
>

Below is what I did to solve the problem (a little bit different, but
based on your advice). All components created by the WOSwitchComponent
extend an AbstractComponent class. I added the following to this
class:

public void awake() {
   ERXWOContext.contextDictionary().setObjectForKey(this, "KEY");
}

...

public void sleep() {
   ERXWOContext.contextDictionary().removeObjectForKey("KEY");
}

In the parent project 'clearInnerComponentState' method I get the
child component (an AbstractComponent type) and call the clearState
method like this:

public void clearInnerComponentState() {
   AbstractCreateComponent component =
     (AbstractCreateComponent)
ERXWOContext.contextDictionary().objectForKey("KEY");

   if (component != null) {
      component.clearState();
   }
}

Now, if I have to clear the state of a component, it is just a matter
of overriding the clearState method.

Cheers,

Henrique
 _______________________________________________
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