You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Josh Kamau <jo...@gmail.com> on 2011/05/06 10:36:06 UTC

@Inject vs @InjectComponent on a block component

Hi Team,

I am  still learning t5 So i may ask very many questions. So here is a
question on injections.

I have so far learnt the following regarding injection:

When injecting Services , Use @Inject
When injecting pages, user @InjectPage
When injecting Components, user @InjectComponent

Am i right so far?

Now in one of the examples, found here
http://tapestry.apache.org/ajax-components-faq.html, @Inject is used on
block component. I was expecting to find @InjectComponent, am i missing
something?

regards,
Josh.

Re: @Inject vs @InjectComponent on a block component

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, 06 May 2011 08:52:54 -0300, Josh Kamau <jo...@gmail.com>  
wrote:

> Thanks Thiago,

:)

> I actually thought blocks are components. I didnt know there are pages,
> components and blocks .[?]

I'd say there are pages, components and mixins. Block is something you can  
declare inside a page or component template. They don't exist outside a  
template.

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


Re: @Inject vs @InjectComponent on a block component

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, 06 May 2011 09:27:51 -0300, Adam Zimowski <zi...@gmail.com>  
wrote:

> I'm sorry about confusion. That's right, a much better way of
> generalizing what is a component is to check the package. For Tapestry
> component, if it lives in org.apache.tapestry5.corelib.components,
> then it is a component.

This is the Tapestry component library, but you can create libraries by  
yourself or add some others to your application (like Tapestry Upload,  
Tapestry Spring, ChennileKit, etc). Each one has a root package and the  
classes in the components package inside it are components too. And  
Tapestry creates another component library automatically for your web app,  
based in the tapestry.app-package context param in web.xml. Creating a  
component in Tapestry is trivial and a common part of developing web apps.

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


Re: @Inject vs @InjectComponent on a block component

Posted by Adam Zimowski <zi...@gmail.com>.
I'm sorry about confusion. That's right, a much better way of
generalizing what is a component is to check the package. For Tapestry
component, if it lives in org.apache.tapestry5.corelib.components,
then it is a component.

Adam

On Fri, May 6, 2011 at 7:12 AM, Thiago H. de Paula Figueiredo
<th...@gmail.com> wrote:
> On Fri, 06 May 2011 09:00:04 -0300, Adam Zimowski <zi...@gmail.com>
> wrote:
>
>> http://tapestry.apache.org/component-reference.html
>> At the bottom, there is a list of base classes which make a component
>> class a component. If a class does not derive from one of them, it
>> technically IS NOT a component.
>
> This is not correct. Tapestry components are true POJOs: they don't need to
> implement any interface or subclass any class. All classes inside the
> components package and its subpackages are components.
>
> --
> 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: @Inject vs @InjectComponent on a block component

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, 06 May 2011 09:00:04 -0300, Adam Zimowski <zi...@gmail.com>  
wrote:

> http://tapestry.apache.org/component-reference.html
> At the bottom, there is a list of base classes which make a component  
> class a component. If a class does not derive from one of them, it  
> technically IS NOT a component.

This is not correct. Tapestry components are true POJOs: they don't need  
to implement any interface or subclass any class. All classes inside the  
components package and its subpackages are components.

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


Re: @Inject vs @InjectComponent on a block component

Posted by Adam Zimowski <zi...@gmail.com>.
It is somewhat confusing. Blocks seem like components because they are
defined in the template. But Thiago is right, they're just "Blocks".

Here is a good reference you can use as a rule of thumb for what is (and is
not) a component:

http://tapestry.apache.org/component-reference.html

At the bottom, there is a list of base classes which make a component class
a component. If a class does not derive from one of them, it technically IS
NOT a component. And Block, derives from BaseLocaltable therefore it is not
a component.

And of course, you use @InjectComponent to inject components defined in the
template.

Therefore, since Block is not a component, you use @Inject, as Thiago said.

Adam

On Fri, May 6, 2011 at 6:52 AM, Josh Kamau <jo...@gmail.com> wrote:

> Thanks Thiago,
>
> I actually thought blocks are components. I didnt know there are pages,
> components and blocks .[?]
>
> regards.
> Josh.
>

Re: @Inject vs @InjectComponent on a block component

Posted by Josh Kamau <jo...@gmail.com>.
Thanks Thiago,

I actually thought blocks are components. I didnt know there are pages,
components and blocks .[?]

regards.
Josh.

Re: @Inject vs @InjectComponent on a block component

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, 06 May 2011 05:36:06 -0300, Josh Kamau <jo...@gmail.com>  
wrote:

> Hi Team,

Hi!

> I am  still learning t5 So i may ask very many questions. So here is a
> question on injections.
>
> I have so far learnt the following regarding injection:
>
> When injecting Services , Use @Inject
> When injecting pages, user @InjectPage
> When injecting Components, user @InjectComponent
>
> Am i right so far?

Yes, but @Inject is not just for services, but other types of injection  
too: configuration symbols (together with @Symbol), assets (together with  
@Path), etc.

> Now in one of the examples, found here
> http://tapestry.apache.org/ajax-components-faq.html, @Inject is used on
> block component. I was expecting to find @InjectComponent, am i missing
> something?

Blocks are not components. Blocks are blocks. :) They're declared in  
templates and @Inject is one way to get it (the other is to use the *block  
methods of ComponentResources).

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