What is difference between @Inject and @InjectComponent since we declare it before component.

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

What is difference between @Inject and @InjectComponent since we declare it before component.

duymap
Hi experts,

I have a snippet code as below:

@Inject
private Zone tZone;

@InjectComponent
private Zone tZone;

So I don't understand what is difference  if I use @Inject or
@InjectComponent for component in Tapestry ? If anyone knows, can you
please let me know why. I really appreciate.

Thanks,
Duy.
Reply | Threaded
Open this post in threaded view
|

Re: What is difference between @Inject and @InjectComponent since we declare it before component.

Lance Java
The following applies to components only, not services.

@Inject is backed by InjectWorker which ultimately delegates to
InjectionProvider2. InjectionProvider2 is a chain which can be contributed
to. See TapestryModule.provideStandardInjectionProviders() for the
defaults. Some of the notable options for @Inject are assets, blocks and
services but you can provide your own.

@InjectComponent can only inject components by id (see
InjectComponentWorker).
Reply | Threaded
Open this post in threaded view
|

Re: What is difference between @Inject and @InjectComponent since we declare it before component.

duymap
Hi Lance,

Many Thanks! Your explanation is clear.

Duy.


On Mon, Jul 28, 2014 at 3:01 PM, Lance Java <[hidden email]>
wrote:

> The following applies to components only, not services.
>
> @Inject is backed by InjectWorker which ultimately delegates to
> InjectionProvider2. InjectionProvider2 is a chain which can be contributed
> to. See TapestryModule.provideStandardInjectionProviders() for the
> defaults. Some of the notable options for @Inject are assets, blocks and
> services but you can provide your own.
>
> @InjectComponent can only inject components by id (see
> InjectComponentWorker).
>



--
Chung Khánh Duy
Project Support Manager
Formos
Reply | Threaded
Open this post in threaded view
|

Re: What is difference between @Inject and @InjectComponent since we declare it before component.

Thiago H de Paula Figueiredo
In reply to this post by duymap
On Sun, 27 Jul 2014 23:47:25 -0300, Chung Khanh Duy  
<[hidden email]> wrote:

> Hi experts,

Hi!

> I have a snippet code as below:
>
> @Inject
> private Zone tZone;

This is declaring a component instance. This supposes you just use <div  
t:id="tZone"> in the template. I used div as an example, but any tag is  
valid.

> @InjectComponent
> private Zone tZone;

This is just injecting a component declared in the template.

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

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]