You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Alessio Gambi <ag...@gmail.com> on 2010/10/13 09:34:13 UTC

Override Default Co

Hi,

I would like to customize the way Tapestry handles responses from  
EventHandler methods.

Basically what I want to realize can be summarized like this:

- If the request contains a special "flag" attribute that I set then  
Tapestry have to manage the results as I decide
- If the request does not contains the flag attribute, then Tapestry  
have to manage the results as usual

My hope was to contribute to some services such that I can put my own  
ComponentEventResultProcessor service in front of all the others (like  
a wrapper or a filter).
unfortunately, the contribution to ComponentEventResultProcessor is a  
Mapped contribution and not an OrderedContribution.
And I did not find a smart way to trigger a  
DefaultComponentResultProcessor before any other
(BWT, ObjectEventResultProcessor is the fall back one but I do not  
know if it is called before or after the others as it is supposed to  
match all the Objects).

In the meanwhile, I workarounded this problem by overriding each of  
the basic EventResultProcessors with a wrapped version. This solution  
is working, but it is not the cleanest one, in fact
it assumes that there's no other contributions to the original set of  
ResultProcessors, and there's a lot of duplicated functionalities.

Moreover, I know that all the requests will be Ajax request so I  
started by contributing the AjaxComponentEventResultProcessor.
Unfortunately, I was not able to understand why in most of the cases  
the one actually called is the "original" (@Traditional marked)
ComponentEventResultProcessor.

Has anyone an idea on one to realize this customization in a way that  
is general and cleaner than the one I designed ?
Will be enough to override the original ObjectResultProcessors to  
handle all the kinds of result ?

Thanks
-- Alessio

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Override Default Co

Posted by Howard Lewis Ship <hl...@gmail.com>.
On an Ajax request, if you don't return a value, Tapestry sends down
an empty JSON object as the response, and the client side is free to
ignore that.

On Sat, Oct 16, 2010 at 2:07 AM, Alessio Gambi <ag...@gmail.com> wrote:
> Hi Thiago,
>
> thanks!
>
> I managed to advice the ComponentEventResultProcessor and that was fine for
> covering all the cases but one: the void return type.
>
> In my case, I would like to handle Ajax requests that triggers event method
> handlers, which in turn have a void return type, and avoid to render the
> page.
> Any suggestions ?
>
> I tried to advice the ImmediateRender without any success (it seems that the
> advice is never triggered). I tried with:
> @Match("ImmediateRender")
> @Match("ImmediateActionRenderResponseFilter")
> @Match("Immediate*")
>
>
> I also defined a new filter and then I tried to contribute it the
> ComponentEventRequestHandler just before the ImmediateRender. However, in
> this case
> if the filter Handle the request before immediate render, then the event
> handler methods are not invoked at all, while if it tries to call the handle
> method then the
> request is processed and send back to the client (thus is too late).
>
> A possible solution is to wrap the Original Response object, let it flows
> "normally", and the after all the processing is finished overwriting the
> response body.
> As you might expect, I do not like this last option.
>
> Thanks
> -- Alessio
>
> On Oct 13, 2010, at 2:51 PM, Thiago H. de Paula Figueiredo wrote:
>
>> On Wed, 13 Oct 2010 04:34:13 -0300, Alessio Gambi <ag...@gmail.com>
>> wrote:
>>
>>> Hi,
>>
>> Hi!
>>
>>> My hope was to contribute to some services such that I can put my own
>>> ComponentEventResultProcessor service in front of all the others (like a
>>> wrapper or a filter).
>>
>> You can override it using decoration or advise it.
>>
>> --
>> Thiago H. de Paula Figueiredo
>> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
>> and instructor
>> Owner, Ars Machina Tecnologia da Informação Ltda.
>> http://www.arsmachina.com.br
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Override Default Co

Posted by Alessio Gambi <ag...@gmail.com>.
Hi Thiago,

thanks!

I managed to advice the ComponentEventResultProcessor and that was  
fine for covering all the cases but one: the void return type.

In my case, I would like to handle Ajax requests that triggers event  
method handlers, which in turn have a void return type, and avoid to  
render the page.
Any suggestions ?

I tried to advice the ImmediateRender without any success (it seems  
that the advice is never triggered). I tried with:
@Match("ImmediateRender")
@Match("ImmediateActionRenderResponseFilter")
@Match("Immediate*")


I also defined a new filter and then I tried to contribute it the  
ComponentEventRequestHandler just before the ImmediateRender. However,  
in this case
if the filter Handle the request before immediate render, then the  
event handler methods are not invoked at all, while if it tries to  
call the handle method then the
request is processed and send back to the client (thus is too late).

A possible solution is to wrap the Original Response object, let it  
flows "normally", and the after all the processing is finished  
overwriting the response body.
As you might expect, I do not like this last option.

Thanks
-- Alessio

On Oct 13, 2010, at 2:51 PM, Thiago H. de Paula Figueiredo wrote:

> On Wed, 13 Oct 2010 04:34:13 -0300, Alessio Gambi  
> <ag...@gmail.com> wrote:
>
>> Hi,
>
> Hi!
>
>> My hope was to contribute to some services such that I can put my  
>> own ComponentEventResultProcessor service in front of all the  
>> others (like a wrapper or a filter).
>
> You can override it using decoration or advise it.
>
> -- 
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant,  
> developer, and instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Override Default Co

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Wed, 13 Oct 2010 04:34:13 -0300, Alessio Gambi <ag...@gmail.com>  
wrote:

> Hi,

Hi!

> My hope was to contribute to some services such that I can put my own  
> ComponentEventResultProcessor service in front of all the others (like a  
> wrapper or a filter).

You can override it using decoration or advise it.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org