You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Charlouze <me...@charlouze.com> on 2014/11/04 17:12:05 UTC

Component plugin

Hey everybody,

I'm trying to build a component where pages that use this component will be
able to add plugin like that :

<t:component>
  <t:plugin1 />
  <t:plugin2 />
</t:component>

I've build a ComponentSupport like the FormSupport to allow plugins to
interact with my component. I'm setting up my support in the environment at
setupRender time so that plugins can reach it.

My problem is that my support doesn't not exists on ajax event triggered by
either my plugins or the component. This is because I register it at render
time in setupRender method. When and how should I be instanciate it so that
it can exists in event ?

Feel free to ask me if i'm not clear enough.

Thanks in advance :D

Cheers,
Charles.

Re: Component plugin

Posted by Lance Java <la...@googlemail.com>.
Basically you'll need to push() the environmental as part of the ajax event
handler. You can either do this explicitly in the event handler or by using
a ComponentEventRequestFilter.

In the case of ajax forms, tapestry uses a AjaxFormUpdateFilter which
implements ComponentEventRequestFilter and invokes AjaxFormUpdateController
(if a request parameter is present).

Re: Component plugin

Posted by Charlouze <me...@charlouze.com>.
I'm not sure to understand in which case the AjaxFormUpdateController is
used ... Would you care to enlighten me?

2014-11-04 18:42 GMT+01:00 Lance Java <la...@googlemail.com>:

> As you've discovered, the container does not go through the render phases
> so doesn't add the environmental. Tapestry uses the
> AjaxFormUpdateControllerImpl to add the FormSupport environmental during
> ajax events. You will need to have a separate mechanism for adding the
> environmental ins the case of ajax actions.
>
> Some related code for tapestry's FormSupport/Ajax implementation:
>
> https://github.com/apache/tapestry-5/search?utf8=%E2%9C%93&q=FORM_COMPONENTID_PARAMETER
>
> https://github.com/apache/tapestry-5/blob/90766995f59048cb7f7d4cf042a21a9d728583db/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ajax/AjaxFormUpdateControllerImpl.java#L90
>

Re: Component plugin

Posted by Charlouze <me...@charlouze.com>.
@Lance: Thx ... I didn't though about testing the ajaxformloop even though
the name was quite obvious :P

@Thiago: As for now, my main concern is to get the client and component id.
As for now, I'm forcing client id to be equals to component id and I'm
using my ComponentSupport (that is a bridge to my component
ComponentResources) to get it in my plugin. I'm now thinking about setting
request parameters containing those two ids. My JS already uses custom
wrapper for ajax requests so i'll be able to add them quite quiclky. It'll
be less quick for tapestry standard form :D

2014-11-04 22:17 GMT+01:00 Thiago H de Paula Figueiredo <th...@gmail.com>
:

> On Tue, 04 Nov 2014 18:13:15 -0200, Charlouze <me...@charlouze.com> wrote:
>
>  @Thaigo: It has render things at page render and then it only
>> communicates to the server via JS.
>>
>
> I imagined that, but what needs to be done on these AJAX requests is what
> defines how you should handle this situation.
>
>
> --
> Thiago H. de Paula Figueiredo
> Tapestry, Java and Hibernate consultant and developer
> http://machina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Component plugin

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Tue, 04 Nov 2014 18:13:15 -0200, Charlouze <me...@charlouze.com> wrote:

> @Thaigo: It has render things at page render and then it only  
> communicates to the server via JS.

I imagined that, but what needs to be done on these AJAX requests is what  
defines how you should handle this situation.

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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


Re: Component plugin

Posted by Lance Java <la...@googlemail.com>.
Try putting a breakpoint in an AjaxFormLoop update.
 On 4 Nov 2014 21:09, "Charlouze" <me...@charlouze.com> wrote:

> I understood what you told me but I try to activate a breakpoint in this
> class and it did not... Anyway, it's ok ... I'm now building a service
> similar to that one used for my purpose.
>
> 2014-11-04 21:56 GMT+01:00 Lance Java <la...@googlemail.com>:
>
> > I've done my best to explain. Probably best to re-read my comments and
> dive
> > into the code via the links I sent.
> >  On 4 Nov 2014 20:52, "Charlouze" <me...@charlouze.com> wrote:
> >
> > > @Thaigo: It has render things at page render and then it only
> > communicates
> > > to the server via JS.
> > >
> > > @Lance: I understand how to push the environmental service. I was
> unable
> > to
> > > understand a use case of this AjaxFormUpdateController.
> > >
> > > 2014-11-04 20:33 GMT+01:00 Thiago H de Paula Figueiredo <
> > > thiagohp@gmail.com>
> > > :
> > >
> > > > On Tue, 04 Nov 2014 17:26:32 -0200, Charlouze <me...@charlouze.com>
> > wrote:
> > > >
> > > >  The event will be triggered at render time so that's too late.
> > > >> Furthermore,
> > > >> my events do not necessarily update a zone containing my component
> and
> > > >> plugins.
> > > >>
> > > >
> > > > In this case, what would the plugin components do when not rendering?
> > > >
> > > >
> > > > --
> > > > Thiago H. de Paula Figueiredo
> > > > Tapestry, Java and Hibernate consultant and developer
> > > > http://machina.com.br
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > For additional commands, e-mail: users-help@tapestry.apache.org
> > > >
> > > >
> > >
> >
>

Re: Component plugin

Posted by Charlouze <me...@charlouze.com>.
I understood what you told me but I try to activate a breakpoint in this
class and it did not... Anyway, it's ok ... I'm now building a service
similar to that one used for my purpose.

2014-11-04 21:56 GMT+01:00 Lance Java <la...@googlemail.com>:

> I've done my best to explain. Probably best to re-read my comments and dive
> into the code via the links I sent.
>  On 4 Nov 2014 20:52, "Charlouze" <me...@charlouze.com> wrote:
>
> > @Thaigo: It has render things at page render and then it only
> communicates
> > to the server via JS.
> >
> > @Lance: I understand how to push the environmental service. I was unable
> to
> > understand a use case of this AjaxFormUpdateController.
> >
> > 2014-11-04 20:33 GMT+01:00 Thiago H de Paula Figueiredo <
> > thiagohp@gmail.com>
> > :
> >
> > > On Tue, 04 Nov 2014 17:26:32 -0200, Charlouze <me...@charlouze.com>
> wrote:
> > >
> > >  The event will be triggered at render time so that's too late.
> > >> Furthermore,
> > >> my events do not necessarily update a zone containing my component and
> > >> plugins.
> > >>
> > >
> > > In this case, what would the plugin components do when not rendering?
> > >
> > >
> > > --
> > > Thiago H. de Paula Figueiredo
> > > Tapestry, Java and Hibernate consultant and developer
> > > http://machina.com.br
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
>

Re: Component plugin

Posted by Lance Java <la...@googlemail.com>.
I've done my best to explain. Probably best to re-read my comments and dive
into the code via the links I sent.
 On 4 Nov 2014 20:52, "Charlouze" <me...@charlouze.com> wrote:

> @Thaigo: It has render things at page render and then it only communicates
> to the server via JS.
>
> @Lance: I understand how to push the environmental service. I was unable to
> understand a use case of this AjaxFormUpdateController.
>
> 2014-11-04 20:33 GMT+01:00 Thiago H de Paula Figueiredo <
> thiagohp@gmail.com>
> :
>
> > On Tue, 04 Nov 2014 17:26:32 -0200, Charlouze <me...@charlouze.com> wrote:
> >
> >  The event will be triggered at render time so that's too late.
> >> Furthermore,
> >> my events do not necessarily update a zone containing my component and
> >> plugins.
> >>
> >
> > In this case, what would the plugin components do when not rendering?
> >
> >
> > --
> > Thiago H. de Paula Figueiredo
> > Tapestry, Java and Hibernate consultant and developer
> > http://machina.com.br
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>

Re: Component plugin

Posted by Charlouze <me...@charlouze.com>.
@Thaigo: It has render things at page render and then it only communicates
to the server via JS.

@Lance: I understand how to push the environmental service. I was unable to
understand a use case of this AjaxFormUpdateController.

2014-11-04 20:33 GMT+01:00 Thiago H de Paula Figueiredo <th...@gmail.com>
:

> On Tue, 04 Nov 2014 17:26:32 -0200, Charlouze <me...@charlouze.com> wrote:
>
>  The event will be triggered at render time so that's too late.
>> Furthermore,
>> my events do not necessarily update a zone containing my component and
>> plugins.
>>
>
> In this case, what would the plugin components do when not rendering?
>
>
> --
> Thiago H. de Paula Figueiredo
> Tapestry, Java and Hibernate consultant and developer
> http://machina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Component plugin

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Tue, 04 Nov 2014 17:26:32 -0200, Charlouze <me...@charlouze.com> wrote:

> The event will be triggered at render time so that's too late.  
> Furthermore,
> my events do not necessarily update a zone containing my component and
> plugins.

In this case, what would the plugin components do when not rendering?

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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


Re: Component plugin

Posted by Charlouze <me...@charlouze.com>.
The event will be triggered at render time so that's too late. Furthermore,
my events do not necessarily update a zone containing my component and
plugins.

2014-11-04 20:19 GMT+01:00 Thiago H de Paula Figueiredo <th...@gmail.com>
:

> You can also try using the Trigger component to trigger an event in your
> outer component to set up the Environment:
>
> <t:component>
>    <t:trigger event="setupEnvironment"/>
>    <t:plugin1 />
>    <t:plugin2 />
> </t:component>
>
> In Component.java:
>
> void onSetupEnvironment() {
>         // set up the Environment.
> }
>
> The Trigger component needs to be placed inside the Zone and before the
> Plugin component instance.s
>
>
> On Tue, 04 Nov 2014 15:42:09 -0200, Lance Java <la...@googlemail.com>
> wrote:
>
>  As you've discovered, the container does not go through the render phases
>> so doesn't add the environmental. Tapestry uses the
>> AjaxFormUpdateControllerImpl to add the FormSupport environmental during
>> ajax events. You will need to have a separate mechanism for adding the
>> environmental ins the case of ajax actions.
>>
>> Some related code for tapestry's FormSupport/Ajax implementation:
>> https://github.com/apache/tapestry-5/search?utf8=%E2%9C%
>> 93&q=FORM_COMPONENTID_PARAMETER
>> https://github.com/apache/tapestry-5/blob/90766995f59048cb7f7d4cf042a21a
>> 9d728583db/tapestry-core/src/main/java/org/apache/
>> tapestry5/internal/services/ajax/AjaxFormUpdateControllerImpl.java#L90
>>
>
>
> --
> Thiago H. de Paula Figueiredo
> Tapestry, Java and Hibernate consultant and developer
> http://machina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Component plugin

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
You can also try using the Trigger component to trigger an event in your  
outer component to set up the Environment:

<t:component>
    <t:trigger event="setupEnvironment"/>
    <t:plugin1 />
    <t:plugin2 />
</t:component>

In Component.java:

void onSetupEnvironment() {
	// set up the Environment.
}

The Trigger component needs to be placed inside the Zone and before the  
Plugin component instance.s

On Tue, 04 Nov 2014 15:42:09 -0200, Lance Java <la...@googlemail.com>  
wrote:

> As you've discovered, the container does not go through the render phases
> so doesn't add the environmental. Tapestry uses the
> AjaxFormUpdateControllerImpl to add the FormSupport environmental during
> ajax events. You will need to have a separate mechanism for adding the
> environmental ins the case of ajax actions.
>
> Some related code for tapestry's FormSupport/Ajax implementation:
> https://github.com/apache/tapestry-5/search?utf8=%E2%9C%93&q=FORM_COMPONENTID_PARAMETER
> https://github.com/apache/tapestry-5/blob/90766995f59048cb7f7d4cf042a21a9d728583db/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ajax/AjaxFormUpdateControllerImpl.java#L90


-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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


Re: Component plugin

Posted by Lance Java <la...@googlemail.com>.
As you've discovered, the container does not go through the render phases
so doesn't add the environmental. Tapestry uses the
AjaxFormUpdateControllerImpl to add the FormSupport environmental during
ajax events. You will need to have a separate mechanism for adding the
environmental ins the case of ajax actions.

Some related code for tapestry's FormSupport/Ajax implementation:
https://github.com/apache/tapestry-5/search?utf8=%E2%9C%93&q=FORM_COMPONENTID_PARAMETER
https://github.com/apache/tapestry-5/blob/90766995f59048cb7f7d4cf042a21a9d728583db/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ajax/AjaxFormUpdateControllerImpl.java#L90