You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Sergey Didenko <se...@gmail.com> on 2009/06/12 21:12:40 UTC

T5.1: get the current page context from a component

Hi,

Is there a way to get the page context from a subcomponent? Right now
I pass it as a component parameter, but that looks ugly.

Regards, Sergey.

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


Re: T5.1: get the current page context from a component

Posted by Sergey Didenko <se...@gmail.com>.
Well, actually what I need is

- dedicated activation context for a component, something like current
onActivate() for pages

- passing request parameters to PageLink, like <t:PageLink
requestparameters="linkRequestParamaters" context="linkContext" >

I'm implementing a pager that generates "forward" - "backward" links
without EventLinks to avoid excessive http requests.

The first item would help me to avoid reflection.

And the second would help me to code optional "pageNum" parameter
using the standard request parameter notation "?pageNum=3", not my own
odd format "/pageNum-3:anotherParameter-ENUM_PARAMATER_VALUE" that I
implemented by contributing ParamaterMap ValueEncoder as was advised
on this list for optional parameters.

On Sat, Jun 13, 2009 at 1:58 AM, Thiago H. de Paula
Figueiredo<th...@gmail.com> wrote:
> Em Fri, 12 Jun 2009 18:54:59 -0300, Sergey Didenko
> <se...@gmail.com> escreveu:
>
>> And call onPassivate() through reflection, right?
>
> Yes. But we can try to find a bfile a JIRA for a better way of getting that
> info without using reflection.
>
>> I missed this case because did not expect my "live" page to extend
>> interface Component that is returned from componentResources.getPage()
>
> The magic of Tapestry modifying our component classes in runtime . . . long
> live Javassist! :)
>
>> Thanks for your answers!
>
> It's a pleasure to help. :)
>
> --
> 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
>
>

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


Re: T5.1: get the current page context from a component

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Fri, 12 Jun 2009 18:54:59 -0300, Sergey Didenko  
<se...@gmail.com> escreveu:

> And call onPassivate() through reflection, right?

Yes. But we can try to find a bfile a JIRA for a better way of getting  
that info without using reflection.

> I missed this case because did not expect my "live" page to extend
> interface Component that is returned from componentResources.getPage()

The magic of Tapestry modifying our component classes in runtime . . .  
long live Javassist! :)

> Thanks for your answers!

It's a pleasure to help. :)

-- 
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: T5.1: get the current page context from a component

Posted by Sergey Didenko <se...@gmail.com>.
And call onPassivate() through reflection, right?

I missed this case because did not expect my "live" page to extend
interface Component that is returned from componentResources.getPage()

Thanks for your answers!

On Sat, Jun 13, 2009 at 12:26 AM, Thiago H. de Paula
Figueiredo<th...@gmail.com> wrote:
> Em Fri, 12 Jun 2009 18:18:10 -0300, Sergey Didenko
> <se...@gmail.com> escreveu:
>
>> Well, how I can inject not just ConcretePage but the current page? So
>> the component can be reused on different pages.
>
> @Inject ComponentResources and then call its getPage() method. You may need
> to cast the returned object.
>
> --
> 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
>
>

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


Re: T5.1: get the current page context from a component

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Fri, 12 Jun 2009 18:18:10 -0300, Sergey Didenko  
<se...@gmail.com> escreveu:

> Well, how I can inject not just ConcretePage but the current page? So
> the component can be reused on different pages.

@Inject ComponentResources and then call its getPage() method. You may  
need to cast the returned object.

-- 
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: T5.1: get the current page context from a component

Posted by Sergey Didenko <se...@gmail.com>.
Well, how I can inject not just ConcretePage but the current page? So
the component can be reused on different pages.

> You could also inject the container into the component, and then reference
> your context somehow directly.


Using "inherit" binding also means parameter declaration as I
understand from a very brief documentation.

>
> Never tried it, but  isn't the inherited: binding what you are looking for?
>

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


Re: T5.1: get the current page context from a component

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Fri, 12 Jun 2009 16:32:51 -0300, Andy Pahne <an...@googlemail.com>  
escreveu:

> You could also inject the container into the component, and then  
> reference your context somehow directly.

Calling onPassivate() directly? ;)

-- 
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: T5.1: get the current page context from a component

Posted by Andy Pahne <an...@googlemail.com>.
Never tried it, but  isn't the inherited: binding what you are looking for?

You could also inject the container into the component, and then 
reference your context somehow directly.

Andy




Sergey Didenko schrieb:
> Hi,
>
> Is there a way to get the page context from a subcomponent? Right now
> I pass it as a component parameter, but that looks ugly.
>
> Regards, Sergey.
>
> ---------------------------------------------------------------------
> 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