Re: Subcomponent Refresh
Re: Subcomponent Refresh
- Subject: Re: Subcomponent Refresh
- From: David Griffith <email@hidden>
- Date: Tue, 24 Feb 2004 10:35:37 +0100
Kranthi,
In the end, I did have to do as Jonathan suggested. That is, I had to
override the appendToResponse() method in the subcomponent. The trick was
to understand the order in which things get done.
Session.appendToResponse()
ParentComponent.appendToResponse()
SubComponent.appendToResponse()
The code to actually add the new element to the database is in the
ParentComponent, and it is executed (I believe) during the
appendToResponse() of the ParentComponent. This is fine, as I need my
SubComponent to call a method to refresh itself, AFTER the new record has
been added to the database.
When I had overridden the awake() method, the SubComponent was refreshing
before the appendToResponse() of the Parent, so I saw no difference
visually. The new record did not show up.
However, when I did override the appendToResponse() method of the
SubComponent (which gets called after the appendToResponse() of the parent)
then I did this:
In the SubComponent:
public void appendToResponse(WOResponse aResponse, WOContext aContext)
{
refreshList();
super.appendToResponse(aResponse, aContext);
}
Basically, this intercepts the appendToResponse() to the subcomponent,
catching its parameters so they can be passed on to the
super.appendToResponse() method once you have done whatever it was that you
needed to do. I needed to refresh a displayGroup.
Works like a charm now!
Hope this helps!
Dave.
> Hi David,
>
> Can you please tell me how you did this. Even I have a similar requirement.
> Thank you.
>
> Regards,
> Kranthi Sagar.
>
>> ----------
>> From: David Griffith
>> Sent: Tuesday, February 24, 2004 1:32 AM
>> To: Jonathan Rochkind; email@hidden
>> Subject: Re: Subcomponent Refresh
>>
>> Thanks, overriding the awake() method has done the trick!
>>
>> Dave.
>>
>>> The proper way to communicate to subcomponents is almost always
>>> through bindings.
>>>
>>> I would add a binding to the subComponent, boolean value, called
>>> 'shouldRefresh'.
>>>
>>> Over-ride the sub-component's appendToResponse, to refresh if the
>>> binding is true, before calling super.appendToResponse. Pass 'true'
>>> to the subcomponent when you want it to refresh.
>>>
>>> Alternately, if you want the subcomponent to _always_ refresh before
>>> displaying it's HTML, you could dispense with the binding, and just
>>> always refresh in appendToResponse before calling
>>> super.appendToResponse.
>>>
>>> Another alternate idea: Pass the actual -data- to the subcomponent
>>> through bindings. When the parent wants to refresh the data, it can
>>> simply refresh the data itself, and pass that new data in through the
>>> bindings. It doesn't sound like that's convenient in your case
>>> though.
>>>
>>> Hope this helps,
>>> --Jonathan
>>>
>>> At 7:47 PM +0100 2/23/04, David Griffith wrote:
>>>> Hi all,
>>>>
>>>> I have a subcomponent whose purpose is to display a list of objects.
>>>> I have a main page containing that subcomponent.
>>>>
>>>> On the main page, you can click a link that will effectively add an item to
>>>> the database (which is now also to be displayed in the list in the
>>>> subcomponent).
>>>>
>>>> The subcomponent gets its data from the database and it works fine except
>>>> that when I return 'null' to the main page to refresh it, the subcomponent
>>>> does not update the list. I guess this makes sense as it hasn't been told
>>>> to refetch from the database, so I need it to be able to do this.
>>>>
>>>> Is there some way to indicate to a subcomponent that it's parent has
>>>> refreshed, or is there a way to execute a method in the subcomponent whe it
>>>> refreshes?
>>>>
>>>> Regards,
>>>> Dave.
>>>> _______________________________________________
>>>> webobjects-dev mailing list | email@hidden
>>>> Help/Unsubscribe/Archives:
>>>> http://www.lists.apple.com/mailman/listinfo/webobjects-dev
>>>> Do not post admin requests to the list. They will be ignored.
>>> _______________________________________________
>>> webobjects-dev mailing list | email@hidden
>>> Help/Unsubscribe/Archives:
>>> http://www.lists.apple.com/mailman/listinfo/webobjects-dev
>>> Do not post admin requests to the list. They will be ignored.
>> _______________________________________________
>> webobjects-dev mailing list | email@hidden
>> Help/Unsubscribe/Archives:
>> http://www.lists.apple.com/mailman/listinfo/webobjects-dev
>> Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.