You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Captain Cid <ca...@indiatimes.com> on 2009/07/04 16:20:59 UTC

Component initialization

Hi,

I have 2 packages

tapestry.pages.view 
and tapestry.components
 
When i am opening some page say /view/A, i find components getting invoked
which are not mentioned in A.tml or A.java . How can i stop it from invoking
non used components ?
-- 
View this message in context: http://www.nabble.com/Component-initialization-tp24335036p24335036.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Component initialization

Posted by Captain Cid <ca...@indiatimes.com>.
i have component folder containing
tapestry.components  containing
top.java
bottom.java
userinfo.java
wishlist.java (wishlist uses some db query in BeginRender function)

tapestry.pages.view containing
showmainpage.java
user.java
user.tml
showmainpage.tml

showmainpage uses userinfo,top,bottom components
user uses wishlist,top,bottom components 

when i open showmain page..wishlist.java is not invoked
when i open user page..wishlist.java is invoked
now when i open showmain page...i find wishlist method getting invoked
twice...
very curious case !

does it maintain some browser session or what?


Thiago H. de Paula Figueiredo wrote:
> 
> Em Sun, 05 Jul 2009 02:25:38 -0300, Captain Cid  
> <ca...@indiatimes.com> escreveu:
> 
>> I have put my queries in one of the rendering methods
>>
>> 	@BeginRender
>> 	void renderMessage(MarkupWriter writer) {
>>                //query code
>>         }
>>
>> and it is getting invoked somehow...even though it is unused component ?
>> what do u suggest ?
> 
> @BeginRender methods should only be invoked when its class or component  
> renders, so there's something strange here. Please post exactly the  
> component and method that is being rendered/invoked unnecessarily.
> 
> -- 
> Thiago H. de Paula Figueiredo
> Independent Java consultant, developer, and instructor
> http://www.arsmachina.com.br/thiago
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Component-initialization-tp24335036p24346369.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Component initialization

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Sun, 05 Jul 2009 02:25:38 -0300, Captain Cid  
<ca...@indiatimes.com> escreveu:

> I have put my queries in one of the rendering methods
>
> 	@BeginRender
> 	void renderMessage(MarkupWriter writer) {
>                //query code
>         }
>
> and it is getting invoked somehow...even though it is unused component ?
> what do u suggest ?

@BeginRender methods should only be invoked when its class or component  
renders, so there's something strange here. Please post exactly the  
component and method that is being rendered/invoked unnecessarily.

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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


Re: Component initialization

Posted by Captain Cid <ca...@indiatimes.com>.
I have put my queries in one of the rendering methods

	@BeginRender
	void renderMessage(MarkupWriter writer) {
               //query code
        }

and it is getting invoked somehow...even though it is unused component ?
what do u suggest ?


Thiago H. de Paula Figueiredo wrote:
> 
> Em Sat, 04 Jul 2009 16:01:12 -0300, Captain Cid  
> <ca...@indiatimes.com> escreveu:
> 
>> Problem is few components use DB queries...so if page which is not using  
>> that component calls it, then there is unnecessary overload !
> 
> Put theses queries in methods invoked during rendering instead of doing it  
> in constructors and field initializations. ;)
> 
> -- 
> Thiago H. de Paula Figueiredo
> Independent Java consultant, developer, and instructor
> http://www.arsmachina.com.br/thiago
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Component-initialization-tp24335036p24340318.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Component initialization

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Sat, 04 Jul 2009 16:01:12 -0300, Captain Cid  
<ca...@indiatimes.com> escreveu:

> Problem is few components use DB queries...so if page which is not using  
> that component calls it, then there is unnecessary overload !

Put theses queries in methods invoked during rendering instead of doing it  
in constructors and field initializations. ;)

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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


Re: Component initialization

Posted by Captain Cid <ca...@indiatimes.com>.
Problem is few components use DB queries...so if page which is not using that
component calls it,
then there is unnecessary overload !



Howard Lewis Ship wrote:
> 
> a) Why do you care? That's more than just flippant, it indicates that if
> you
> are concerned about when or in what order your components are
> instantiated,
> you are likely setting yourself up for deployment failure. A code smell
> for
> this is a static variable in a component. Remember that pages and
> compnents
> are instantiated as needed, will be reused across different clients and
> discarded when Tapestry feels they are no longer needed.
> b) Tapestry instantiates pages to verify that the target of a PageLink
> component is valid. You are probably seeing component instantiations
> related
> to that.
> 
> On Sat, Jul 4, 2009 at 7:20 AM, Captain Cid
> <ca...@indiatimes.com>wrote:
> 
>>
>> Hi,
>>
>> I have 2 packages
>>
>> tapestry.pages.view
>> and tapestry.components
>>
>> When i am opening some page say /view/A, i find components getting
>> invoked
>> which are not mentioned in A.tml or A.java . How can i stop it from
>> invoking
>> non used components ?
>> --
>> View this message in context:
>> http://www.nabble.com/Component-initialization-tp24335036p24335036.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> 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
> Director of Open Source Technology at Formos
> 
> 

-- 
View this message in context: http://www.nabble.com/Component-initialization-tp24335036p24337139.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Component initialization

Posted by Howard Lewis Ship <hl...@gmail.com>.
a) Why do you care? That's more than just flippant, it indicates that if you
are concerned about when or in what order your components are instantiated,
you are likely setting yourself up for deployment failure. A code smell for
this is a static variable in a component. Remember that pages and compnents
are instantiated as needed, will be reused across different clients and
discarded when Tapestry feels they are no longer needed.
b) Tapestry instantiates pages to verify that the target of a PageLink
component is valid. You are probably seeing component instantiations related
to that.

On Sat, Jul 4, 2009 at 7:20 AM, Captain Cid <ca...@indiatimes.com>wrote:

>
> Hi,
>
> I have 2 packages
>
> tapestry.pages.view
> and tapestry.components
>
> When i am opening some page say /view/A, i find components getting invoked
> which are not mentioned in A.tml or A.java . How can i stop it from
> invoking
> non used components ?
> --
> View this message in context:
> http://www.nabble.com/Component-initialization-tp24335036p24335036.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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
Director of Open Source Technology at Formos