You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by János Jarecsni <ja...@gmail.com> on 2008/04/29 08:15:04 UTC

page activation + components

Hi there,

I have an activatable page, in its onActivate(String param) method I save
the param to a normal instance variable of the page class (no persistence!).
How can any component embedded within this page access this variable?

the page class:

//...
private String param;

public void onActivate(String param) {
   this.param = param;
}


public String getParam() {...}


Thx in advance!
Janos

Re: page activation + components

Posted by "Filip S. Adamsen" <fs...@fsadev.com>.
This is not what @Retain is for. If you use it, the value won't be 
cleared out at the end of the request.

http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry/annotations/Retain.html

-Filip

Michael Gerzabek skrev:
> 6) @Retain could do the job. Your String will be available until the end 
> of the request.
> 
> 
> János Jarecsni schrieb:
>> Hi there,
>>
>> I have an activatable page, in its onActivate(String param) method I save
>> the param to a normal instance variable of the page class (no 
>> persistence!).
>> How can any component embedded within this page access this variable?
>>
>> the page class:
>>
>> //...
>> private String param;
>>
>> public void onActivate(String param) {
>>    this.param = param;
>> }
>>
>>
>> public String getParam() {...}
>>
>>
>> Thx in advance!
>> Janos
>>
>>   
> 
> 
> ---------------------------------------------------------------------
> 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: page activation + components

Posted by Michael Gerzabek <mi...@gmx.net>.
6) @Retain could do the job. Your String will be available until the end 
of the request.


János Jarecsni schrieb:
> Hi there,
>
> I have an activatable page, in its onActivate(String param) method I save
> the param to a normal instance variable of the page class (no persistence!).
> How can any component embedded within this page access this variable?
>
> the page class:
>
> //...
> private String param;
>
> public void onActivate(String param) {
>    this.param = param;
> }
>
>
> public String getParam() {...}
>
>
> Thx in advance!
> Janos
>
>   


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


Re: page activation + components

Posted by Michael Gerzabek <mi...@gmx.net>.
@Retain
private String param;

Salue

János Jarecsni schrieb:
> and how a component can get to know the page in which it is included? I
> mean, I can't @InjectPage, as the component will be included in many kinds
> of pages.
>
> @Kristian: thx for the many ways :) I'll try these, hope that the
> @Environmental stuff is scalable (I'm trying to bypass session creation as
> much as possible)
>
> Is there a doc on the various annotations available?
>
> @Michael:
> Could you include a tiny bit of example? THX!
>
> Thx to you all
> cheers
> janos
>
> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>
>   
>> 5) @InjectPage the page and call the getter
>>
>> Kristian Marinkovic wrote:
>>     
>>> hi janos,
>>>
>>> there are several possibilities:
>>>
>>> 1) declare a component parameter and pass in the variable
>>>
>>> 2) put it in a ASO and inject the ASO in all your components (using
>>> @ApplicationState)
>>> the drawback is that any other page or component will be able to access
>>> the ASO
>>>
>>> 3) put it into the Environment and read it whereever you need it in your
>>> nested components.
>>> be careful when you put your object in your environment. if you put it
>>>       
>> in
>>     
>>> during the action
>>> request it will not be able in the render request (because of the page
>>> redirect).
>>>
>>> page:
>>>
>>> @Inject Environment env;
>>>
>>> @Persist("flash") whateverclass w;
>>>
>>> onActivate(w) {  this.w= w }
>>>
>>> setupRender() { env.push(whateverclass.class,w);}
>>>
>>> components:
>>>
>>> @Environmental Whateverclass var;
>>>
>>> 4) define a service that can take this variable (and saves it
>>>       
>> appropriatly
>>     
>>> so it is not
>>> lost on a redirect:)) and inject your service in the components where
>>> needed
>>> to retrieve the value.
>>>
>>> maybe there are some more possibilities :)
>>>
>>> g,
>>> kris
>>>
>>>
>>>
>>>
>>> "János Jarecsni" <ja...@gmail.com>
>>> 29.04.2008 08:15
>>> Bitte antworten an
>>> "Tapestry users" <us...@tapestry.apache.org>
>>>
>>>
>>> An
>>> "Tapestry users" <us...@tapestry.apache.org>
>>> Kopie
>>>
>>> Thema
>>> page activation + components
>>>
>>>
>>>
>>>
>>>
>>>
>>> Hi there,
>>>
>>> I have an activatable page, in its onActivate(String param) method I
>>>       
>> save
>>     
>>> the param to a normal instance variable of the page class (no
>>> persistence!).
>>> How can any component embedded within this page access this variable?
>>>
>>> the page class:
>>>
>>> //...
>>> private String param;
>>>
>>> public void onActivate(String param) {
>>>    this.param = param;
>>> }
>>>
>>>
>>> public String getParam() {...}
>>>
>>>
>>> Thx in advance!
>>> Janos
>>>
>>>
>>>
>>>       
>> --
>> http://thegodcode.net
>>
>>
>> ---------------------------------------------------------------------
>> 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: page activation + components

Posted by Josh Canfield <jo...@thedailytube.com>.
> Form Validation creates a session for flash persistence... nothing in the
> session, but a session none the less.

I'm not sure what you mean by "nothing in the session", last I
checked, flash persisted objects are stored in the session, but
cleared on first access. If you're concerned about session inflation,
@Persist("flash") isn't really the answer.

Josh

On Fri, May 2, 2008 at 8:07 AM, nicholas Krul <ni...@gmail.com> wrote:
> Hi.
>
> 'My intention is to defer session creation until it is absolutely necessary'
> I agree with you on that...
>
> Why don't you use persistence and store it in a cookie? for simple
> (non-hibernate) objects, its fine.
>
> Form Validation creates a session for flash persistence... nothing in the
> session, but a session none the less.
>
> --nK
>
>
> On Fri, May 2, 2008 at 3:55 PM, János Jarecsni <ja...@gmail.com>
>
> wrote:
>
> > Hi,
> >
> > yes still listening :) thx so much for the replies. I start responding
> > here.
> > Well, you're right Josh, I don't care for the URL. My intention is to
> > defer
> > session creation until it is absolutely necessary (like when the user is
> > logged in or has put some goods in a shopping cart). Although I think I
> > only
> > need to "remember" 1 thing at a time, the last action. In my theory all my
> > component instances (I use this word to emphasize I can have n instances
> > of
> > a stock monitor component, each monitoring a different paper) have a
> > configuration. So I don't have to pass all bits of info in the URL... On
> > an
> > admin site or using properties files, whatever the basic stuff is
> > preconfigured for a component instance. What gets passed in the URL is any
> > information the action processing needs. I don't know how clearly I can
> > describe this :) but the important thing is component instances render
> > themselves according to their configuration, and one of them changes its
> > state according to some action on the user's side. Hm... life is not that
> > simple I have to admit. I can easily think of a site where the user clicks
> > around, changing the states of multiple components (like changing a
> > weather
> > monitor state code to NY or asking for a voter component to show voting
> > status and so on). It would be bad if the last action would clear this
> > "state", resulting in all components rendering the default state. If we
> > really stick to deferred session creation then this state has to be
> > encoded
> > somehow and get sent to the client with every response (the developer
> > would
> > have to use some encodeStateInUrl() method to generate the link to
> > preserve
> > the actual state and add the new bit. At this point I really start to
> > question deferred session creation... :) maybe an easier approach that
> > session is not created for for the start page, but all this component
> > state
> > is session persisted. Ok, it may not be as scalable...
> >
> > cheers
> > Janos
> >
> > 2008/4/30 Josh Canfield <jo...@thedailytube.com>:
> >
> > > Are you trying to keep the news id out of the url? Doesn't sound like
> > > it from your response to not doing the redirect. Since that's the
> > > case, why not add it to the page context?
> > >
> > > I suppose if you were building a portal with several components then
> > > keeping track of component parameters could get unwieldy. If you were
> > > showing a news article from the news portlet, and a stock highlight
> > > from the stock portlet... At that point you're sort of building a
> > > framework on a framework.
> > >
> > > You could build your page such that it accumulated context from it's
> > > components. Push a ComponentContext object into the Environment
> > > onActivate, and setupRender in your page (env gets cleared before
> > > render phase, not sure if there is a better way than doing it in
> > > both.) Then collect component parameter mappings. onPassivate for your
> > > page would organize and return these as it's context (you might want
> > > to sort them to get consistent results)
> > >
> > > Your url might look like this:
> > >
> > > http://localhost/context/mypage/cc/news/4527/stock/MCD
> > >
> > > Then onactivate you init the ComponentContext from the url keying off
> > > the "cc" to grab the remaining parameters and use them as key/value
> > > for the components. The your components do something like:
> > >
> > > @Environmental
> > > private ComponentContext _compContext;
> > >
> > > void setupRender() {
> > >  Long newsId = _compContext.getLong(_resources.getId());
> > > }
> > >
> > > void onPickNewsItem(Long id) {
> > >  _compContext.put(_resources.getId(), id);
> > > }
> > >
> > >
> > > Josh
> > >
> > > On Wed, Apr 30, 2008 at 5:23 AM, János Jarecsni
> > > <ja...@gmail.com> wrote:
> > > > Hi Chris,
> > > >
> > > > I try to explain :)
> > > > Say, you have a "NewsQuote" component, which shows a few lines from
> > the
> > > 5
> > > > latest news. At the and of each quotations, there a "More" link. Now,
> > > when
> > > > the user clicks on this link (an action link, for that matter), the
> > > > NewsQuote component will set a request scope info saying that the news
> > > with
> > > > ID=4527 is requested. And when it comes to the "News" component (it is
> > > able
> > > > to show the text of a given news in full), it simply looks at this
> > piece
> > > of
> > > > info, and loads the news with id 4527 (or gets it from an app level
> > > cache
> > > > :)) and renders it.
> > > >
> > > > Hope it tells something about what I am up to :)
> > > >
> > > > thx
> > > > Janos
> > > >
> > > > 2008/4/30 Chris Lewis <ch...@bellsouth.net>:
> > > >
> > > >
> > > > > Honestly it's difficult for me to imagine a situation where I'd do
> > > that
> > > > > because it seems to violate a degree of encapsulation that tapestry
> > > > > imposes as a "freeing law" of the framework. The epicenter of that
> > > being
> > > > > that one should not think in terms of low-level idioms such as
> > request
> > > > > parameters, and instead replace those with a higher level of
> > > application
> > > > > logic that eclipses them entirely (when possible). That's not to say
> > > > > that your perspective is flawed, but from the small bit of
> > > understanding
> > > > > I've taken from your posts I can't see why one would do what you
> > want.
> > > > > The thing that I've been saying is missing here is, what are you
> > > trying
> > > > > to do? I don't mean technically, I mean what is the end result for
> > the
> > > > > user? Understanding this is critical, but even if I don't your
> > problem
> > > > > can still be solved by using a session to serve as an arbitrary
> > > holder.
> > > > > If you've settled on this architecture, why not write such a generic
> > > > > service and move on?
> > > > >
> > > > > János Jarecsni wrote:
> > > > > > Hi,
> > > > > >
> > > > > > I looked everywhere for usage of request scope variables, but
> > found
> > > > > nothing
> > > > > > (maybe I'm impatient a bit :)...
> > > > > > Is it really that unrealistic to have two components in a page,
> > one
> > > (A)
> > > > > > having an action link eventhandler where it would set some
> > attribute
> > > for
> > > > > the
> > > > > > request only (not the session!) and then component B could render
> > > itself
> > > > > > according to the attribute set by component A?
> > > > > >
> > > > > > I think it should be a piece of cake :)
> > > > > >
> > > > > > thx
> > > > > > Janos
> > > > > >
> > > > > > 2008/4/30 Filip S. Adamsen <fs...@fsadev.com>:
> > > > > >
> > > > > >
> > > > > >> Nope, you're exactly right.
> > > > > >>
> > > > > >> -Filip
> > > > > >>
> > > > > >> Blower, Andy skrev:
> > > > > >>
> > > > > >>  This is not what I understood 'perthread' scope to be. I thought
> > > that
> > > > > it
> > > > > >>
> > > > > >>> meant that each thread using a service gets its own instance of
> > > the
> > > > > service
> > > > > >>> to use, even though that instance may not be the same as any
> > > previous
> > > > > >>> instance it used. In other words, nothing to do with user
> > > sessions,
> > > > > it's
> > > > > >>> just for services that are not thread safe and cannot be
> > > singletons.
> > > > > >>>
> > > > > >>> Have I got the wrong end of the stick here?
> > > > > >>>
> > > > > >>>  -----Original Message-----
> > > > > >>>
> > > > > >>>> From: Andy Huhn [mailto:amhuhn@hrtc.net]
> > > > > >>>> Sent: 29 April 2008 17:34
> > > > > >>>> To: Tapestry users
> > > > > >>>> Subject: Re: page activation + components
> > > > > >>>>
> > > > > >>>>
> > > > > >>>> Hello,
> > > > > >>>>
> > > > > >>>> You can define the scope of each service...you can set that
> > > > > particular
> > > > > >>>> service to be tied to only one session.
> > > > > >>>>
> > > > > >>>> See
> > > http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html,
> > > > > >>>> and
> > > > > >>>> search for "perthread".
> > > > > >>>>
> > > > > >>>> Thanks,
> > > > > >>>> Andy
> > > > > >>>>
> > > > > >>>> On Tue, 29 Apr 2008 18:02:52 +0200, "János Jarecsni"
> > > > > >>>> <ja...@gmail.com> wrote:
> > > > > >>>>
> > > > > >>>>
> > > > > >>>>> Hi there,
> > > > > >>>>>
> > > > > >>>>> the service approach (as I expected) is session-agnostic (and
> > is
> > > > > >>>>> page-independent so concurrent users would interfere badly),
> > > > > >>>>>
> > > > > >>>>>
> > > > > >>>> therefore is
> > > > > >>>>
> > > > > >>>>
> > > > > >>>>> not ok.
> > > > > >>>>>
> > > > > >>>>> I will now try the Environment approach... if that is
> > > session-aware
> > > > > >>>>>
> > > > > >>>>>
> > > > > >>>> :)
> > > > > >>>>
> > > > > >>>>
> > > > > >>>>> thx again
> > > > > >>>>> janos
> > > > > >>>>>
> > > > > >>>>> 2008/4/29 János Jarecsni <ja...@gmail.com>:
> > > > > >>>>>
> > > > > >>>>>  Hi Chris,
> > > > > >>>>>
> > > > > >>>>>> even so you could help :) I want this kind of generic way of
> > > > > >>>>>> passing
> > > > > >>>>>> around information (component to component communication :))
> > so
> > > > > >>>>>> I'll
> > > > > >>>>>>
> > > > > >>>>>>
> > > > > >>>>> look
> > > > > >>>>>
> > > > > >>>>>
> > > > > >>>>>> for the solutions Kristian and you outlined.
> > > > > >>>>>>
> > > > > >>>>>> thanks!
> > > > > >>>>>>
> > > > > >>>>>> cheers,
> > > > > >>>>>> janos
> > > > > >>>>>>
> > > > > >>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > > > >>>>>>
> > > > > >>>>>>  Janos,
> > > > > >>>>>>
> > > > > >>>>>>> Without code or a description of your actual goal, I'm
> > finding
> > > > > >>>>>>>
> > > > > >>>>>>>
> > > > > >>>>>> your
> > > > > >>>>>>
> > > > > >>>>> situation too hypothetical to really digest. The one thing I
> > can
> > > > > >>>>>
> > > > > >>>>>> point
> > > > > >>>>>>
> > > > > >>>>> out is what you said about wanting a component to set a
> > property
> > > > > >>>>>
> > > > > >>>>>> in
> > > > > >>>>>>
> > > > > >>>>> the
> > > > > >>>>>
> > > > > >>>>>
> > > > > >>>>>> page. If you want to do that, then you have to know the class
> > > of
> > > > > >>>>>>
> > > > > >>>>>> the
> > > > > >>>>>>
> > > > > >>>>> page and so injecting a page would make sense. Of course that
> > > > > >>>>>
> > > > > >>>>>> means
> > > > > >>>>>>
> > > > > >>>>> tightly coupling a component to a page, which to me doesn't
> > make
> > > > > >>>>>
> > > > > >>>>>> sense.
> > > > > >>>>>>
> > > > > >>>>>> If you simply need a generic way of passing data between
> > pages
> > > and
> > > > > >>>>>>
> > > > > >>>>>>> components, consider using a service that provides an
> > untyped
> > > > > >>>>>>> list
> > > > > >>>>>>>
> > > > > >>>>>>>
> > > > > >>>>>> or
> > > > > >>>>>>
> > > > > >>>>> putting something in the environment as Kristian suggested.
> > I'm
> > > > > >>>>>
> > > > > >>>>>> sorry
> > > > > >>>>>>
> > > > > >>>>> I
> > > > > >>>>>
> > > > > >>>>>
> > > > > >>>>>> can't be more helpful but as I said I'm not clear on what
> > > you're
> > > > > >>>>>>
> > > > > >>>>>> really
> > > > > >>>>>>
> > > > > >>>>>> trying to do.
> > > > > >>>>>>
> > > > > >>>>>>> good luck
> > > > > >>>>>>> chris
> > > > > >>>>>>>
> > > > > >>>>>>> János Jarecsni wrote:
> > > > > >>>>>>>
> > > > > >>>>>>>
> > > > > >>>>>>>> Hi Chris,
> > > > > >>>>>>>>
> > > > > >>>>>>>> I thought of pages as "contexts" for the components
> > embedded
> > > > > >>>>>>>>
> > > > > >>>>>>>>
> > > > > >>>>>>> within
> > > > > >>>>>>>
> > > > > >>>>> them.
> > > > > >>>>>
> > > > > >>>>>>>> So, in one event handler of a component I would like to set
> > > > > >>>>>>>> some
> > > > > >>>>>>>>
> > > > > >>>>>>>>
> > > > > >>>>>>> property or
> > > > > >>>>>>>
> > > > > >>>>>>>
> > > > > >>>>>>>> another (in the page object), and the other components in
> > the
> > > > > >>>>>>>>
> > > > > >>>>>>>>
> > > > > >>>>>>> page,
> > > > > >>>>>>>
> > > > > >>>>> which
> > > > > >>>>>
> > > > > >>>>>>>> are also able to access this property may change their
> > > > > >>>>>>>>
> > > > > >>>>>>>>
> > > > > >>>>>>> appearance
> > > > > >>>>>>>
> > > > > >>>>> (say, the
> > > > > >>>>>
> > > > > >>>>>>>> .TML would test the property). Maybe I'm on a wrong track,
> > > > > >>>>>>>>
> > > > > >>>>>>>>
> > > > > >>>>>>> please
> > > > > >>>>>>>
> > > > > >>>>> let
> > > > > >>>>>
> > > > > >>>>>
> > > > > >>>>>> me
> > > > > >>>>>>
> > > > > >>>>>>>> know :)
> > > > > >>>>>>>>
> > > > > >>>>>>>> thx
> > > > > >>>>>>>> Cheers,
> > > > > >>>>>>>> janos
> > > > > >>>>>>>>
> > > > > >>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > > > >>>>>>>>
> > > > > >>>>>>>>
> > > > > >>>>>>>>  Janos,
> > > > > >>>>>>>>
> > > > > >>>>>>>>> I'm having a hard time understanding a case that a
> > component
> > > > > >>>>>>>>>
> > > > > >>>>>>>>>
> > > > > >>>>>>>> should
> > > > > >>>>>>>>
> > > > > >>>>> know
> > > > > >>>>>
> > > > > >>>>>>>> in which page it is embedded, so my suggestion probably
> > > wasn't
> > > > > >>>>>>>>
> > > > > >>>>>>>> a
> > > > > >>>>>>>>
> > > > > >>>>> good
> > > > > >>>>>
> > > > > >>>>>
> > > > > >>>>>> one. Activation contexts aren't meant for components but for
> > > > > >>>>>>
> > > > > >>>>>>>> pages
> > > > > >>>>>>>>
> > > > > >>>>> -
> > > > > >>>>>
> > > > > >>>>>
> > > > > >>>>>> you
> > > > > >>>>>>
> > > > > >>>>>>>> should be using component parameters to configure them, and
> > > if
> > > > > >>>>>>>>
> > > > > >>>>>>>> it's
> > > > > >>>>>>>>
> > > > > >>>>> a
> > > > > >>>>>
> > > > > >>>>>
> > > > > >>>>>> more sophisticated component, probably a service.
> > > > > >>>>>>
> > > > > >>>>>>>>> chris
> > > > > >>>>>>>>>
> > > > > >>>>>>>>> János Jarecsni wrote:
> > > > > >>>>>>>>>
> > > > > >>>>>>>>>  and how a component can get to know the page in which it
> > is
> > > > > >>>>>>>>>
> > > > > >>>>>>>>> included? I
> > > > > >>>>>>>>>
> > > > > >>>>>>>> mean, I can't @InjectPage, as the component will be
> > included
> > > > > >>>>>>>>
> > > > > >>>>>>>>> in
> > > > > >>>>>>>>>
> > > > > >>>>> many
> > > > > >>>>>
> > > > > >>>>>
> > > > > >>>>>> kinds
> > > > > >>>>>>
> > > > > >>>>>>>>>  of pages.
> > > > > >>>>>>>>>
> > > > > >>>>>>>>>> @Kristian: thx for the many ways :) I'll try these, hope
> > > > > >>>>>>>>>> that
> > > > > >>>>>>>>>>
> > > > > >>>>>>>>>>
> > > > > >>>>>>>>> the
> > > > > >>>>>>>>>
> > > > > >>>>> @Environmental stuff is scalable (I'm trying to bypass session
> > > > > >>>>>
> > > > > >>>>>>>>> creation
> > > > > >>>>>>>>>
> > > > > >>>>>>>> as
> > > > > >>>>>>>>
> > > > > >>>>>>>>>  much as possible)
> > > > > >>>>>>>>>
> > > > > >>>>>>>>>> Is there a doc on the various annotations available?
> > > > > >>>>>>>>>>
> > > > > >>>>>>>>>> @Michael:
> > > > > >>>>>>>>>> Could you include a tiny bit of example? THX!
> > > > > >>>>>>>>>>
> > > > > >>>>>>>>>> Thx to you all
> > > > > >>>>>>>>>> cheers
> > > > > >>>>>>>>>> janos
> > > > > >>>>>>>>>>
> > > > > >>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > > > >>>>>>>>>>
> > > > > >>>>>>>>>>
> > > > > >>>>>>>>>>
> > > > > >>>>>>>>>>  5) @InjectPage the page and call the getter
> > > > > >>>>>>>>>>
> > > > > >>>>>>>>>>> Kristian Marinkovic wrote:
> > > > > >>>>>>>>>>>
> > > > > >>>>>>>>>>>
> > > > > >>>>>>>>>>>  hi janos,
> > > > > >>>>>>>>>>>
> > > > > >>>>>>>>>>>> there are several possibilities:
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> 1) declare a component parameter and pass in the
> > > > > >>>>>>>>>>>> variable
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> 2) put it in a ASO and inject the ASO in all your
> > > > > >>>>>>>>>>>> components
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>> (using
> > > > > >>>>>>>>>>>
> > > > > >>>>>>>> @ApplicationState)
> > > > > >>>>>>>>
> > > > > >>>>>>>>>>>> the drawback is that any other page or component will
> > > > > >>>>>>>>>>>> be
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>> able to
> > > > > >>>>>>>>>>>
> > > > > >>>>> access
> > > > > >>>>>
> > > > > >>>>>>>>>  the ASO
> > > > > >>>>>>>>>
> > > > > >>>>>>>>>>>> 3) put it into the Environment and read it whereever
> > > > > >>>>>>>>>>>> you
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>> need it
> > > > > >>>>>>>>>>>
> > > > > >>>>> in
> > > > > >>>>>
> > > > > >>>>>>>> your
> > > > > >>>>>>>>
> > > > > >>>>>>>>>  nested components.
> > > > > >>>>>>>>>
> > > > > >>>>>>>>>>>> be careful when you put your object in your
> > > > > >>>>>>>>>>>> environment. if
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>> you
> > > > > >>>>>>>>>>>
> > > > > >>>>> put it
> > > > > >>>>>
> > > > > >>>>>>>>>>>>  in
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>  during the action
> > > > > >>>>>>>>>>>
> > > > > >>>>>>>>>>>> request it will not be able in the render request
> > > > > >>>>>>>>>>>> (because
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>> of
> > > > > >>>>>>>>>>>
> > > > > >>>>> the
> > > > > >>>>>
> > > > > >>>>>
> > > > > >>>>>> page
> > > > > >>>>>>
> > > > > >>>>>>>> redirect).
> > > > > >>>>>>>>
> > > > > >>>>>>>>>>>> page:
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> @Inject Environment env;
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> @Persist("flash") whateverclass w;
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> onActivate(w) {  this.w= w }
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> setupRender() { env.push(whateverclass.class,w);}
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> components:
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> @Environmental Whateverclass var;
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> 4) define a service that can take this variable (and
> > > > > >>>>>>>>>>>> saves
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>> it
> > > > > >>>>>>>>>>>
> > > > > >>>>>>>>>>>>  appropriatly
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>  so it is not
> > > > > >>>>>>>>>>>
> > > > > >>>>>>>>>>>> lost on a redirect:)) and inject your service in the
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>> components
> > > > > >>>>>>>>>>>
> > > > > >>>>> where
> > > > > >>>>>
> > > > > >>>>>>>> needed
> > > > > >>>>>>>>
> > > > > >>>>>>>>>>>> to retrieve the value.
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> maybe there are some more possibilities :)
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> g,
> > > > > >>>>>>>>>>>> kris
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> "János Jarecsni" <ja...@gmail.com>
> > > > > >>>>>>>>>>>> 29.04.2008 08:15
> > > > > >>>>>>>>>>>> Bitte antworten an
> > > > > >>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> An
> > > > > >>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
> > > > > >>>>>>>>>>>> Kopie
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> Thema
> > > > > >>>>>>>>>>>> page activation + components
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> Hi there,
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> I have an activatable page, in its onActivate(String
> > > > > >>>>>>>>>>>> param)
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>> method
> > > > > >>>>>>>>>>>
> > > > > >>>>>> I
> > > > > >>>>>>
> > > > > >>>>>>>>>>>>  save
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>  the param to a normal instance variable of the page
> > > > > >>>>>>>>>>>
> > > > > >>>>>>>>>>>> class
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>> (no
> > > > > >>>>>>>>>>>
> > > > > >>>>> persistence!).
> > > > > >>>>>
> > > > > >>>>>>>>>>>> How can any component embedded within this page access
> > > > > >>>>>>>>>>>> this
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>> variable?
> > > > > >>>>>>>>>>>
> > > > > >>>>>>>> the page class:
> > > > > >>>>>>>>
> > > > > >>>>>>>>>>>> //...
> > > > > >>>>>>>>>>>> private String param;
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> public void onActivate(String param) {
> > > > > >>>>>>>>>>>>   this.param = param;
> > > > > >>>>>>>>>>>> }
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> public String getParam() {...}
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> Thx in advance!
> > > > > >>>>>>>>>>>> Janos
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>  --
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>> http://thegodcode.net
> > > > > >>>>>>>>>>>
> > > > > >>>>>>>>>>>
> > > > > >>>>>>>>>>>
> > > > > >>>>>>>>>>>
> > > > > ------------------------------------------------------------------
> > > > > >>>>>>>>>>>
> > > > > >>>>>> ---
> > > > > >>>>>>
> > > > > >>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > > >>>>>
> > > > > >>>>>>>>>>> For additional commands, e-mail: users-
> > > > > >>>>>>>>>>>
> > > > > >>>>>>>>>>>
> > > > > >>>>>>>>>> help@tapestry.apache.org
> > > > > >>>>>>>>>>
> > > > > >>>>>>>>>>>  --
> > > > > >>>>>>>>>>>
> > > > > >>>>>>>>> http://thegodcode.net
> > > > > >>>>>>>>>
> > > > > >>>>>>>>>
> > > > > >>>>>>>>>
> > > > > >>>>>>>>>
> > > > >
> > ---------------------------------------------------------------------
> > > > > >>>>>>>>>
> > > > > >>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > > >>>>>>
> > > > > >>>>>>>>> For additional commands, e-mail:
> > > > > >>>>>>>>> users-help@tapestry.apache.org
> > > > > >>>>>>>>>
> > > > > >>>>>>>>>
> > > > > >>>>>>>>>
> > > > > >>>>>>>>>  --
> > > > > >>>>>>>>>
> > > > > >>>>>>> http://thegodcode.net
> > > > > >>>>>>>
> > > > > >>>>>>>
> > > > > >>>>>>>
> > > > > >>>>>>>
> > > ------------------------------------------------------------------
> > > > > >>>>>>>
> > > > > >>>>>>>
> > > > > >>>>>> ---
> > > > > >>>>>>
> > > > > >>>>> 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
> > > > > >>>>
> > > > > >>>>
> > > > > >>>
> > > > > >>
> > > ---------------------------------------------------------------------
> > > > > >>
> > > > > >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > > >> For additional commands, e-mail: users-help@tapestry.apache.org
> > > > > >>
> > > > > >>
> > > > > >>
> > > > >
> > > > > --
> > > > > http://thegodcode.net
> > > > >
> > > > >
> > > > >
> > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > > For additional commands, e-mail: users-help@tapestry.apache.org
> > > > >
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > --
> > > TheDailyTube.com. Sign up and get the best new videos on the internet
> > > delivered fresh to your inbox.
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
>



-- 
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.

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


Re: page activation + components

Posted by nicholas Krul <ni...@gmail.com>.
Hi.

'My intention is to defer session creation until it is absolutely necessary'
I agree with you on that...

Why don't you use persistence and store it in a cookie? for simple
(non-hibernate) objects, its fine.

Form Validation creates a session for flash persistence... nothing in the
session, but a session none the less.

--nK


On Fri, May 2, 2008 at 3:55 PM, János Jarecsni <ja...@gmail.com>
wrote:

> Hi,
>
> yes still listening :) thx so much for the replies. I start responding
> here.
> Well, you're right Josh, I don't care for the URL. My intention is to
> defer
> session creation until it is absolutely necessary (like when the user is
> logged in or has put some goods in a shopping cart). Although I think I
> only
> need to "remember" 1 thing at a time, the last action. In my theory all my
> component instances (I use this word to emphasize I can have n instances
> of
> a stock monitor component, each monitoring a different paper) have a
> configuration. So I don't have to pass all bits of info in the URL... On
> an
> admin site or using properties files, whatever the basic stuff is
> preconfigured for a component instance. What gets passed in the URL is any
> information the action processing needs. I don't know how clearly I can
> describe this :) but the important thing is component instances render
> themselves according to their configuration, and one of them changes its
> state according to some action on the user's side. Hm... life is not that
> simple I have to admit. I can easily think of a site where the user clicks
> around, changing the states of multiple components (like changing a
> weather
> monitor state code to NY or asking for a voter component to show voting
> status and so on). It would be bad if the last action would clear this
> "state", resulting in all components rendering the default state. If we
> really stick to deferred session creation then this state has to be
> encoded
> somehow and get sent to the client with every response (the developer
> would
> have to use some encodeStateInUrl() method to generate the link to
> preserve
> the actual state and add the new bit. At this point I really start to
> question deferred session creation... :) maybe an easier approach that
> session is not created for for the start page, but all this component
> state
> is session persisted. Ok, it may not be as scalable...
>
> cheers
> Janos
>
> 2008/4/30 Josh Canfield <jo...@thedailytube.com>:
>
> > Are you trying to keep the news id out of the url? Doesn't sound like
> > it from your response to not doing the redirect. Since that's the
> > case, why not add it to the page context?
> >
> > I suppose if you were building a portal with several components then
> > keeping track of component parameters could get unwieldy. If you were
> > showing a news article from the news portlet, and a stock highlight
> > from the stock portlet... At that point you're sort of building a
> > framework on a framework.
> >
> > You could build your page such that it accumulated context from it's
> > components. Push a ComponentContext object into the Environment
> > onActivate, and setupRender in your page (env gets cleared before
> > render phase, not sure if there is a better way than doing it in
> > both.) Then collect component parameter mappings. onPassivate for your
> > page would organize and return these as it's context (you might want
> > to sort them to get consistent results)
> >
> > Your url might look like this:
> >
> > http://localhost/context/mypage/cc/news/4527/stock/MCD
> >
> > Then onactivate you init the ComponentContext from the url keying off
> > the "cc" to grab the remaining parameters and use them as key/value
> > for the components. The your components do something like:
> >
> > @Environmental
> > private ComponentContext _compContext;
> >
> > void setupRender() {
> >  Long newsId = _compContext.getLong(_resources.getId());
> > }
> >
> > void onPickNewsItem(Long id) {
> >  _compContext.put(_resources.getId(), id);
> > }
> >
> >
> > Josh
> >
> > On Wed, Apr 30, 2008 at 5:23 AM, János Jarecsni
> > <ja...@gmail.com> wrote:
> > > Hi Chris,
> > >
> > > I try to explain :)
> > > Say, you have a "NewsQuote" component, which shows a few lines from
> the
> > 5
> > > latest news. At the and of each quotations, there a "More" link. Now,
> > when
> > > the user clicks on this link (an action link, for that matter), the
> > > NewsQuote component will set a request scope info saying that the news
> > with
> > > ID=4527 is requested. And when it comes to the "News" component (it is
> > able
> > > to show the text of a given news in full), it simply looks at this
> piece
> > of
> > > info, and loads the news with id 4527 (or gets it from an app level
> > cache
> > > :)) and renders it.
> > >
> > > Hope it tells something about what I am up to :)
> > >
> > > thx
> > > Janos
> > >
> > > 2008/4/30 Chris Lewis <ch...@bellsouth.net>:
> > >
> > >
> > > > Honestly it's difficult for me to imagine a situation where I'd do
> > that
> > > > because it seems to violate a degree of encapsulation that tapestry
> > > > imposes as a "freeing law" of the framework. The epicenter of that
> > being
> > > > that one should not think in terms of low-level idioms such as
> request
> > > > parameters, and instead replace those with a higher level of
> > application
> > > > logic that eclipses them entirely (when possible). That's not to say
> > > > that your perspective is flawed, but from the small bit of
> > understanding
> > > > I've taken from your posts I can't see why one would do what you
> want.
> > > > The thing that I've been saying is missing here is, what are you
> > trying
> > > > to do? I don't mean technically, I mean what is the end result for
> the
> > > > user? Understanding this is critical, but even if I don't your
> problem
> > > > can still be solved by using a session to serve as an arbitrary
> > holder.
> > > > If you've settled on this architecture, why not write such a generic
> > > > service and move on?
> > > >
> > > > János Jarecsni wrote:
> > > > > Hi,
> > > > >
> > > > > I looked everywhere for usage of request scope variables, but
> found
> > > > nothing
> > > > > (maybe I'm impatient a bit :)...
> > > > > Is it really that unrealistic to have two components in a page,
> one
> > (A)
> > > > > having an action link eventhandler where it would set some
> attribute
> > for
> > > > the
> > > > > request only (not the session!) and then component B could render
> > itself
> > > > > according to the attribute set by component A?
> > > > >
> > > > > I think it should be a piece of cake :)
> > > > >
> > > > > thx
> > > > > Janos
> > > > >
> > > > > 2008/4/30 Filip S. Adamsen <fs...@fsadev.com>:
> > > > >
> > > > >
> > > > >> Nope, you're exactly right.
> > > > >>
> > > > >> -Filip
> > > > >>
> > > > >> Blower, Andy skrev:
> > > > >>
> > > > >>  This is not what I understood 'perthread' scope to be. I thought
> > that
> > > > it
> > > > >>
> > > > >>> meant that each thread using a service gets its own instance of
> > the
> > > > service
> > > > >>> to use, even though that instance may not be the same as any
> > previous
> > > > >>> instance it used. In other words, nothing to do with user
> > sessions,
> > > > it's
> > > > >>> just for services that are not thread safe and cannot be
> > singletons.
> > > > >>>
> > > > >>> Have I got the wrong end of the stick here?
> > > > >>>
> > > > >>>  -----Original Message-----
> > > > >>>
> > > > >>>> From: Andy Huhn [mailto:amhuhn@hrtc.net]
> > > > >>>> Sent: 29 April 2008 17:34
> > > > >>>> To: Tapestry users
> > > > >>>> Subject: Re: page activation + components
> > > > >>>>
> > > > >>>>
> > > > >>>> Hello,
> > > > >>>>
> > > > >>>> You can define the scope of each service...you can set that
> > > > particular
> > > > >>>> service to be tied to only one session.
> > > > >>>>
> > > > >>>> See
> > http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html,
> > > > >>>> and
> > > > >>>> search for "perthread".
> > > > >>>>
> > > > >>>> Thanks,
> > > > >>>> Andy
> > > > >>>>
> > > > >>>> On Tue, 29 Apr 2008 18:02:52 +0200, "János Jarecsni"
> > > > >>>> <ja...@gmail.com> wrote:
> > > > >>>>
> > > > >>>>
> > > > >>>>> Hi there,
> > > > >>>>>
> > > > >>>>> the service approach (as I expected) is session-agnostic (and
> is
> > > > >>>>> page-independent so concurrent users would interfere badly),
> > > > >>>>>
> > > > >>>>>
> > > > >>>> therefore is
> > > > >>>>
> > > > >>>>
> > > > >>>>> not ok.
> > > > >>>>>
> > > > >>>>> I will now try the Environment approach... if that is
> > session-aware
> > > > >>>>>
> > > > >>>>>
> > > > >>>> :)
> > > > >>>>
> > > > >>>>
> > > > >>>>> thx again
> > > > >>>>> janos
> > > > >>>>>
> > > > >>>>> 2008/4/29 János Jarecsni <ja...@gmail.com>:
> > > > >>>>>
> > > > >>>>>  Hi Chris,
> > > > >>>>>
> > > > >>>>>> even so you could help :) I want this kind of generic way of
> > > > >>>>>> passing
> > > > >>>>>> around information (component to component communication :))
> so
> > > > >>>>>> I'll
> > > > >>>>>>
> > > > >>>>>>
> > > > >>>>> look
> > > > >>>>>
> > > > >>>>>
> > > > >>>>>> for the solutions Kristian and you outlined.
> > > > >>>>>>
> > > > >>>>>> thanks!
> > > > >>>>>>
> > > > >>>>>> cheers,
> > > > >>>>>> janos
> > > > >>>>>>
> > > > >>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > > >>>>>>
> > > > >>>>>>  Janos,
> > > > >>>>>>
> > > > >>>>>>> Without code or a description of your actual goal, I'm
> finding
> > > > >>>>>>>
> > > > >>>>>>>
> > > > >>>>>> your
> > > > >>>>>>
> > > > >>>>> situation too hypothetical to really digest. The one thing I
> can
> > > > >>>>>
> > > > >>>>>> point
> > > > >>>>>>
> > > > >>>>> out is what you said about wanting a component to set a
> property
> > > > >>>>>
> > > > >>>>>> in
> > > > >>>>>>
> > > > >>>>> the
> > > > >>>>>
> > > > >>>>>
> > > > >>>>>> page. If you want to do that, then you have to know the class
> > of
> > > > >>>>>>
> > > > >>>>>> the
> > > > >>>>>>
> > > > >>>>> page and so injecting a page would make sense. Of course that
> > > > >>>>>
> > > > >>>>>> means
> > > > >>>>>>
> > > > >>>>> tightly coupling a component to a page, which to me doesn't
> make
> > > > >>>>>
> > > > >>>>>> sense.
> > > > >>>>>>
> > > > >>>>>> If you simply need a generic way of passing data between
> pages
> > and
> > > > >>>>>>
> > > > >>>>>>> components, consider using a service that provides an
> untyped
> > > > >>>>>>> list
> > > > >>>>>>>
> > > > >>>>>>>
> > > > >>>>>> or
> > > > >>>>>>
> > > > >>>>> putting something in the environment as Kristian suggested.
> I'm
> > > > >>>>>
> > > > >>>>>> sorry
> > > > >>>>>>
> > > > >>>>> I
> > > > >>>>>
> > > > >>>>>
> > > > >>>>>> can't be more helpful but as I said I'm not clear on what
> > you're
> > > > >>>>>>
> > > > >>>>>> really
> > > > >>>>>>
> > > > >>>>>> trying to do.
> > > > >>>>>>
> > > > >>>>>>> good luck
> > > > >>>>>>> chris
> > > > >>>>>>>
> > > > >>>>>>> János Jarecsni wrote:
> > > > >>>>>>>
> > > > >>>>>>>
> > > > >>>>>>>> Hi Chris,
> > > > >>>>>>>>
> > > > >>>>>>>> I thought of pages as "contexts" for the components
> embedded
> > > > >>>>>>>>
> > > > >>>>>>>>
> > > > >>>>>>> within
> > > > >>>>>>>
> > > > >>>>> them.
> > > > >>>>>
> > > > >>>>>>>> So, in one event handler of a component I would like to set
> > > > >>>>>>>> some
> > > > >>>>>>>>
> > > > >>>>>>>>
> > > > >>>>>>> property or
> > > > >>>>>>>
> > > > >>>>>>>
> > > > >>>>>>>> another (in the page object), and the other components in
> the
> > > > >>>>>>>>
> > > > >>>>>>>>
> > > > >>>>>>> page,
> > > > >>>>>>>
> > > > >>>>> which
> > > > >>>>>
> > > > >>>>>>>> are also able to access this property may change their
> > > > >>>>>>>>
> > > > >>>>>>>>
> > > > >>>>>>> appearance
> > > > >>>>>>>
> > > > >>>>> (say, the
> > > > >>>>>
> > > > >>>>>>>> .TML would test the property). Maybe I'm on a wrong track,
> > > > >>>>>>>>
> > > > >>>>>>>>
> > > > >>>>>>> please
> > > > >>>>>>>
> > > > >>>>> let
> > > > >>>>>
> > > > >>>>>
> > > > >>>>>> me
> > > > >>>>>>
> > > > >>>>>>>> know :)
> > > > >>>>>>>>
> > > > >>>>>>>> thx
> > > > >>>>>>>> Cheers,
> > > > >>>>>>>> janos
> > > > >>>>>>>>
> > > > >>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > > >>>>>>>>
> > > > >>>>>>>>
> > > > >>>>>>>>  Janos,
> > > > >>>>>>>>
> > > > >>>>>>>>> I'm having a hard time understanding a case that a
> component
> > > > >>>>>>>>>
> > > > >>>>>>>>>
> > > > >>>>>>>> should
> > > > >>>>>>>>
> > > > >>>>> know
> > > > >>>>>
> > > > >>>>>>>> in which page it is embedded, so my suggestion probably
> > wasn't
> > > > >>>>>>>>
> > > > >>>>>>>> a
> > > > >>>>>>>>
> > > > >>>>> good
> > > > >>>>>
> > > > >>>>>
> > > > >>>>>> one. Activation contexts aren't meant for components but for
> > > > >>>>>>
> > > > >>>>>>>> pages
> > > > >>>>>>>>
> > > > >>>>> -
> > > > >>>>>
> > > > >>>>>
> > > > >>>>>> you
> > > > >>>>>>
> > > > >>>>>>>> should be using component parameters to configure them, and
> > if
> > > > >>>>>>>>
> > > > >>>>>>>> it's
> > > > >>>>>>>>
> > > > >>>>> a
> > > > >>>>>
> > > > >>>>>
> > > > >>>>>> more sophisticated component, probably a service.
> > > > >>>>>>
> > > > >>>>>>>>> chris
> > > > >>>>>>>>>
> > > > >>>>>>>>> János Jarecsni wrote:
> > > > >>>>>>>>>
> > > > >>>>>>>>>  and how a component can get to know the page in which it
> is
> > > > >>>>>>>>>
> > > > >>>>>>>>> included? I
> > > > >>>>>>>>>
> > > > >>>>>>>> mean, I can't @InjectPage, as the component will be
> included
> > > > >>>>>>>>
> > > > >>>>>>>>> in
> > > > >>>>>>>>>
> > > > >>>>> many
> > > > >>>>>
> > > > >>>>>
> > > > >>>>>> kinds
> > > > >>>>>>
> > > > >>>>>>>>>  of pages.
> > > > >>>>>>>>>
> > > > >>>>>>>>>> @Kristian: thx for the many ways :) I'll try these, hope
> > > > >>>>>>>>>> that
> > > > >>>>>>>>>>
> > > > >>>>>>>>>>
> > > > >>>>>>>>> the
> > > > >>>>>>>>>
> > > > >>>>> @Environmental stuff is scalable (I'm trying to bypass session
> > > > >>>>>
> > > > >>>>>>>>> creation
> > > > >>>>>>>>>
> > > > >>>>>>>> as
> > > > >>>>>>>>
> > > > >>>>>>>>>  much as possible)
> > > > >>>>>>>>>
> > > > >>>>>>>>>> Is there a doc on the various annotations available?
> > > > >>>>>>>>>>
> > > > >>>>>>>>>> @Michael:
> > > > >>>>>>>>>> Could you include a tiny bit of example? THX!
> > > > >>>>>>>>>>
> > > > >>>>>>>>>> Thx to you all
> > > > >>>>>>>>>> cheers
> > > > >>>>>>>>>> janos
> > > > >>>>>>>>>>
> > > > >>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > > >>>>>>>>>>
> > > > >>>>>>>>>>
> > > > >>>>>>>>>>
> > > > >>>>>>>>>>  5) @InjectPage the page and call the getter
> > > > >>>>>>>>>>
> > > > >>>>>>>>>>> Kristian Marinkovic wrote:
> > > > >>>>>>>>>>>
> > > > >>>>>>>>>>>
> > > > >>>>>>>>>>>  hi janos,
> > > > >>>>>>>>>>>
> > > > >>>>>>>>>>>> there are several possibilities:
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> 1) declare a component parameter and pass in the
> > > > >>>>>>>>>>>> variable
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> 2) put it in a ASO and inject the ASO in all your
> > > > >>>>>>>>>>>> components
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>> (using
> > > > >>>>>>>>>>>
> > > > >>>>>>>> @ApplicationState)
> > > > >>>>>>>>
> > > > >>>>>>>>>>>> the drawback is that any other page or component will
> > > > >>>>>>>>>>>> be
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>> able to
> > > > >>>>>>>>>>>
> > > > >>>>> access
> > > > >>>>>
> > > > >>>>>>>>>  the ASO
> > > > >>>>>>>>>
> > > > >>>>>>>>>>>> 3) put it into the Environment and read it whereever
> > > > >>>>>>>>>>>> you
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>> need it
> > > > >>>>>>>>>>>
> > > > >>>>> in
> > > > >>>>>
> > > > >>>>>>>> your
> > > > >>>>>>>>
> > > > >>>>>>>>>  nested components.
> > > > >>>>>>>>>
> > > > >>>>>>>>>>>> be careful when you put your object in your
> > > > >>>>>>>>>>>> environment. if
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>> you
> > > > >>>>>>>>>>>
> > > > >>>>> put it
> > > > >>>>>
> > > > >>>>>>>>>>>>  in
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>  during the action
> > > > >>>>>>>>>>>
> > > > >>>>>>>>>>>> request it will not be able in the render request
> > > > >>>>>>>>>>>> (because
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>> of
> > > > >>>>>>>>>>>
> > > > >>>>> the
> > > > >>>>>
> > > > >>>>>
> > > > >>>>>> page
> > > > >>>>>>
> > > > >>>>>>>> redirect).
> > > > >>>>>>>>
> > > > >>>>>>>>>>>> page:
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> @Inject Environment env;
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> @Persist("flash") whateverclass w;
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> onActivate(w) {  this.w= w }
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> setupRender() { env.push(whateverclass.class,w);}
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> components:
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> @Environmental Whateverclass var;
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> 4) define a service that can take this variable (and
> > > > >>>>>>>>>>>> saves
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>> it
> > > > >>>>>>>>>>>
> > > > >>>>>>>>>>>>  appropriatly
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>  so it is not
> > > > >>>>>>>>>>>
> > > > >>>>>>>>>>>> lost on a redirect:)) and inject your service in the
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>> components
> > > > >>>>>>>>>>>
> > > > >>>>> where
> > > > >>>>>
> > > > >>>>>>>> needed
> > > > >>>>>>>>
> > > > >>>>>>>>>>>> to retrieve the value.
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> maybe there are some more possibilities :)
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> g,
> > > > >>>>>>>>>>>> kris
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> "János Jarecsni" <ja...@gmail.com>
> > > > >>>>>>>>>>>> 29.04.2008 08:15
> > > > >>>>>>>>>>>> Bitte antworten an
> > > > >>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> An
> > > > >>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
> > > > >>>>>>>>>>>> Kopie
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> Thema
> > > > >>>>>>>>>>>> page activation + components
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> Hi there,
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> I have an activatable page, in its onActivate(String
> > > > >>>>>>>>>>>> param)
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>> method
> > > > >>>>>>>>>>>
> > > > >>>>>> I
> > > > >>>>>>
> > > > >>>>>>>>>>>>  save
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>  the param to a normal instance variable of the page
> > > > >>>>>>>>>>>
> > > > >>>>>>>>>>>> class
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>> (no
> > > > >>>>>>>>>>>
> > > > >>>>> persistence!).
> > > > >>>>>
> > > > >>>>>>>>>>>> How can any component embedded within this page access
> > > > >>>>>>>>>>>> this
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>> variable?
> > > > >>>>>>>>>>>
> > > > >>>>>>>> the page class:
> > > > >>>>>>>>
> > > > >>>>>>>>>>>> //...
> > > > >>>>>>>>>>>> private String param;
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> public void onActivate(String param) {
> > > > >>>>>>>>>>>>   this.param = param;
> > > > >>>>>>>>>>>> }
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> public String getParam() {...}
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> Thx in advance!
> > > > >>>>>>>>>>>> Janos
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>  --
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>> http://thegodcode.net
> > > > >>>>>>>>>>>
> > > > >>>>>>>>>>>
> > > > >>>>>>>>>>>
> > > > >>>>>>>>>>>
> > > > ------------------------------------------------------------------
> > > > >>>>>>>>>>>
> > > > >>>>>> ---
> > > > >>>>>>
> > > > >>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > >>>>>
> > > > >>>>>>>>>>> For additional commands, e-mail: users-
> > > > >>>>>>>>>>>
> > > > >>>>>>>>>>>
> > > > >>>>>>>>>> help@tapestry.apache.org
> > > > >>>>>>>>>>
> > > > >>>>>>>>>>>  --
> > > > >>>>>>>>>>>
> > > > >>>>>>>>> http://thegodcode.net
> > > > >>>>>>>>>
> > > > >>>>>>>>>
> > > > >>>>>>>>>
> > > > >>>>>>>>>
> > > >
> ---------------------------------------------------------------------
> > > > >>>>>>>>>
> > > > >>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > >>>>>>
> > > > >>>>>>>>> For additional commands, e-mail:
> > > > >>>>>>>>> users-help@tapestry.apache.org
> > > > >>>>>>>>>
> > > > >>>>>>>>>
> > > > >>>>>>>>>
> > > > >>>>>>>>>  --
> > > > >>>>>>>>>
> > > > >>>>>>> http://thegodcode.net
> > > > >>>>>>>
> > > > >>>>>>>
> > > > >>>>>>>
> > > > >>>>>>>
> > ------------------------------------------------------------------
> > > > >>>>>>>
> > > > >>>>>>>
> > > > >>>>>> ---
> > > > >>>>>>
> > > > >>>>> 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
> > > > >>>>
> > > > >>>>
> > > > >>>
> > > > >>
> > ---------------------------------------------------------------------
> > > > >>
> > > > >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > >> For additional commands, e-mail: users-help@tapestry.apache.org
> > > > >>
> > > > >>
> > > > >>
> > > >
> > > > --
> > > > http://thegodcode.net
> > > >
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > For additional commands, e-mail: users-help@tapestry.apache.org
> > > >
> > > >
> > >
> >
> >
> >
> > --
> > --
> > TheDailyTube.com. Sign up and get the best new videos on the internet
> > delivered fresh to your inbox.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>

Re: page activation + components

Posted by János Jarecsni <ja...@gmail.com>.
Hi Kris,
I'd like to avoid the session - as far as possible, say until login has
done. What I'd like to do is to set a value in the request in one component
and read that value in another component (or the page itself) (both
components are in the same page). Like in the example I sent: the action
link event handler sets the attribute and the page tries to display that
(with no effect :))

hope this is more concrete - and thx you haven't given up helping me out :)

janos

2008/4/30 Kristian Marinkovic <kr...@porsche.co.at>:

> if you inject the Tapestry Request services - available in any pages,
> components
> and mixins - you can access the HttpSession in an abstract way via the
> Session
> interface. If you want the real stuff you can inject the RequestGlobals
> instance :)
>
> nevertheless i'd not use the HttpSession directly but try to use one of
> the provided
> services to do so. For example you can inject the ApplicationStateManager
> to
> put/get instances from the HttpSession. The only thing you have to be
> aware of
> is that if you put in a instance with the classname foo.class any page
> that declares
> @ApplicationState Foo f; will have this instance
>
> you could also use a PropertyShadowBuilder to abstract the access to a
> certain
> property/attribute  of the HttpSession ... but that's another story :)
>
> i'm still not sure what your use-case is. if you elaborate more on your
> problem
> will probably be able to give a more concise advice :)
>
> g,
> kris
>
>
>
>
> "János Jarecsni" <ja...@gmail.com>
> 30.04.2008 08:50
> Bitte antworten an
> "Tapestry users" <us...@tapestry.apache.org>
>
>
> An
> "Tapestry users" <us...@tapestry.apache.org>
> Kopie
>
> Thema
> Re: page activation + components
>
>
>
>
>
>
> Hi,
>
> thx for the info! Another idea... is there a HttpRequest like object
> available to components and pages? If it were, then setting a request
> attribute would be ok for me. Anyway the per-request service is similar to
> this, so it will be ok for me.
>
> thx again
> janos
>
> 2008/4/29 Andy Huhn <am...@hrtc.net>:
>
> >
> > Hello,
> >
> > You can define the scope of each service...you can set that particular
> > service to be tied to only one session.
> >
> > See http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html, and
> > search for "perthread".
> >
> > Thanks,
> > Andy
> >
> > On Tue, 29 Apr 2008 18:02:52 +0200, "János Jarecsni"
> > <ja...@gmail.com> wrote:
> > > Hi there,
> > >
> > > the service approach (as I expected) is session-agnostic (and is
> > > page-independent so concurrent users would interfere badly), therefore
> > is
> > > not ok.
> > >
> > > I will now try the Environment approach... if that is session-aware :)
> > >
> > > thx again
> > > janos
> > >
> > > 2008/4/29 János Jarecsni <ja...@gmail.com>:
> > >
> > >> Hi Chris,
> > >>
> > >> even so you could help :) I want this kind of generic way of passing
> > >> around information (component to component communication :)) so I'll
> > > look
> > >> for the solutions Kristian and you outlined.
> > >>
> > >> thanks!
> > >>
> > >> cheers,
> > >> janos
> > >>
> > >> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > >>
> > >> > Janos,
> > >> >
> > >> > Without code or a description of your actual goal, I'm finding your
> > >> > situation too hypothetical to really digest. The one thing I can
> > point
> > >> > out is what you said about wanting a component to set a property in
> > > the
> > >> > page. If you want to do that, then you have to know the class of
> the
> > >> > page and so injecting a page would make sense. Of course that means
> > >> > tightly coupling a component to a page, which to me doesn't make
> > > sense.
> > >> > If you simply need a generic way of passing data between pages and
> > >> > components, consider using a service that provides an untyped list
> or
> > >> > putting something in the environment as Kristian suggested. I'm
> sorry
> > > I
> > >> > can't be more helpful but as I said I'm not clear on what you're
> > > really
> > >> > trying to do.
> > >> >
> > >> > good luck
> > >> > chris
> > >> >
> > >> > János Jarecsni wrote:
> > >> > > Hi Chris,
> > >> > >
> > >> > > I thought of pages as "contexts" for the components embedded
> within
> > >> > them.
> > >> > > So, in one event handler of a component I would like to set some
> > >> > property or
> > >> > > another (in the page object), and the other components in the
> page,
> > >> > which
> > >> > > are also able to access this property may change their appearance
> > >> > (say, the
> > >> > > .TML would test the property). Maybe I'm on a wrong track, please
> > > let
> > >> > me
> > >> > > know :)
> > >> > >
> > >> > > thx
> > >> > > Cheers,
> > >> > > janos
> > >> > >
> > >> > > 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > >> > >
> > >> > >
> > >> > >> Janos,
> > >> > >>
> > >> > >> I'm having a hard time understanding a case that a component
> > should
> > >> > know
> > >> > >> in which page it is embedded, so my suggestion probably wasn't a
> > > good
> > >> > >> one. Activation contexts aren't meant for components but for
> pages
> > > -
> > >> > you
> > >> > >> should be using component parameters to configure them, and if
> > it's
> > > a
> > >> > >> more sophisticated component, probably a service.
> > >> > >>
> > >> > >> chris
> > >> > >>
> > >> > >> János Jarecsni wrote:
> > >> > >>
> > >> > >>> and how a component can get to know the page in which it is
> > >> > included? I
> > >> > >>> mean, I can't @InjectPage, as the component will be included in
> > > many
> > >> > >>>
> > >> > >> kinds
> > >> > >>
> > >> > >>> of pages.
> > >> > >>>
> > >> > >>> @Kristian: thx for the many ways :) I'll try these, hope that
> the
> > >> > >>> @Environmental stuff is scalable (I'm trying to bypass session
> > >> > creation
> > >> > >>>
> > >> > >> as
> > >> > >>
> > >> > >>> much as possible)
> > >> > >>>
> > >> > >>> Is there a doc on the various annotations available?
> > >> > >>>
> > >> > >>> @Michael:
> > >> > >>> Could you include a tiny bit of example? THX!
> > >> > >>>
> > >> > >>> Thx to you all
> > >> > >>> cheers
> > >> > >>> janos
> > >> > >>>
> > >> > >>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > >> > >>>
> > >> > >>>
> > >> > >>>
> > >> > >>>> 5) @InjectPage the page and call the getter
> > >> > >>>>
> > >> > >>>> Kristian Marinkovic wrote:
> > >> > >>>>
> > >> > >>>>
> > >> > >>>>> hi janos,
> > >> > >>>>>
> > >> > >>>>> there are several possibilities:
> > >> > >>>>>
> > >> > >>>>> 1) declare a component parameter and pass in the variable
> > >> > >>>>>
> > >> > >>>>> 2) put it in a ASO and inject the ASO in all your components
> > >> > (using
> > >> > >>>>> @ApplicationState)
> > >> > >>>>> the drawback is that any other page or component will be able
> > to
> > >> > >>>>>
> > >> > >> access
> > >> > >>
> > >> > >>>>> the ASO
> > >> > >>>>>
> > >> > >>>>> 3) put it into the Environment and read it whereever you need
> > it
> > >> > in
> > >> > >>>>>
> > >> > >> your
> > >> > >>
> > >> > >>>>> nested components.
> > >> > >>>>> be careful when you put your object in your environment. if
> you
> > >> > put it
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>> in
> > >> > >>>>
> > >> > >>>>
> > >> > >>>>> during the action
> > >> > >>>>> request it will not be able in the render request (because of
> > > the
> > >> > page
> > >> > >>>>> redirect).
> > >> > >>>>>
> > >> > >>>>> page:
> > >> > >>>>>
> > >> > >>>>> @Inject Environment env;
> > >> > >>>>>
> > >> > >>>>> @Persist("flash") whateverclass w;
> > >> > >>>>>
> > >> > >>>>> onActivate(w) {  this.w= w }
> > >> > >>>>>
> > >> > >>>>> setupRender() { env.push(whateverclass.class,w);}
> > >> > >>>>>
> > >> > >>>>> components:
> > >> > >>>>>
> > >> > >>>>> @Environmental Whateverclass var;
> > >> > >>>>>
> > >> > >>>>> 4) define a service that can take this variable (and saves it
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>> appropriatly
> > >> > >>>>
> > >> > >>>>
> > >> > >>>>> so it is not
> > >> > >>>>> lost on a redirect:)) and inject your service in the
> components
> > >> > where
> > >> > >>>>> needed
> > >> > >>>>> to retrieve the value.
> > >> > >>>>>
> > >> > >>>>> maybe there are some more possibilities :)
> > >> > >>>>>
> > >> > >>>>> g,
> > >> > >>>>> kris
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>> "János Jarecsni" <ja...@gmail.com>
> > >> > >>>>> 29.04.2008 08:15
> > >> > >>>>> Bitte antworten an
> > >> > >>>>> "Tapestry users" <us...@tapestry.apache.org>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>> An
> > >> > >>>>> "Tapestry users" <us...@tapestry.apache.org>
> > >> > >>>>> Kopie
> > >> > >>>>>
> > >> > >>>>> Thema
> > >> > >>>>> page activation + components
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>> Hi there,
> > >> > >>>>>
> > >> > >>>>> I have an activatable page, in its onActivate(String param)
> > > method
> > >> > I
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>> save
> > >> > >>>>
> > >> > >>>>
> > >> > >>>>> the param to a normal instance variable of the page class (no
> > >> > >>>>> persistence!).
> > >> > >>>>> How can any component embedded within this page access this
> > >> > variable?
> > >> > >>>>>
> > >> > >>>>> the page class:
> > >> > >>>>>
> > >> > >>>>> //...
> > >> > >>>>> private String param;
> > >> > >>>>>
> > >> > >>>>> public void onActivate(String param) {
> > >> > >>>>>    this.param = param;
> > >> > >>>>> }
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>> public String getParam() {...}
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>> Thx in advance!
> > >> > >>>>> Janos
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>> --
> > >> > >>>> http://thegodcode.net
> > >> > >>>>
> > >> > >>>>
> > >> > >>>>
> > >> >
> ---------------------------------------------------------------------
> > >> > >>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > >> > >>>> For additional commands, e-mail:
> users-help@tapestry.apache.org
> > >> > >>>>
> > >> > >>>>
> > >> > >>>>
> > >> > >>>>
> > >> > >> --
> > >> > >> http://thegodcode.net
> > >> > >>
> > >> > >>
> > >> > >>
> > > ---------------------------------------------------------------------
> > >> > >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > >> > >> For additional commands, e-mail: users-help@tapestry.apache.org
> > >> > >>
> > >> > >>
> > >> > >>
> > >> >
> > >> > --
> > >> > http://thegodcode.net
> > >> >
> > >> >
> > >> >
> ---------------------------------------------------------------------
> > >> > 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: page activation + components

Posted by Kristian Marinkovic <kr...@porsche.co.at>.
if you inject the Tapestry Request services - available in any pages, 
components
and mixins - you can access the HttpSession in an abstract way via the 
Session 
interface. If you want the real stuff you can inject the RequestGlobals 
instance :)

nevertheless i'd not use the HttpSession directly but try to use one of 
the provided
services to do so. For example you can inject the ApplicationStateManager 
to 
put/get instances from the HttpSession. The only thing you have to be 
aware of
is that if you put in a instance with the classname foo.class any page 
that declares
@ApplicationState Foo f; will have this instance 

you could also use a PropertyShadowBuilder to abstract the access to a 
certain
property/attribute  of the HttpSession ... but that's another story :)

i'm still not sure what your use-case is. if you elaborate more on your 
problem 
will probably be able to give a more concise advice :)

g,
kris




"János Jarecsni" <ja...@gmail.com> 
30.04.2008 08:50
Bitte antworten an
"Tapestry users" <us...@tapestry.apache.org>


An
"Tapestry users" <us...@tapestry.apache.org>
Kopie

Thema
Re: page activation + components






Hi,

thx for the info! Another idea... is there a HttpRequest like object
available to components and pages? If it were, then setting a request
attribute would be ok for me. Anyway the per-request service is similar to
this, so it will be ok for me.

thx again
janos

2008/4/29 Andy Huhn <am...@hrtc.net>:

>
> Hello,
>
> You can define the scope of each service...you can set that particular
> service to be tied to only one session.
>
> See http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html, and
> search for "perthread".
>
> Thanks,
> Andy
>
> On Tue, 29 Apr 2008 18:02:52 +0200, "János Jarecsni"
> <ja...@gmail.com> wrote:
> > Hi there,
> >
> > the service approach (as I expected) is session-agnostic (and is
> > page-independent so concurrent users would interfere badly), therefore
> is
> > not ok.
> >
> > I will now try the Environment approach... if that is session-aware :)
> >
> > thx again
> > janos
> >
> > 2008/4/29 János Jarecsni <ja...@gmail.com>:
> >
> >> Hi Chris,
> >>
> >> even so you could help :) I want this kind of generic way of passing
> >> around information (component to component communication :)) so I'll
> > look
> >> for the solutions Kristian and you outlined.
> >>
> >> thanks!
> >>
> >> cheers,
> >> janos
> >>
> >> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> >>
> >> > Janos,
> >> >
> >> > Without code or a description of your actual goal, I'm finding your
> >> > situation too hypothetical to really digest. The one thing I can
> point
> >> > out is what you said about wanting a component to set a property in
> > the
> >> > page. If you want to do that, then you have to know the class of 
the
> >> > page and so injecting a page would make sense. Of course that means
> >> > tightly coupling a component to a page, which to me doesn't make
> > sense.
> >> > If you simply need a generic way of passing data between pages and
> >> > components, consider using a service that provides an untyped list 
or
> >> > putting something in the environment as Kristian suggested. I'm 
sorry
> > I
> >> > can't be more helpful but as I said I'm not clear on what you're
> > really
> >> > trying to do.
> >> >
> >> > good luck
> >> > chris
> >> >
> >> > János Jarecsni wrote:
> >> > > Hi Chris,
> >> > >
> >> > > I thought of pages as "contexts" for the components embedded 
within
> >> > them.
> >> > > So, in one event handler of a component I would like to set some
> >> > property or
> >> > > another (in the page object), and the other components in the 
page,
> >> > which
> >> > > are also able to access this property may change their appearance
> >> > (say, the
> >> > > .TML would test the property). Maybe I'm on a wrong track, please
> > let
> >> > me
> >> > > know :)
> >> > >
> >> > > thx
> >> > > Cheers,
> >> > > janos
> >> > >
> >> > > 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> >> > >
> >> > >
> >> > >> Janos,
> >> > >>
> >> > >> I'm having a hard time understanding a case that a component
> should
> >> > know
> >> > >> in which page it is embedded, so my suggestion probably wasn't a
> > good
> >> > >> one. Activation contexts aren't meant for components but for 
pages
> > -
> >> > you
> >> > >> should be using component parameters to configure them, and if
> it's
> > a
> >> > >> more sophisticated component, probably a service.
> >> > >>
> >> > >> chris
> >> > >>
> >> > >> János Jarecsni wrote:
> >> > >>
> >> > >>> and how a component can get to know the page in which it is
> >> > included? I
> >> > >>> mean, I can't @InjectPage, as the component will be included in
> > many
> >> > >>>
> >> > >> kinds
> >> > >>
> >> > >>> of pages.
> >> > >>>
> >> > >>> @Kristian: thx for the many ways :) I'll try these, hope that 
the
> >> > >>> @Environmental stuff is scalable (I'm trying to bypass session
> >> > creation
> >> > >>>
> >> > >> as
> >> > >>
> >> > >>> much as possible)
> >> > >>>
> >> > >>> Is there a doc on the various annotations available?
> >> > >>>
> >> > >>> @Michael:
> >> > >>> Could you include a tiny bit of example? THX!
> >> > >>>
> >> > >>> Thx to you all
> >> > >>> cheers
> >> > >>> janos
> >> > >>>
> >> > >>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> >> > >>>
> >> > >>>
> >> > >>>
> >> > >>>> 5) @InjectPage the page and call the getter
> >> > >>>>
> >> > >>>> Kristian Marinkovic wrote:
> >> > >>>>
> >> > >>>>
> >> > >>>>> hi janos,
> >> > >>>>>
> >> > >>>>> there are several possibilities:
> >> > >>>>>
> >> > >>>>> 1) declare a component parameter and pass in the variable
> >> > >>>>>
> >> > >>>>> 2) put it in a ASO and inject the ASO in all your components
> >> > (using
> >> > >>>>> @ApplicationState)
> >> > >>>>> the drawback is that any other page or component will be able
> to
> >> > >>>>>
> >> > >> access
> >> > >>
> >> > >>>>> the ASO
> >> > >>>>>
> >> > >>>>> 3) put it into the Environment and read it whereever you need
> it
> >> > in
> >> > >>>>>
> >> > >> your
> >> > >>
> >> > >>>>> nested components.
> >> > >>>>> be careful when you put your object in your environment. if 
you
> >> > put it
> >> > >>>>>
> >> > >>>>>
> >> > >>>> in
> >> > >>>>
> >> > >>>>
> >> > >>>>> during the action
> >> > >>>>> request it will not be able in the render request (because of
> > the
> >> > page
> >> > >>>>> redirect).
> >> > >>>>>
> >> > >>>>> page:
> >> > >>>>>
> >> > >>>>> @Inject Environment env;
> >> > >>>>>
> >> > >>>>> @Persist("flash") whateverclass w;
> >> > >>>>>
> >> > >>>>> onActivate(w) {  this.w= w }
> >> > >>>>>
> >> > >>>>> setupRender() { env.push(whateverclass.class,w);}
> >> > >>>>>
> >> > >>>>> components:
> >> > >>>>>
> >> > >>>>> @Environmental Whateverclass var;
> >> > >>>>>
> >> > >>>>> 4) define a service that can take this variable (and saves it
> >> > >>>>>
> >> > >>>>>
> >> > >>>> appropriatly
> >> > >>>>
> >> > >>>>
> >> > >>>>> so it is not
> >> > >>>>> lost on a redirect:)) and inject your service in the 
components
> >> > where
> >> > >>>>> needed
> >> > >>>>> to retrieve the value.
> >> > >>>>>
> >> > >>>>> maybe there are some more possibilities :)
> >> > >>>>>
> >> > >>>>> g,
> >> > >>>>> kris
> >> > >>>>>
> >> > >>>>>
> >> > >>>>>
> >> > >>>>>
> >> > >>>>> "János Jarecsni" <ja...@gmail.com>
> >> > >>>>> 29.04.2008 08:15
> >> > >>>>> Bitte antworten an
> >> > >>>>> "Tapestry users" <us...@tapestry.apache.org>
> >> > >>>>>
> >> > >>>>>
> >> > >>>>> An
> >> > >>>>> "Tapestry users" <us...@tapestry.apache.org>
> >> > >>>>> Kopie
> >> > >>>>>
> >> > >>>>> Thema
> >> > >>>>> page activation + components
> >> > >>>>>
> >> > >>>>>
> >> > >>>>>
> >> > >>>>>
> >> > >>>>>
> >> > >>>>>
> >> > >>>>> Hi there,
> >> > >>>>>
> >> > >>>>> I have an activatable page, in its onActivate(String param)
> > method
> >> > I
> >> > >>>>>
> >> > >>>>>
> >> > >>>> save
> >> > >>>>
> >> > >>>>
> >> > >>>>> the param to a normal instance variable of the page class (no
> >> > >>>>> persistence!).
> >> > >>>>> How can any component embedded within this page access this
> >> > variable?
> >> > >>>>>
> >> > >>>>> the page class:
> >> > >>>>>
> >> > >>>>> //...
> >> > >>>>> private String param;
> >> > >>>>>
> >> > >>>>> public void onActivate(String param) {
> >> > >>>>>    this.param = param;
> >> > >>>>> }
> >> > >>>>>
> >> > >>>>>
> >> > >>>>> public String getParam() {...}
> >> > >>>>>
> >> > >>>>>
> >> > >>>>> Thx in advance!
> >> > >>>>> Janos
> >> > >>>>>
> >> > >>>>>
> >> > >>>>>
> >> > >>>>>
> >> > >>>>>
> >> > >>>> --
> >> > >>>> http://thegodcode.net
> >> > >>>>
> >> > >>>>
> >> > >>>>
> >> > 
---------------------------------------------------------------------
> >> > >>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> > >>>> For additional commands, e-mail: 
users-help@tapestry.apache.org
> >> > >>>>
> >> > >>>>
> >> > >>>>
> >> > >>>>
> >> > >> --
> >> > >> http://thegodcode.net
> >> > >>
> >> > >>
> >> > >>
> > ---------------------------------------------------------------------
> >> > >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> > >> For additional commands, e-mail: users-help@tapestry.apache.org
> >> > >>
> >> > >>
> >> > >>
> >> >
> >> > --
> >> > http://thegodcode.net
> >> >
> >> >
> >> > 
---------------------------------------------------------------------
> >> > 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: page activation + components

Posted by János Jarecsni <ja...@gmail.com>.
Hi there,

finally I put together a minimalistic test to proof the idea.

1. I have a simple component, named SetRequestParameter, its purpose is to
receive something from an actionlink (it is on its template) and set that
value in a per-request way.

1.1 the template for this component
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
    <a href="#" t:type="ActionLink" t:id="requestLink"
t:context="${time}">Set request value</a>
</html>

1.2 the java code for this component
    @Inject
    private Request request;

    @Inject
    private ApplicationStateStore state;

    @Inject
    private Logger log;

    @OnEvent(component = "requestLink")
    Object onRequestLink( String param) {
        request.setAttribute("currentTime", param);
        state.setState("currentTime", param);
        log.info("setting state on " + state.hashCode());
        return null;
    }

    public String getTime() {
        return "" + System.currentTimeMillis();
    }

1.3 the Start.tml (where I include the above component)
        <p> The current time is: ${currentTime}. </p>

        <t:SetRequestParameter/>
and finally, the java code for it:

    @Inject
    private ApplicationStateStore state;

    @Inject
    private Logger log;

    @Inject
    private Request request;

    public Start() {
        log.info(hashCode() + ": Setting state on " + state.hashCode());
        state.setState("start", new Date());
    }

    public String getCurrentTime() {
        log.info("Getting state from " + state.hashCode());
        final Object currentTime = state.getState("currentTime");
        return new Date() + " / " + state.getState("start") + ":::" +
request.getAttribute("currentTime") + "@" + currentTime;
    }

so it's obvious it is only for testing. the getCurrentTime is returning all
stuff, which are for testing where I could insert some request scoped
valules. Oh and yes, the ApplicationStateStore service is perthread. What
happens is, that from the state, and the request I get new instances, so I
use an instance A when setting the values, and an instance B when getting
them.... I'm sure I'm doing something quite wrong here, I don't believe that
the request-session-application scopes don't exist in T.

thx again!
Janos

2008/4/30 János Jarecsni <ja...@gmail.com>:

> Hi,
>
> thx for the info! Another idea... is there a HttpRequest like object
> available to components and pages? If it were, then setting a request
> attribute would be ok for me. Anyway the per-request service is similar to
> this, so it will be ok for me.
>
> thx again
> janos
>
> 2008/4/29 Andy Huhn <am...@hrtc.net>:
>
>
> > Hello,
> >
> > You can define the scope of each service...you can set that particular
> > service to be tied to only one session.
> >
> > See http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html, and
> > search for "perthread".
> >
> > Thanks,
> > Andy
> >
> > On Tue, 29 Apr 2008 18:02:52 +0200, "János Jarecsni"
> > <ja...@gmail.com> wrote:
> > > Hi there,
> > >
> > > the service approach (as I expected) is session-agnostic (and is
> > > page-independent so concurrent users would interfere badly), therefore
> > is
> > > not ok.
> > >
> > > I will now try the Environment approach... if that is session-aware :)
> > >
> > > thx again
> > > janos
> > >
> > > 2008/4/29 János Jarecsni <ja...@gmail.com>:
> > >
> > >> Hi Chris,
> > >>
> > >> even so you could help :) I want this kind of generic way of passing
> > >> around information (component to component communication :)) so I'll
> > > look
> > >> for the solutions Kristian and you outlined.
> > >>
> > >> thanks!
> > >>
> > >> cheers,
> > >> janos
> > >>
> > >> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > >>
> > >> > Janos,
> > >> >
> > >> > Without code or a description of your actual goal, I'm finding your
> > >> > situation too hypothetical to really digest. The one thing I can
> > point
> > >> > out is what you said about wanting a component to set a property in
> > > the
> > >> > page. If you want to do that, then you have to know the class of
> > the
> > >> > page and so injecting a page would make sense. Of course that means
> > >> > tightly coupling a component to a page, which to me doesn't make
> > > sense.
> > >> > If you simply need a generic way of passing data between pages and
> > >> > components, consider using a service that provides an untyped list
> > or
> > >> > putting something in the environment as Kristian suggested. I'm
> > sorry
> > > I
> > >> > can't be more helpful but as I said I'm not clear on what you're
> > > really
> > >> > trying to do.
> > >> >
> > >> > good luck
> > >> > chris
> > >> >
> > >> > János Jarecsni wrote:
> > >> > > Hi Chris,
> > >> > >
> > >> > > I thought of pages as "contexts" for the components embedded
> > within
> > >> > them.
> > >> > > So, in one event handler of a component I would like to set some
> > >> > property or
> > >> > > another (in the page object), and the other components in the
> > page,
> > >> > which
> > >> > > are also able to access this property may change their appearance
> > >> > (say, the
> > >> > > .TML would test the property). Maybe I'm on a wrong track, please
> > > let
> > >> > me
> > >> > > know :)
> > >> > >
> > >> > > thx
> > >> > > Cheers,
> > >> > > janos
> > >> > >
> > >> > > 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > >> > >
> > >> > >
> > >> > >> Janos,
> > >> > >>
> > >> > >> I'm having a hard time understanding a case that a component
> > should
> > >> > know
> > >> > >> in which page it is embedded, so my suggestion probably wasn't a
> > > good
> > >> > >> one. Activation contexts aren't meant for components but for
> > pages
> > > -
> > >> > you
> > >> > >> should be using component parameters to configure them, and if
> > it's
> > > a
> > >> > >> more sophisticated component, probably a service.
> > >> > >>
> > >> > >> chris
> > >> > >>
> > >> > >> János Jarecsni wrote:
> > >> > >>
> > >> > >>> and how a component can get to know the page in which it is
> > >> > included? I
> > >> > >>> mean, I can't @InjectPage, as the component will be included in
> > > many
> > >> > >>>
> > >> > >> kinds
> > >> > >>
> > >> > >>> of pages.
> > >> > >>>
> > >> > >>> @Kristian: thx for the many ways :) I'll try these, hope that
> > the
> > >> > >>> @Environmental stuff is scalable (I'm trying to bypass session
> > >> > creation
> > >> > >>>
> > >> > >> as
> > >> > >>
> > >> > >>> much as possible)
> > >> > >>>
> > >> > >>> Is there a doc on the various annotations available?
> > >> > >>>
> > >> > >>> @Michael:
> > >> > >>> Could you include a tiny bit of example? THX!
> > >> > >>>
> > >> > >>> Thx to you all
> > >> > >>> cheers
> > >> > >>> janos
> > >> > >>>
> > >> > >>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > >> > >>>
> > >> > >>>
> > >> > >>>
> > >> > >>>> 5) @InjectPage the page and call the getter
> > >> > >>>>
> > >> > >>>> Kristian Marinkovic wrote:
> > >> > >>>>
> > >> > >>>>
> > >> > >>>>> hi janos,
> > >> > >>>>>
> > >> > >>>>> there are several possibilities:
> > >> > >>>>>
> > >> > >>>>> 1) declare a component parameter and pass in the variable
> > >> > >>>>>
> > >> > >>>>> 2) put it in a ASO and inject the ASO in all your components
> > >> > (using
> > >> > >>>>> @ApplicationState)
> > >> > >>>>> the drawback is that any other page or component will be able
> > to
> > >> > >>>>>
> > >> > >> access
> > >> > >>
> > >> > >>>>> the ASO
> > >> > >>>>>
> > >> > >>>>> 3) put it into the Environment and read it whereever you need
> > it
> > >> > in
> > >> > >>>>>
> > >> > >> your
> > >> > >>
> > >> > >>>>> nested components.
> > >> > >>>>> be careful when you put your object in your environment. if
> > you
> > >> > put it
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>> in
> > >> > >>>>
> > >> > >>>>
> > >> > >>>>> during the action
> > >> > >>>>> request it will not be able in the render request (because of
> > > the
> > >> > page
> > >> > >>>>> redirect).
> > >> > >>>>>
> > >> > >>>>> page:
> > >> > >>>>>
> > >> > >>>>> @Inject Environment env;
> > >> > >>>>>
> > >> > >>>>> @Persist("flash") whateverclass w;
> > >> > >>>>>
> > >> > >>>>> onActivate(w) {  this.w= w }
> > >> > >>>>>
> > >> > >>>>> setupRender() { env.push(whateverclass.class,w);}
> > >> > >>>>>
> > >> > >>>>> components:
> > >> > >>>>>
> > >> > >>>>> @Environmental Whateverclass var;
> > >> > >>>>>
> > >> > >>>>> 4) define a service that can take this variable (and saves it
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>> appropriatly
> > >> > >>>>
> > >> > >>>>
> > >> > >>>>> so it is not
> > >> > >>>>> lost on a redirect:)) and inject your service in the
> > components
> > >> > where
> > >> > >>>>> needed
> > >> > >>>>> to retrieve the value.
> > >> > >>>>>
> > >> > >>>>> maybe there are some more possibilities :)
> > >> > >>>>>
> > >> > >>>>> g,
> > >> > >>>>> kris
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>> "János Jarecsni" <ja...@gmail.com>
> > >> > >>>>> 29.04.2008 08:15
> > >> > >>>>> Bitte antworten an
> > >> > >>>>> "Tapestry users" <us...@tapestry.apache.org>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>> An
> > >> > >>>>> "Tapestry users" <us...@tapestry.apache.org>
> > >> > >>>>> Kopie
> > >> > >>>>>
> > >> > >>>>> Thema
> > >> > >>>>> page activation + components
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>> Hi there,
> > >> > >>>>>
> > >> > >>>>> I have an activatable page, in its onActivate(String param)
> > > method
> > >> > I
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>> save
> > >> > >>>>
> > >> > >>>>
> > >> > >>>>> the param to a normal instance variable of the page class (no
> > >> > >>>>> persistence!).
> > >> > >>>>> How can any component embedded within this page access this
> > >> > variable?
> > >> > >>>>>
> > >> > >>>>> the page class:
> > >> > >>>>>
> > >> > >>>>> //...
> > >> > >>>>> private String param;
> > >> > >>>>>
> > >> > >>>>> public void onActivate(String param) {
> > >> > >>>>>    this.param = param;
> > >> > >>>>> }
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>> public String getParam() {...}
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>> Thx in advance!
> > >> > >>>>> Janos
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>> --
> > >> > >>>> http://thegodcode.net
> > >> > >>>>
> > >> > >>>>
> > >> > >>>>
> > >> >
> > ---------------------------------------------------------------------
> > >> > >>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > >> > >>>> For additional commands, e-mail:
> > users-help@tapestry.apache.org
> > >> > >>>>
> > >> > >>>>
> > >> > >>>>
> > >> > >>>>
> > >> > >> --
> > >> > >> http://thegodcode.net
> > >> > >>
> > >> > >>
> > >> > >>
> > > ---------------------------------------------------------------------
> > >> > >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > >> > >> For additional commands, e-mail: users-help@tapestry.apache.org
> > >> > >>
> > >> > >>
> > >> > >>
> > >> >
> > >> > --
> > >> > http://thegodcode.net
> > >> >
> > >> >
> > >> >
> > ---------------------------------------------------------------------
> > >> > 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: page activation + components

Posted by János Jarecsni <ja...@gmail.com>.
Hi,

thx for the info! Another idea... is there a HttpRequest like object
available to components and pages? If it were, then setting a request
attribute would be ok for me. Anyway the per-request service is similar to
this, so it will be ok for me.

thx again
janos

2008/4/29 Andy Huhn <am...@hrtc.net>:

>
> Hello,
>
> You can define the scope of each service...you can set that particular
> service to be tied to only one session.
>
> See http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html, and
> search for "perthread".
>
> Thanks,
> Andy
>
> On Tue, 29 Apr 2008 18:02:52 +0200, "János Jarecsni"
> <ja...@gmail.com> wrote:
> > Hi there,
> >
> > the service approach (as I expected) is session-agnostic (and is
> > page-independent so concurrent users would interfere badly), therefore
> is
> > not ok.
> >
> > I will now try the Environment approach... if that is session-aware :)
> >
> > thx again
> > janos
> >
> > 2008/4/29 János Jarecsni <ja...@gmail.com>:
> >
> >> Hi Chris,
> >>
> >> even so you could help :) I want this kind of generic way of passing
> >> around information (component to component communication :)) so I'll
> > look
> >> for the solutions Kristian and you outlined.
> >>
> >> thanks!
> >>
> >> cheers,
> >> janos
> >>
> >> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> >>
> >> > Janos,
> >> >
> >> > Without code or a description of your actual goal, I'm finding your
> >> > situation too hypothetical to really digest. The one thing I can
> point
> >> > out is what you said about wanting a component to set a property in
> > the
> >> > page. If you want to do that, then you have to know the class of the
> >> > page and so injecting a page would make sense. Of course that means
> >> > tightly coupling a component to a page, which to me doesn't make
> > sense.
> >> > If you simply need a generic way of passing data between pages and
> >> > components, consider using a service that provides an untyped list or
> >> > putting something in the environment as Kristian suggested. I'm sorry
> > I
> >> > can't be more helpful but as I said I'm not clear on what you're
> > really
> >> > trying to do.
> >> >
> >> > good luck
> >> > chris
> >> >
> >> > János Jarecsni wrote:
> >> > > Hi Chris,
> >> > >
> >> > > I thought of pages as "contexts" for the components embedded within
> >> > them.
> >> > > So, in one event handler of a component I would like to set some
> >> > property or
> >> > > another (in the page object), and the other components in the page,
> >> > which
> >> > > are also able to access this property may change their appearance
> >> > (say, the
> >> > > .TML would test the property). Maybe I'm on a wrong track, please
> > let
> >> > me
> >> > > know :)
> >> > >
> >> > > thx
> >> > > Cheers,
> >> > > janos
> >> > >
> >> > > 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> >> > >
> >> > >
> >> > >> Janos,
> >> > >>
> >> > >> I'm having a hard time understanding a case that a component
> should
> >> > know
> >> > >> in which page it is embedded, so my suggestion probably wasn't a
> > good
> >> > >> one. Activation contexts aren't meant for components but for pages
> > -
> >> > you
> >> > >> should be using component parameters to configure them, and if
> it's
> > a
> >> > >> more sophisticated component, probably a service.
> >> > >>
> >> > >> chris
> >> > >>
> >> > >> János Jarecsni wrote:
> >> > >>
> >> > >>> and how a component can get to know the page in which it is
> >> > included? I
> >> > >>> mean, I can't @InjectPage, as the component will be included in
> > many
> >> > >>>
> >> > >> kinds
> >> > >>
> >> > >>> of pages.
> >> > >>>
> >> > >>> @Kristian: thx for the many ways :) I'll try these, hope that the
> >> > >>> @Environmental stuff is scalable (I'm trying to bypass session
> >> > creation
> >> > >>>
> >> > >> as
> >> > >>
> >> > >>> much as possible)
> >> > >>>
> >> > >>> Is there a doc on the various annotations available?
> >> > >>>
> >> > >>> @Michael:
> >> > >>> Could you include a tiny bit of example? THX!
> >> > >>>
> >> > >>> Thx to you all
> >> > >>> cheers
> >> > >>> janos
> >> > >>>
> >> > >>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> >> > >>>
> >> > >>>
> >> > >>>
> >> > >>>> 5) @InjectPage the page and call the getter
> >> > >>>>
> >> > >>>> Kristian Marinkovic wrote:
> >> > >>>>
> >> > >>>>
> >> > >>>>> hi janos,
> >> > >>>>>
> >> > >>>>> there are several possibilities:
> >> > >>>>>
> >> > >>>>> 1) declare a component parameter and pass in the variable
> >> > >>>>>
> >> > >>>>> 2) put it in a ASO and inject the ASO in all your components
> >> > (using
> >> > >>>>> @ApplicationState)
> >> > >>>>> the drawback is that any other page or component will be able
> to
> >> > >>>>>
> >> > >> access
> >> > >>
> >> > >>>>> the ASO
> >> > >>>>>
> >> > >>>>> 3) put it into the Environment and read it whereever you need
> it
> >> > in
> >> > >>>>>
> >> > >> your
> >> > >>
> >> > >>>>> nested components.
> >> > >>>>> be careful when you put your object in your environment. if you
> >> > put it
> >> > >>>>>
> >> > >>>>>
> >> > >>>> in
> >> > >>>>
> >> > >>>>
> >> > >>>>> during the action
> >> > >>>>> request it will not be able in the render request (because of
> > the
> >> > page
> >> > >>>>> redirect).
> >> > >>>>>
> >> > >>>>> page:
> >> > >>>>>
> >> > >>>>> @Inject Environment env;
> >> > >>>>>
> >> > >>>>> @Persist("flash") whateverclass w;
> >> > >>>>>
> >> > >>>>> onActivate(w) {  this.w= w }
> >> > >>>>>
> >> > >>>>> setupRender() { env.push(whateverclass.class,w);}
> >> > >>>>>
> >> > >>>>> components:
> >> > >>>>>
> >> > >>>>> @Environmental Whateverclass var;
> >> > >>>>>
> >> > >>>>> 4) define a service that can take this variable (and saves it
> >> > >>>>>
> >> > >>>>>
> >> > >>>> appropriatly
> >> > >>>>
> >> > >>>>
> >> > >>>>> so it is not
> >> > >>>>> lost on a redirect:)) and inject your service in the components
> >> > where
> >> > >>>>> needed
> >> > >>>>> to retrieve the value.
> >> > >>>>>
> >> > >>>>> maybe there are some more possibilities :)
> >> > >>>>>
> >> > >>>>> g,
> >> > >>>>> kris
> >> > >>>>>
> >> > >>>>>
> >> > >>>>>
> >> > >>>>>
> >> > >>>>> "János Jarecsni" <ja...@gmail.com>
> >> > >>>>> 29.04.2008 08:15
> >> > >>>>> Bitte antworten an
> >> > >>>>> "Tapestry users" <us...@tapestry.apache.org>
> >> > >>>>>
> >> > >>>>>
> >> > >>>>> An
> >> > >>>>> "Tapestry users" <us...@tapestry.apache.org>
> >> > >>>>> Kopie
> >> > >>>>>
> >> > >>>>> Thema
> >> > >>>>> page activation + components
> >> > >>>>>
> >> > >>>>>
> >> > >>>>>
> >> > >>>>>
> >> > >>>>>
> >> > >>>>>
> >> > >>>>> Hi there,
> >> > >>>>>
> >> > >>>>> I have an activatable page, in its onActivate(String param)
> > method
> >> > I
> >> > >>>>>
> >> > >>>>>
> >> > >>>> save
> >> > >>>>
> >> > >>>>
> >> > >>>>> the param to a normal instance variable of the page class (no
> >> > >>>>> persistence!).
> >> > >>>>> How can any component embedded within this page access this
> >> > variable?
> >> > >>>>>
> >> > >>>>> the page class:
> >> > >>>>>
> >> > >>>>> //...
> >> > >>>>> private String param;
> >> > >>>>>
> >> > >>>>> public void onActivate(String param) {
> >> > >>>>>    this.param = param;
> >> > >>>>> }
> >> > >>>>>
> >> > >>>>>
> >> > >>>>> public String getParam() {...}
> >> > >>>>>
> >> > >>>>>
> >> > >>>>> Thx in advance!
> >> > >>>>> Janos
> >> > >>>>>
> >> > >>>>>
> >> > >>>>>
> >> > >>>>>
> >> > >>>>>
> >> > >>>> --
> >> > >>>> http://thegodcode.net
> >> > >>>>
> >> > >>>>
> >> > >>>>
> >> > ---------------------------------------------------------------------
> >> > >>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> > >>>> For additional commands, e-mail: users-help@tapestry.apache.org
> >> > >>>>
> >> > >>>>
> >> > >>>>
> >> > >>>>
> >> > >> --
> >> > >> http://thegodcode.net
> >> > >>
> >> > >>
> >> > >>
> > ---------------------------------------------------------------------
> >> > >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> > >> For additional commands, e-mail: users-help@tapestry.apache.org
> >> > >>
> >> > >>
> >> > >>
> >> >
> >> > --
> >> > http://thegodcode.net
> >> >
> >> >
> >> > ---------------------------------------------------------------------
> >> > 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: page activation + components

Posted by Chris Lewis <ch...@bellsouth.net>.
My emails keep getting rejected - I'm sorry to break this up so much.

3) The component writes out links with generated action link URLs,
firing the "itemselected" action. We catch handle that action in the
component and propagate it by firing a new event, "viewitem":

    void onItemselected(long newsId) {
       
        // This is our handler for the action links we created, and the
context,
        // newsId, will be the id of a NewsItem. The NewsQuote component's
        // job is to notify the page of the selection, so we fire the event
        // "viewitem" here and a listening page can receive this event
        // in an onViewitem() handler.
       
        resources.triggerEvent("viewitem", new Object[] { newsId }, null);
       
    }

one more coming


Josh Canfield wrote:
> Are you trying to keep the news id out of the url? Doesn't sound like
> it from your response to not doing the redirect. Since that's the
> case, why not add it to the page context?
>
> I suppose if you were building a portal with several components then
> keeping track of component parameters could get unwieldy. If you were
> showing a news article from the news portlet, and a stock highlight
> from the stock portlet... At that point you're sort of building a
> framework on a framework.
>
> You could build your page such that it accumulated context from it's
> components. Push a ComponentContext object into the Environment
> onActivate, and setupRender in your page (env gets cleared before
> render phase, not sure if there is a better way than doing it in
> both.) Then collect component parameter mappings. onPassivate for your
> page would organize and return these as it's context (you might want
> to sort them to get consistent results)
>
> Your url might look like this:
>
> http://localhost/context/mypage/cc/news/4527/stock/MCD
>
> Then onactivate you init the ComponentContext from the url keying off
> the "cc" to grab the remaining parameters and use them as key/value
> for the components. The your components do something like:
>
> @Environmental
> private ComponentContext _compContext;
>
> void setupRender() {
>   Long newsId = _compContext.getLong(_resources.getId());
> }
>
> void onPickNewsItem(Long id) {
>   _compContext.put(_resources.getId(), id);
> }
>
>
> Josh
>
> On Wed, Apr 30, 2008 at 5:23 AM, János Jarecsni
> <ja...@gmail.com> wrote:
>   
>> Hi Chris,
>>
>> I try to explain :)
>> Say, you have a "NewsQuote" component, which shows a few lines from the 5
>> latest news. At the and of each quotations, there a "More" link. Now, when
>> the user clicks on this link (an action link, for that matter), the
>> NewsQuote component will set a request scope info saying that the news with
>> ID=4527 is requested. And when it comes to the "News" component (it is able
>> to show the text of a given news in full), it simply looks at this piece of
>> info, and loads the news with id 4527 (or gets it from an app level cache
>> :)) and renders it.
>>
>> Hope it tells something about what I am up to :)
>>
>> thx
>> Janos
>>
>> 2008/4/30 Chris Lewis <ch...@bellsouth.net>:
>>
>>
>>     
>>> Honestly it's difficult for me to imagine a situation where I'd do that
>>> because it seems to violate a degree of encapsulation that tapestry
>>> imposes as a "freeing law" of the framework. The epicenter of that being
>>> that one should not think in terms of low-level idioms such as request
>>> parameters, and instead replace those with a higher level of application
>>> logic that eclipses them entirely (when possible). That's not to say
>>> that your perspective is flawed, but from the small bit of understanding
>>> I've taken from your posts I can't see why one would do what you want.
>>> The thing that I've been saying is missing here is, what are you trying
>>> to do? I don't mean technically, I mean what is the end result for the
>>> user? Understanding this is critical, but even if I don't your problem
>>> can still be solved by using a session to serve as an arbitrary holder.
>>> If you've settled on this architecture, why not write such a generic
>>> service and move on?
>>>
>>> János Jarecsni wrote:
>>>       
>>>> Hi,
>>>>
>>>> I looked everywhere for usage of request scope variables, but found
>>>>         
>>> nothing
>>>       
>>>> (maybe I'm impatient a bit :)...
>>>> Is it really that unrealistic to have two components in a page, one (A)
>>>> having an action link eventhandler where it would set some attribute for
>>>>         
>>> the
>>>       
>>>> request only (not the session!) and then component B could render itself
>>>> according to the attribute set by component A?
>>>>
>>>> I think it should be a piece of cake :)
>>>>
>>>> thx
>>>> Janos
>>>>
>>>> 2008/4/30 Filip S. Adamsen <fs...@fsadev.com>:
>>>>
>>>>
>>>>         
>>>>> Nope, you're exactly right.
>>>>>
>>>>> -Filip
>>>>>
>>>>> Blower, Andy skrev:
>>>>>
>>>>>  This is not what I understood 'perthread' scope to be. I thought that
>>>>>           
>>> it
>>>       
>>>>>> meant that each thread using a service gets its own instance of the
>>>>>>             
>>> service
>>>       
>>>>>> to use, even though that instance may not be the same as any previous
>>>>>> instance it used. In other words, nothing to do with user sessions,
>>>>>>             
>>> it's
>>>       
>>>>>> just for services that are not thread safe and cannot be singletons.
>>>>>>
>>>>>> Have I got the wrong end of the stick here?
>>>>>>
>>>>>>  -----Original Message-----
>>>>>>
>>>>>>             
>>>>>>> From: Andy Huhn [mailto:amhuhn@hrtc.net]
>>>>>>> Sent: 29 April 2008 17:34
>>>>>>> To: Tapestry users
>>>>>>> Subject: Re: page activation + components
>>>>>>>
>>>>>>>
>>>>>>> Hello,
>>>>>>>
>>>>>>> You can define the scope of each service...you can set that
>>>>>>>               
>>> particular
>>>       
>>>>>>> service to be tied to only one session.
>>>>>>>
>>>>>>> See http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html,
>>>>>>> and
>>>>>>> search for "perthread".
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Andy
>>>>>>>
>>>>>>> On Tue, 29 Apr 2008 18:02:52 +0200, "János Jarecsni"
>>>>>>> <ja...@gmail.com> wrote:
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> Hi there,
>>>>>>>>
>>>>>>>> the service approach (as I expected) is session-agnostic (and is
>>>>>>>> page-independent so concurrent users would interfere badly),
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>> therefore is
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> not ok.
>>>>>>>>
>>>>>>>> I will now try the Environment approach... if that is session-aware
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>> :)
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> thx again
>>>>>>>> janos
>>>>>>>>
>>>>>>>> 2008/4/29 János Jarecsni <ja...@gmail.com>:
>>>>>>>>
>>>>>>>>  Hi Chris,
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> even so you could help :) I want this kind of generic way of
>>>>>>>>> passing
>>>>>>>>> around information (component to component communication :)) so
>>>>>>>>> I'll
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> look
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> for the solutions Kristian and you outlined.
>>>>>>>>>
>>>>>>>>> thanks!
>>>>>>>>>
>>>>>>>>> cheers,
>>>>>>>>> janos
>>>>>>>>>
>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>>>>>>>>>
>>>>>>>>>  Janos,
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> Without code or a description of your actual goal, I'm finding
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> your
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> situation too hypothetical to really digest. The one thing I can
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> point
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> out is what you said about wanting a component to set a property
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> in
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> the
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> page. If you want to do that, then you have to know the class of
>>>>>>>>>
>>>>>>>>> the
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> page and so injecting a page would make sense. Of course that
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> means
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> tightly coupling a component to a page, which to me doesn't make
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> sense.
>>>>>>>>>
>>>>>>>>> If you simply need a generic way of passing data between pages and
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> components, consider using a service that provides an untyped
>>>>>>>>>> list
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> or
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> putting something in the environment as Kristian suggested. I'm
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> sorry
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> I
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> can't be more helpful but as I said I'm not clear on what you're
>>>>>>>>>
>>>>>>>>> really
>>>>>>>>>
>>>>>>>>> trying to do.
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> good luck
>>>>>>>>>> chris
>>>>>>>>>>
>>>>>>>>>> János Jarecsni wrote:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>> Hi Chris,
>>>>>>>>>>>
>>>>>>>>>>> I thought of pages as "contexts" for the components embedded
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> within
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>> them.
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>> So, in one event handler of a component I would like to set
>>>>>>>>>>> some
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> property or
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>> another (in the page object), and the other components in the
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> page,
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>> which
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>> are also able to access this property may change their
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> appearance
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>> (say, the
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>> .TML would test the property). Maybe I'm on a wrong track,
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> please
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>> let
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> me
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>> know :)
>>>>>>>>>>>
>>>>>>>>>>> thx
>>>>>>>>>>> Cheers,
>>>>>>>>>>> janos
>>>>>>>>>>>
>>>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>  Janos,
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>> I'm having a hard time understanding a case that a component
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> should
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>> know
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>> in which page it is embedded, so my suggestion probably wasn't
>>>>>>>>>>>
>>>>>>>>>>> a
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>> good
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> one. Activation contexts aren't meant for components but for
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>> pages
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>> -
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> you
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>> should be using component parameters to configure them, and if
>>>>>>>>>>>
>>>>>>>>>>> it's
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>> a
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> more sophisticated component, probably a service.
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>>> chris
>>>>>>>>>>>>
>>>>>>>>>>>> János Jarecsni wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>  and how a component can get to know the page in which it is
>>>>>>>>>>>>
>>>>>>>>>>>> included? I
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> mean, I can't @InjectPage, as the component will be included
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>> in
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>> many
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> kinds
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>>>  of pages.
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>> @Kristian: thx for the many ways :) I'll try these, hope
>>>>>>>>>>>>> that
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>> the
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>> @Environmental stuff is scalable (I'm trying to bypass session
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>>> creation
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> as
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>>  much as possible)
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>> Is there a doc on the various annotations available?
>>>>>>>>>>>>>
>>>>>>>>>>>>> @Michael:
>>>>>>>>>>>>> Could you include a tiny bit of example? THX!
>>>>>>>>>>>>>
>>>>>>>>>>>>> Thx to you all
>>>>>>>>>>>>> cheers
>>>>>>>>>>>>> janos
>>>>>>>>>>>>>
>>>>>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>  5) @InjectPage the page and call the getter
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>> Kristian Marinkovic wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  hi janos,
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>> there are several possibilities:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> 1) declare a component parameter and pass in the
>>>>>>>>>>>>>>> variable
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> 2) put it in a ASO and inject the ASO in all your
>>>>>>>>>>>>>>> components
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> (using
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>> @ApplicationState)
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>>>>> the drawback is that any other page or component will
>>>>>>>>>>>>>>> be
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> able to
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>> access
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>>>  the ASO
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>>>> 3) put it into the Environment and read it whereever
>>>>>>>>>>>>>>> you
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> need it
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>> in
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>> your
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>>  nested components.
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>>>> be careful when you put your object in your
>>>>>>>>>>>>>>> environment. if
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> you
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>> put it
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>>>>>>  in
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>>  during the action
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>> request it will not be able in the render request
>>>>>>>>>>>>>>> (because
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> of
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>> the
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> page
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>> redirect).
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>>>>> page:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> @Inject Environment env;
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> @Persist("flash") whateverclass w;
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> onActivate(w) {  this.w= w }
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> setupRender() { env.push(whateverclass.class,w);}
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> components:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> @Environmental Whateverclass var;
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> 4) define a service that can take this variable (and
>>>>>>>>>>>>>>> saves
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> it
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>>  appropriatly
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>>  so it is not
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>> lost on a redirect:)) and inject your service in the
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> components
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>> where
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>> needed
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>>>>> to retrieve the value.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> maybe there are some more possibilities :)
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> g,
>>>>>>>>>>>>>>> kris
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> "János Jarecsni" <ja...@gmail.com>
>>>>>>>>>>>>>>> 29.04.2008 08:15
>>>>>>>>>>>>>>> Bitte antworten an
>>>>>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> An
>>>>>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
>>>>>>>>>>>>>>> Kopie
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Thema
>>>>>>>>>>>>>>> page activation + components
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Hi there,
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> I have an activatable page, in its onActivate(String
>>>>>>>>>>>>>>> param)
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> method
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>> I
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>>>>>>  save
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>>  the param to a normal instance variable of the page
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>> class
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> (no
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>> persistence!).
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>>>>>> How can any component embedded within this page access
>>>>>>>>>>>>>>> this
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> variable?
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>> the page class:
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>>>>> //...
>>>>>>>>>>>>>>> private String param;
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> public void onActivate(String param) {
>>>>>>>>>>>>>>>   this.param = param;
>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> public String getParam() {...}
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Thx in advance!
>>>>>>>>>>>>>>> Janos
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>  --
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> http://thegodcode.net
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>> ------------------------------------------------------------------
>>>       
>>>>>>>>> ---
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>>>>> For additional commands, e-mail: users-
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>> help@tapestry.apache.org
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>>  --
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>> http://thegodcode.net
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>> ---------------------------------------------------------------------
>>>       
>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>>> For additional commands, e-mail:
>>>>>>>>>>>> users-help@tapestry.apache.org
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>  --
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>> http://thegodcode.net
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> ------------------------------------------------------------------
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> ---
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> 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
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>> ---------------------------------------------------------------------
>>>>>
>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>
>>>>>
>>>>>
>>>>>           
>>> --
>>> http://thegodcode.net
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>>       
>
>
>
>   

-- 
http://thegodcode.net


Re: page activation + components

Posted by Chris Lewis <ch...@bellsouth.net>.
this the last of it

4) In our embedding page class, News, we have an event handler to be
notified of the selection by handling the "viewitem" event:

    void onViewitem(long id) {
       
        this.currentItem = newsSource.getItemById(id);
        logger.info("got " + this.currentItem.getTitle());

    }


Now if you run this (I can pass along the project with a mock dao, no
real db needed) you'll see that up through the last bit, where the page
handles the event from the NewsQuote component, everything works
perfectly. We catch the event in the page and grab the object. The
problem is still how to deal with the T5-encouraged redirect and
maintain that value in the page, so we can render the news item. That
is, without using @Persist....

Still thinking on this - input welcome!

chris

Josh Canfield wrote:
> Are you trying to keep the news id out of the url? Doesn't sound like
> it from your response to not doing the redirect. Since that's the
> case, why not add it to the page context?
>
> I suppose if you were building a portal with several components then
> keeping track of component parameters could get unwieldy. If you were
> showing a news article from the news portlet, and a stock highlight
> from the stock portlet... At that point you're sort of building a
> framework on a framework.
>
> You could build your page such that it accumulated context from it's
> components. Push a ComponentContext object into the Environment
> onActivate, and setupRender in your page (env gets cleared before
> render phase, not sure if there is a better way than doing it in
> both.) Then collect component parameter mappings. onPassivate for your
> page would organize and return these as it's context (you might want
> to sort them to get consistent results)
>
> Your url might look like this:
>
> http://localhost/context/mypage/cc/news/4527/stock/MCD
>
> Then onactivate you init the ComponentContext from the url keying off
> the "cc" to grab the remaining parameters and use them as key/value
> for the components. The your components do something like:
>
> @Environmental
> private ComponentContext _compContext;
>
> void setupRender() {
>   Long newsId = _compContext.getLong(_resources.getId());
> }
>
> void onPickNewsItem(Long id) {
>   _compContext.put(_resources.getId(), id);
> }
>
>
>   

-- 
http://thegodcode.net


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


Re: page activation + components

Posted by Chris Lewis <ch...@bellsouth.net>.
(one more coming after this - sorry)

1) There is a service in place - likely a DAO - for accessing the news
items (type NewsItem) and is wired up via autobinding in the app module:

    public static void bind(ServiceBinder binder)
    {
        binder.bind(NewsSource.class, NewsSourceExampleImpl.class);
    }


2) NewsQuote component injects this service and writes out links to the
latest 5 items:

    @BeginRender
    void beginRender(MarkupWriter writer) {
       
        // This component writes out NewsItems loaded from a NewsSource
        // into a UL.
       
        writer.element("ul");
       
        for(NewsItem item : newsSource.getLatest(5)) {
           
            writer.element("li");
           
            // Here we create action link URLs and write them into <a>
elements,
            // effectively creating actionlink components on the fly. We
specify
            // the action as "itemselected" and give each the context of a
            // NewsItem id.
           
            Link link = resources.createActionLink("itemselected",
false, item.getId());
            writer.element("a", "href", link.toAbsoluteURI());
            writer.write(item.getTitle());
            writer.end(); //end <a>
           
            writer.end(); //end <li> - use afterRender to close the <ul>
        }
    }

Josh Canfield wrote:
> Are you trying to keep the news id out of the url? Doesn't sound like
> it from your response to not doing the redirect. Since that's the
> case, why not add it to the page context?
>
> I suppose if you were building a portal with several components then
> keeping track of component parameters could get unwieldy. If you were
> showing a news article from the news portlet, and a stock highlight
> from the stock portlet... At that point you're sort of building a
> framework on a framework.
>
> You could build your page such that it accumulated context from it's
> components. Push a ComponentContext object into the Environment
> onActivate, and setupRender in your page (env gets cleared before
> render phase, not sure if there is a better way than doing it in
> both.) Then collect component parameter mappings. onPassivate for your
> page would organize and return these as it's context (you might want
> to sort them to get consistent results)
>
> Your url might look like this:
>
> http://localhost/context/mypage/cc/news/4527/stock/MCD
>
> Then onactivate you init the ComponentContext from the url keying off
> the "cc" to grab the remaining parameters and use them as key/value
> for the components. The your components do something like:
>
> @Environmental
> private ComponentContext _compContext;
>
> void setupRender() {
>   Long newsId = _compContext.getLong(_resources.getId());
> }
>
> void onPickNewsItem(Long id) {
>   _compContext.put(_resources.getId(), id);
> }
>
>
> Josh
>
> On Wed, Apr 30, 2008 at 5:23 AM, János Jarecsni
> <ja...@gmail.com> wrote:
>   
>> Hi Chris,
>>
>> I try to explain :)
>> Say, you have a "NewsQuote" component, which shows a few lines from the 5
>> latest news. At the and of each quotations, there a "More" link. Now, when
>> the user clicks on this link (an action link, for that matter), the
>> NewsQuote component will set a request scope info saying that the news with
>> ID=4527 is requested. And when it comes to the "News" component (it is able
>> to show the text of a given news in full), it simply looks at this piece of
>> info, and loads the news with id 4527 (or gets it from an app level cache
>> :)) and renders it.
>>
>> Hope it tells something about what I am up to :)
>>
>> thx
>> Janos
>>
>> 2008/4/30 Chris Lewis <ch...@bellsouth.net>:
>>
>>
>>     
>>> Honestly it's difficult for me to imagine a situation where I'd do that
>>> because it seems to violate a degree of encapsulation that tapestry
>>> imposes as a "freeing law" of the framework. The epicenter of that being
>>> that one should not think in terms of low-level idioms such as request
>>> parameters, and instead replace those with a higher level of application
>>> logic that eclipses them entirely (when possible). That's not to say
>>> that your perspective is flawed, but from the small bit of understanding
>>> I've taken from your posts I can't see why one would do what you want.
>>> The thing that I've been saying is missing here is, what are you trying
>>> to do? I don't mean technically, I mean what is the end result for the
>>> user? Understanding this is critical, but even if I don't your problem
>>> can still be solved by using a session to serve as an arbitrary holder.
>>> If you've settled on this architecture, why not write such a generic
>>> service and move on?
>>>
>>> János Jarecsni wrote:
>>>       
>>>> Hi,
>>>>
>>>> I looked everywhere for usage of request scope variables, but found
>>>>         
>>> nothing
>>>       
>>>> (maybe I'm impatient a bit :)...
>>>> Is it really that unrealistic to have two components in a page, one (A)
>>>> having an action link eventhandler where it would set some attribute for
>>>>         
>>> the
>>>       
>>>> request only (not the session!) and then component B could render itself
>>>> according to the attribute set by component A?
>>>>
>>>> I think it should be a piece of cake :)
>>>>
>>>> thx
>>>> Janos
>>>>
>>>> 2008/4/30 Filip S. Adamsen <fs...@fsadev.com>:
>>>>
>>>>
>>>>         
>>>>> Nope, you're exactly right.
>>>>>
>>>>> -Filip
>>>>>
>>>>> Blower, Andy skrev:
>>>>>
>>>>>  This is not what I understood 'perthread' scope to be. I thought that
>>>>>           
>>> it
>>>       
>>>>>> meant that each thread using a service gets its own instance of the
>>>>>>             
>>> service
>>>       
>>>>>> to use, even though that instance may not be the same as any previous
>>>>>> instance it used. In other words, nothing to do with user sessions,
>>>>>>             
>>> it's
>>>       
>>>>>> just for services that are not thread safe and cannot be singletons.
>>>>>>
>>>>>> Have I got the wrong end of the stick here?
>>>>>>
>>>>>>  -----Original Message-----
>>>>>>
>>>>>>             
>>>>>>> From: Andy Huhn [mailto:amhuhn@hrtc.net]
>>>>>>> Sent: 29 April 2008 17:34
>>>>>>> To: Tapestry users
>>>>>>> Subject: Re: page activation + components
>>>>>>>
>>>>>>>
>>>>>>> Hello,
>>>>>>>
>>>>>>> You can define the scope of each service...you can set that
>>>>>>>               
>>> particular
>>>       
>>>>>>> service to be tied to only one session.
>>>>>>>
>>>>>>> See http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html,
>>>>>>> and
>>>>>>> search for "perthread".
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Andy
>>>>>>>
>>>>>>> On Tue, 29 Apr 2008 18:02:52 +0200, "János Jarecsni"
>>>>>>> <ja...@gmail.com> wrote:
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> Hi there,
>>>>>>>>
>>>>>>>> the service approach (as I expected) is session-agnostic (and is
>>>>>>>> page-independent so concurrent users would interfere badly),
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>> therefore is
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> not ok.
>>>>>>>>
>>>>>>>> I will now try the Environment approach... if that is session-aware
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>> :)
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> thx again
>>>>>>>> janos
>>>>>>>>
>>>>>>>> 2008/4/29 János Jarecsni <ja...@gmail.com>:
>>>>>>>>
>>>>>>>>  Hi Chris,
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> even so you could help :) I want this kind of generic way of
>>>>>>>>> passing
>>>>>>>>> around information (component to component communication :)) so
>>>>>>>>> I'll
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> look
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> for the solutions Kristian and you outlined.
>>>>>>>>>
>>>>>>>>> thanks!
>>>>>>>>>
>>>>>>>>> cheers,
>>>>>>>>> janos
>>>>>>>>>
>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>>>>>>>>>
>>>>>>>>>  Janos,
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> Without code or a description of your actual goal, I'm finding
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> your
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> situation too hypothetical to really digest. The one thing I can
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> point
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> out is what you said about wanting a component to set a property
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> in
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> the
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> page. If you want to do that, then you have to know the class of
>>>>>>>>>
>>>>>>>>> the
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> page and so injecting a page would make sense. Of course that
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> means
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> tightly coupling a component to a page, which to me doesn't make
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> sense.
>>>>>>>>>
>>>>>>>>> If you simply need a generic way of passing data between pages and
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> components, consider using a service that provides an untyped
>>>>>>>>>> list
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> or
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> putting something in the environment as Kristian suggested. I'm
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> sorry
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> I
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> can't be more helpful but as I said I'm not clear on what you're
>>>>>>>>>
>>>>>>>>> really
>>>>>>>>>
>>>>>>>>> trying to do.
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> good luck
>>>>>>>>>> chris
>>>>>>>>>>
>>>>>>>>>> János Jarecsni wrote:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>> Hi Chris,
>>>>>>>>>>>
>>>>>>>>>>> I thought of pages as "contexts" for the components embedded
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> within
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>> them.
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>> So, in one event handler of a component I would like to set
>>>>>>>>>>> some
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> property or
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>> another (in the page object), and the other components in the
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> page,
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>> which
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>> are also able to access this property may change their
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> appearance
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>> (say, the
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>> .TML would test the property). Maybe I'm on a wrong track,
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> please
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>> let
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> me
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>> know :)
>>>>>>>>>>>
>>>>>>>>>>> thx
>>>>>>>>>>> Cheers,
>>>>>>>>>>> janos
>>>>>>>>>>>
>>>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>  Janos,
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>> I'm having a hard time understanding a case that a component
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> should
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>> know
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>> in which page it is embedded, so my suggestion probably wasn't
>>>>>>>>>>>
>>>>>>>>>>> a
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>> good
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> one. Activation contexts aren't meant for components but for
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>> pages
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>> -
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> you
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>> should be using component parameters to configure them, and if
>>>>>>>>>>>
>>>>>>>>>>> it's
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>> a
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> more sophisticated component, probably a service.
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>>> chris
>>>>>>>>>>>>
>>>>>>>>>>>> János Jarecsni wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>  and how a component can get to know the page in which it is
>>>>>>>>>>>>
>>>>>>>>>>>> included? I
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> mean, I can't @InjectPage, as the component will be included
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>> in
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>> many
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> kinds
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>>>  of pages.
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>> @Kristian: thx for the many ways :) I'll try these, hope
>>>>>>>>>>>>> that
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>> the
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>> @Environmental stuff is scalable (I'm trying to bypass session
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>>> creation
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> as
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>>  much as possible)
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>> Is there a doc on the various annotations available?
>>>>>>>>>>>>>
>>>>>>>>>>>>> @Michael:
>>>>>>>>>>>>> Could you include a tiny bit of example? THX!
>>>>>>>>>>>>>
>>>>>>>>>>>>> Thx to you all
>>>>>>>>>>>>> cheers
>>>>>>>>>>>>> janos
>>>>>>>>>>>>>
>>>>>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>  5) @InjectPage the page and call the getter
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>> Kristian Marinkovic wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  hi janos,
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>> there are several possibilities:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> 1) declare a component parameter and pass in the
>>>>>>>>>>>>>>> variable
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> 2) put it in a ASO and inject the ASO in all your
>>>>>>>>>>>>>>> components
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> (using
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>> @ApplicationState)
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>>>>> the drawback is that any other page or component will
>>>>>>>>>>>>>>> be
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> able to
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>> access
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>>>  the ASO
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>>>> 3) put it into the Environment and read it whereever
>>>>>>>>>>>>>>> you
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> need it
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>> in
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>> your
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>>  nested components.
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>>>> be careful when you put your object in your
>>>>>>>>>>>>>>> environment. if
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> you
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>> put it
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>>>>>>  in
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>>  during the action
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>> request it will not be able in the render request
>>>>>>>>>>>>>>> (because
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> of
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>> the
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> page
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>> redirect).
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>>>>> page:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> @Inject Environment env;
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> @Persist("flash") whateverclass w;
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> onActivate(w) {  this.w= w }
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> setupRender() { env.push(whateverclass.class,w);}
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> components:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> @Environmental Whateverclass var;
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> 4) define a service that can take this variable (and
>>>>>>>>>>>>>>> saves
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> it
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>>  appropriatly
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>>  so it is not
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>> lost on a redirect:)) and inject your service in the
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> components
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>> where
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>> needed
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>>>>> to retrieve the value.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> maybe there are some more possibilities :)
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> g,
>>>>>>>>>>>>>>> kris
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> "János Jarecsni" <ja...@gmail.com>
>>>>>>>>>>>>>>> 29.04.2008 08:15
>>>>>>>>>>>>>>> Bitte antworten an
>>>>>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> An
>>>>>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
>>>>>>>>>>>>>>> Kopie
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Thema
>>>>>>>>>>>>>>> page activation + components
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Hi there,
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> I have an activatable page, in its onActivate(String
>>>>>>>>>>>>>>> param)
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> method
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>> I
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>>>>>>  save
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>>  the param to a normal instance variable of the page
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>> class
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> (no
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>> persistence!).
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>>>>>> How can any component embedded within this page access
>>>>>>>>>>>>>>> this
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> variable?
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>> the page class:
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>>>>> //...
>>>>>>>>>>>>>>> private String param;
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> public void onActivate(String param) {
>>>>>>>>>>>>>>>   this.param = param;
>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> public String getParam() {...}
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Thx in advance!
>>>>>>>>>>>>>>> Janos
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>  --
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> http://thegodcode.net
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>> ------------------------------------------------------------------
>>>       
>>>>>>>>> ---
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>>>>> For additional commands, e-mail: users-
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>> help@tapestry.apache.org
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>>  --
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>> http://thegodcode.net
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>> ---------------------------------------------------------------------
>>>       
>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>>> For additional commands, e-mail:
>>>>>>>>>>>> users-help@tapestry.apache.org
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>  --
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>> http://thegodcode.net
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> ------------------------------------------------------------------
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> ---
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> 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
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>> ---------------------------------------------------------------------
>>>>>
>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>
>>>>>
>>>>>
>>>>>           
>>> --
>>> http://thegodcode.net
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>>       
>
>
>
>   

-- 
http://thegodcode.net


Re: page activation + components

Posted by János Jarecsni <ja...@gmail.com>.
Hi,

yes still listening :) thx so much for the replies. I start responding here.
Well, you're right Josh, I don't care for the URL. My intention is to defer
session creation until it is absolutely necessary (like when the user is
logged in or has put some goods in a shopping cart). Although I think I only
need to "remember" 1 thing at a time, the last action. In my theory all my
component instances (I use this word to emphasize I can have n instances of
a stock monitor component, each monitoring a different paper) have a
configuration. So I don't have to pass all bits of info in the URL... On an
admin site or using properties files, whatever the basic stuff is
preconfigured for a component instance. What gets passed in the URL is any
information the action processing needs. I don't know how clearly I can
describe this :) but the important thing is component instances render
themselves according to their configuration, and one of them changes its
state according to some action on the user's side. Hm... life is not that
simple I have to admit. I can easily think of a site where the user clicks
around, changing the states of multiple components (like changing a weather
monitor state code to NY or asking for a voter component to show voting
status and so on). It would be bad if the last action would clear this
"state", resulting in all components rendering the default state. If we
really stick to deferred session creation then this state has to be encoded
somehow and get sent to the client with every response (the developer would
have to use some encodeStateInUrl() method to generate the link to preserve
the actual state and add the new bit. At this point I really start to
question deferred session creation... :) maybe an easier approach that
session is not created for for the start page, but all this component state
is session persisted. Ok, it may not be as scalable...

cheers
Janos

2008/4/30 Josh Canfield <jo...@thedailytube.com>:

> Are you trying to keep the news id out of the url? Doesn't sound like
> it from your response to not doing the redirect. Since that's the
> case, why not add it to the page context?
>
> I suppose if you were building a portal with several components then
> keeping track of component parameters could get unwieldy. If you were
> showing a news article from the news portlet, and a stock highlight
> from the stock portlet... At that point you're sort of building a
> framework on a framework.
>
> You could build your page such that it accumulated context from it's
> components. Push a ComponentContext object into the Environment
> onActivate, and setupRender in your page (env gets cleared before
> render phase, not sure if there is a better way than doing it in
> both.) Then collect component parameter mappings. onPassivate for your
> page would organize and return these as it's context (you might want
> to sort them to get consistent results)
>
> Your url might look like this:
>
> http://localhost/context/mypage/cc/news/4527/stock/MCD
>
> Then onactivate you init the ComponentContext from the url keying off
> the "cc" to grab the remaining parameters and use them as key/value
> for the components. The your components do something like:
>
> @Environmental
> private ComponentContext _compContext;
>
> void setupRender() {
>  Long newsId = _compContext.getLong(_resources.getId());
> }
>
> void onPickNewsItem(Long id) {
>  _compContext.put(_resources.getId(), id);
> }
>
>
> Josh
>
> On Wed, Apr 30, 2008 at 5:23 AM, János Jarecsni
> <ja...@gmail.com> wrote:
> > Hi Chris,
> >
> > I try to explain :)
> > Say, you have a "NewsQuote" component, which shows a few lines from the
> 5
> > latest news. At the and of each quotations, there a "More" link. Now,
> when
> > the user clicks on this link (an action link, for that matter), the
> > NewsQuote component will set a request scope info saying that the news
> with
> > ID=4527 is requested. And when it comes to the "News" component (it is
> able
> > to show the text of a given news in full), it simply looks at this piece
> of
> > info, and loads the news with id 4527 (or gets it from an app level
> cache
> > :)) and renders it.
> >
> > Hope it tells something about what I am up to :)
> >
> > thx
> > Janos
> >
> > 2008/4/30 Chris Lewis <ch...@bellsouth.net>:
> >
> >
> > > Honestly it's difficult for me to imagine a situation where I'd do
> that
> > > because it seems to violate a degree of encapsulation that tapestry
> > > imposes as a "freeing law" of the framework. The epicenter of that
> being
> > > that one should not think in terms of low-level idioms such as request
> > > parameters, and instead replace those with a higher level of
> application
> > > logic that eclipses them entirely (when possible). That's not to say
> > > that your perspective is flawed, but from the small bit of
> understanding
> > > I've taken from your posts I can't see why one would do what you want.
> > > The thing that I've been saying is missing here is, what are you
> trying
> > > to do? I don't mean technically, I mean what is the end result for the
> > > user? Understanding this is critical, but even if I don't your problem
> > > can still be solved by using a session to serve as an arbitrary
> holder.
> > > If you've settled on this architecture, why not write such a generic
> > > service and move on?
> > >
> > > János Jarecsni wrote:
> > > > Hi,
> > > >
> > > > I looked everywhere for usage of request scope variables, but found
> > > nothing
> > > > (maybe I'm impatient a bit :)...
> > > > Is it really that unrealistic to have two components in a page, one
> (A)
> > > > having an action link eventhandler where it would set some attribute
> for
> > > the
> > > > request only (not the session!) and then component B could render
> itself
> > > > according to the attribute set by component A?
> > > >
> > > > I think it should be a piece of cake :)
> > > >
> > > > thx
> > > > Janos
> > > >
> > > > 2008/4/30 Filip S. Adamsen <fs...@fsadev.com>:
> > > >
> > > >
> > > >> Nope, you're exactly right.
> > > >>
> > > >> -Filip
> > > >>
> > > >> Blower, Andy skrev:
> > > >>
> > > >>  This is not what I understood 'perthread' scope to be. I thought
> that
> > > it
> > > >>
> > > >>> meant that each thread using a service gets its own instance of
> the
> > > service
> > > >>> to use, even though that instance may not be the same as any
> previous
> > > >>> instance it used. In other words, nothing to do with user
> sessions,
> > > it's
> > > >>> just for services that are not thread safe and cannot be
> singletons.
> > > >>>
> > > >>> Have I got the wrong end of the stick here?
> > > >>>
> > > >>>  -----Original Message-----
> > > >>>
> > > >>>> From: Andy Huhn [mailto:amhuhn@hrtc.net]
> > > >>>> Sent: 29 April 2008 17:34
> > > >>>> To: Tapestry users
> > > >>>> Subject: Re: page activation + components
> > > >>>>
> > > >>>>
> > > >>>> Hello,
> > > >>>>
> > > >>>> You can define the scope of each service...you can set that
> > > particular
> > > >>>> service to be tied to only one session.
> > > >>>>
> > > >>>> See
> http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html,
> > > >>>> and
> > > >>>> search for "perthread".
> > > >>>>
> > > >>>> Thanks,
> > > >>>> Andy
> > > >>>>
> > > >>>> On Tue, 29 Apr 2008 18:02:52 +0200, "János Jarecsni"
> > > >>>> <ja...@gmail.com> wrote:
> > > >>>>
> > > >>>>
> > > >>>>> Hi there,
> > > >>>>>
> > > >>>>> the service approach (as I expected) is session-agnostic (and is
> > > >>>>> page-independent so concurrent users would interfere badly),
> > > >>>>>
> > > >>>>>
> > > >>>> therefore is
> > > >>>>
> > > >>>>
> > > >>>>> not ok.
> > > >>>>>
> > > >>>>> I will now try the Environment approach... if that is
> session-aware
> > > >>>>>
> > > >>>>>
> > > >>>> :)
> > > >>>>
> > > >>>>
> > > >>>>> thx again
> > > >>>>> janos
> > > >>>>>
> > > >>>>> 2008/4/29 János Jarecsni <ja...@gmail.com>:
> > > >>>>>
> > > >>>>>  Hi Chris,
> > > >>>>>
> > > >>>>>> even so you could help :) I want this kind of generic way of
> > > >>>>>> passing
> > > >>>>>> around information (component to component communication :)) so
> > > >>>>>> I'll
> > > >>>>>>
> > > >>>>>>
> > > >>>>> look
> > > >>>>>
> > > >>>>>
> > > >>>>>> for the solutions Kristian and you outlined.
> > > >>>>>>
> > > >>>>>> thanks!
> > > >>>>>>
> > > >>>>>> cheers,
> > > >>>>>> janos
> > > >>>>>>
> > > >>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > >>>>>>
> > > >>>>>>  Janos,
> > > >>>>>>
> > > >>>>>>> Without code or a description of your actual goal, I'm finding
> > > >>>>>>>
> > > >>>>>>>
> > > >>>>>> your
> > > >>>>>>
> > > >>>>> situation too hypothetical to really digest. The one thing I can
> > > >>>>>
> > > >>>>>> point
> > > >>>>>>
> > > >>>>> out is what you said about wanting a component to set a property
> > > >>>>>
> > > >>>>>> in
> > > >>>>>>
> > > >>>>> the
> > > >>>>>
> > > >>>>>
> > > >>>>>> page. If you want to do that, then you have to know the class
> of
> > > >>>>>>
> > > >>>>>> the
> > > >>>>>>
> > > >>>>> page and so injecting a page would make sense. Of course that
> > > >>>>>
> > > >>>>>> means
> > > >>>>>>
> > > >>>>> tightly coupling a component to a page, which to me doesn't make
> > > >>>>>
> > > >>>>>> sense.
> > > >>>>>>
> > > >>>>>> If you simply need a generic way of passing data between pages
> and
> > > >>>>>>
> > > >>>>>>> components, consider using a service that provides an untyped
> > > >>>>>>> list
> > > >>>>>>>
> > > >>>>>>>
> > > >>>>>> or
> > > >>>>>>
> > > >>>>> putting something in the environment as Kristian suggested. I'm
> > > >>>>>
> > > >>>>>> sorry
> > > >>>>>>
> > > >>>>> I
> > > >>>>>
> > > >>>>>
> > > >>>>>> can't be more helpful but as I said I'm not clear on what
> you're
> > > >>>>>>
> > > >>>>>> really
> > > >>>>>>
> > > >>>>>> trying to do.
> > > >>>>>>
> > > >>>>>>> good luck
> > > >>>>>>> chris
> > > >>>>>>>
> > > >>>>>>> János Jarecsni wrote:
> > > >>>>>>>
> > > >>>>>>>
> > > >>>>>>>> Hi Chris,
> > > >>>>>>>>
> > > >>>>>>>> I thought of pages as "contexts" for the components embedded
> > > >>>>>>>>
> > > >>>>>>>>
> > > >>>>>>> within
> > > >>>>>>>
> > > >>>>> them.
> > > >>>>>
> > > >>>>>>>> So, in one event handler of a component I would like to set
> > > >>>>>>>> some
> > > >>>>>>>>
> > > >>>>>>>>
> > > >>>>>>> property or
> > > >>>>>>>
> > > >>>>>>>
> > > >>>>>>>> another (in the page object), and the other components in the
> > > >>>>>>>>
> > > >>>>>>>>
> > > >>>>>>> page,
> > > >>>>>>>
> > > >>>>> which
> > > >>>>>
> > > >>>>>>>> are also able to access this property may change their
> > > >>>>>>>>
> > > >>>>>>>>
> > > >>>>>>> appearance
> > > >>>>>>>
> > > >>>>> (say, the
> > > >>>>>
> > > >>>>>>>> .TML would test the property). Maybe I'm on a wrong track,
> > > >>>>>>>>
> > > >>>>>>>>
> > > >>>>>>> please
> > > >>>>>>>
> > > >>>>> let
> > > >>>>>
> > > >>>>>
> > > >>>>>> me
> > > >>>>>>
> > > >>>>>>>> know :)
> > > >>>>>>>>
> > > >>>>>>>> thx
> > > >>>>>>>> Cheers,
> > > >>>>>>>> janos
> > > >>>>>>>>
> > > >>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > >>>>>>>>
> > > >>>>>>>>
> > > >>>>>>>>  Janos,
> > > >>>>>>>>
> > > >>>>>>>>> I'm having a hard time understanding a case that a component
> > > >>>>>>>>>
> > > >>>>>>>>>
> > > >>>>>>>> should
> > > >>>>>>>>
> > > >>>>> know
> > > >>>>>
> > > >>>>>>>> in which page it is embedded, so my suggestion probably
> wasn't
> > > >>>>>>>>
> > > >>>>>>>> a
> > > >>>>>>>>
> > > >>>>> good
> > > >>>>>
> > > >>>>>
> > > >>>>>> one. Activation contexts aren't meant for components but for
> > > >>>>>>
> > > >>>>>>>> pages
> > > >>>>>>>>
> > > >>>>> -
> > > >>>>>
> > > >>>>>
> > > >>>>>> you
> > > >>>>>>
> > > >>>>>>>> should be using component parameters to configure them, and
> if
> > > >>>>>>>>
> > > >>>>>>>> it's
> > > >>>>>>>>
> > > >>>>> a
> > > >>>>>
> > > >>>>>
> > > >>>>>> more sophisticated component, probably a service.
> > > >>>>>>
> > > >>>>>>>>> chris
> > > >>>>>>>>>
> > > >>>>>>>>> János Jarecsni wrote:
> > > >>>>>>>>>
> > > >>>>>>>>>  and how a component can get to know the page in which it is
> > > >>>>>>>>>
> > > >>>>>>>>> included? I
> > > >>>>>>>>>
> > > >>>>>>>> mean, I can't @InjectPage, as the component will be included
> > > >>>>>>>>
> > > >>>>>>>>> in
> > > >>>>>>>>>
> > > >>>>> many
> > > >>>>>
> > > >>>>>
> > > >>>>>> kinds
> > > >>>>>>
> > > >>>>>>>>>  of pages.
> > > >>>>>>>>>
> > > >>>>>>>>>> @Kristian: thx for the many ways :) I'll try these, hope
> > > >>>>>>>>>> that
> > > >>>>>>>>>>
> > > >>>>>>>>>>
> > > >>>>>>>>> the
> > > >>>>>>>>>
> > > >>>>> @Environmental stuff is scalable (I'm trying to bypass session
> > > >>>>>
> > > >>>>>>>>> creation
> > > >>>>>>>>>
> > > >>>>>>>> as
> > > >>>>>>>>
> > > >>>>>>>>>  much as possible)
> > > >>>>>>>>>
> > > >>>>>>>>>> Is there a doc on the various annotations available?
> > > >>>>>>>>>>
> > > >>>>>>>>>> @Michael:
> > > >>>>>>>>>> Could you include a tiny bit of example? THX!
> > > >>>>>>>>>>
> > > >>>>>>>>>> Thx to you all
> > > >>>>>>>>>> cheers
> > > >>>>>>>>>> janos
> > > >>>>>>>>>>
> > > >>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > >>>>>>>>>>
> > > >>>>>>>>>>
> > > >>>>>>>>>>
> > > >>>>>>>>>>  5) @InjectPage the page and call the getter
> > > >>>>>>>>>>
> > > >>>>>>>>>>> Kristian Marinkovic wrote:
> > > >>>>>>>>>>>
> > > >>>>>>>>>>>
> > > >>>>>>>>>>>  hi janos,
> > > >>>>>>>>>>>
> > > >>>>>>>>>>>> there are several possibilities:
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> 1) declare a component parameter and pass in the
> > > >>>>>>>>>>>> variable
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> 2) put it in a ASO and inject the ASO in all your
> > > >>>>>>>>>>>> components
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>> (using
> > > >>>>>>>>>>>
> > > >>>>>>>> @ApplicationState)
> > > >>>>>>>>
> > > >>>>>>>>>>>> the drawback is that any other page or component will
> > > >>>>>>>>>>>> be
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>> able to
> > > >>>>>>>>>>>
> > > >>>>> access
> > > >>>>>
> > > >>>>>>>>>  the ASO
> > > >>>>>>>>>
> > > >>>>>>>>>>>> 3) put it into the Environment and read it whereever
> > > >>>>>>>>>>>> you
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>> need it
> > > >>>>>>>>>>>
> > > >>>>> in
> > > >>>>>
> > > >>>>>>>> your
> > > >>>>>>>>
> > > >>>>>>>>>  nested components.
> > > >>>>>>>>>
> > > >>>>>>>>>>>> be careful when you put your object in your
> > > >>>>>>>>>>>> environment. if
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>> you
> > > >>>>>>>>>>>
> > > >>>>> put it
> > > >>>>>
> > > >>>>>>>>>>>>  in
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>  during the action
> > > >>>>>>>>>>>
> > > >>>>>>>>>>>> request it will not be able in the render request
> > > >>>>>>>>>>>> (because
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>> of
> > > >>>>>>>>>>>
> > > >>>>> the
> > > >>>>>
> > > >>>>>
> > > >>>>>> page
> > > >>>>>>
> > > >>>>>>>> redirect).
> > > >>>>>>>>
> > > >>>>>>>>>>>> page:
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> @Inject Environment env;
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> @Persist("flash") whateverclass w;
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> onActivate(w) {  this.w= w }
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> setupRender() { env.push(whateverclass.class,w);}
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> components:
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> @Environmental Whateverclass var;
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> 4) define a service that can take this variable (and
> > > >>>>>>>>>>>> saves
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>> it
> > > >>>>>>>>>>>
> > > >>>>>>>>>>>>  appropriatly
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>  so it is not
> > > >>>>>>>>>>>
> > > >>>>>>>>>>>> lost on a redirect:)) and inject your service in the
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>> components
> > > >>>>>>>>>>>
> > > >>>>> where
> > > >>>>>
> > > >>>>>>>> needed
> > > >>>>>>>>
> > > >>>>>>>>>>>> to retrieve the value.
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> maybe there are some more possibilities :)
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> g,
> > > >>>>>>>>>>>> kris
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> "János Jarecsni" <ja...@gmail.com>
> > > >>>>>>>>>>>> 29.04.2008 08:15
> > > >>>>>>>>>>>> Bitte antworten an
> > > >>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> An
> > > >>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
> > > >>>>>>>>>>>> Kopie
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> Thema
> > > >>>>>>>>>>>> page activation + components
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> Hi there,
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> I have an activatable page, in its onActivate(String
> > > >>>>>>>>>>>> param)
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>> method
> > > >>>>>>>>>>>
> > > >>>>>> I
> > > >>>>>>
> > > >>>>>>>>>>>>  save
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>  the param to a normal instance variable of the page
> > > >>>>>>>>>>>
> > > >>>>>>>>>>>> class
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>> (no
> > > >>>>>>>>>>>
> > > >>>>> persistence!).
> > > >>>>>
> > > >>>>>>>>>>>> How can any component embedded within this page access
> > > >>>>>>>>>>>> this
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>> variable?
> > > >>>>>>>>>>>
> > > >>>>>>>> the page class:
> > > >>>>>>>>
> > > >>>>>>>>>>>> //...
> > > >>>>>>>>>>>> private String param;
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> public void onActivate(String param) {
> > > >>>>>>>>>>>>   this.param = param;
> > > >>>>>>>>>>>> }
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> public String getParam() {...}
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> Thx in advance!
> > > >>>>>>>>>>>> Janos
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>  --
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>> http://thegodcode.net
> > > >>>>>>>>>>>
> > > >>>>>>>>>>>
> > > >>>>>>>>>>>
> > > >>>>>>>>>>>
> > > ------------------------------------------------------------------
> > > >>>>>>>>>>>
> > > >>>>>> ---
> > > >>>>>>
> > > >>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > >>>>>
> > > >>>>>>>>>>> For additional commands, e-mail: users-
> > > >>>>>>>>>>>
> > > >>>>>>>>>>>
> > > >>>>>>>>>> help@tapestry.apache.org
> > > >>>>>>>>>>
> > > >>>>>>>>>>>  --
> > > >>>>>>>>>>>
> > > >>>>>>>>> http://thegodcode.net
> > > >>>>>>>>>
> > > >>>>>>>>>
> > > >>>>>>>>>
> > > >>>>>>>>>
> > > ---------------------------------------------------------------------
> > > >>>>>>>>>
> > > >>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > >>>>>>
> > > >>>>>>>>> For additional commands, e-mail:
> > > >>>>>>>>> users-help@tapestry.apache.org
> > > >>>>>>>>>
> > > >>>>>>>>>
> > > >>>>>>>>>
> > > >>>>>>>>>  --
> > > >>>>>>>>>
> > > >>>>>>> http://thegodcode.net
> > > >>>>>>>
> > > >>>>>>>
> > > >>>>>>>
> > > >>>>>>>
> ------------------------------------------------------------------
> > > >>>>>>>
> > > >>>>>>>
> > > >>>>>> ---
> > > >>>>>>
> > > >>>>> 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
> > > >>>>
> > > >>>>
> > > >>>
> > > >>
> ---------------------------------------------------------------------
> > > >>
> > > >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > >> For additional commands, e-mail: users-help@tapestry.apache.org
> > > >>
> > > >>
> > > >>
> > >
> > > --
> > > http://thegodcode.net
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
>
>
>
> --
> --
> TheDailyTube.com. Sign up and get the best new videos on the internet
> delivered fresh to your inbox.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: page activation + components

Posted by Josh Canfield <jo...@thedailytube.com>.
On Fri, May 2, 2008 at 1:23 PM, János Jarecsni <ja...@gmail.com> wrote:
> hi Josh
>
> well I think if I have a reusable (pluggable) component, the ability to
> configure it comes in handy when putting the site together. Say, I have a
> voter component. Week by week there's another question, or I'd like to add
> three instances of a stock monitor each configured to poll a different
> paper's data. All this can be done in the admin site accompanying the base
> site. I would not reserve this model for CMS, manageability is an important
> feature for any application.
>

Yeah, that's all out of the realm of what I would consider Tapestry's
area of responsibility. These are application concepts best left to
the application designer, whether your application is a portal/cms/or
other.

> Regarding localization, say we have some component C residing in the
> com.foo.components package. It has its own message catalogue, C.properties.
> Question is how and where to put a C.properties file to override the
> "factory defaults" for this component? Say the component author defined a
> label like username=User name whereas in the current application I'd like to
> have this as: username=Employee name. I want to use the component but with a
> different message catalogue. All this without modifying the component JAR.
>

There is probably room for better support for replacing existing
message bundles. As it stands I believe putting your properties files
into the classpath in front of your compoent jars would get your
desired result.

> Is there some info on your page cache implementation (and the component
> version as well)? In my vision caching is also something to be configured on
> the admin site :)

I based my cache off of the ehcache j2ee cache and a request
dispatcher. I believe if you search the list you can find out
something about the component class.

>
> Maybe it's time to cache myself in bed now or I'll miss this night too, and
> that would be baaad :)
>
> Cheers
> janos
>
> 2008/5/2 Josh Canfield <jo...@thedailytube.com>:
>
>
> > Hey Janos,
> >
> > Perhaps a building platform on a framework then?  :)
> >
> > > 1. automatic admin site generation (the administration or configuration
> > of
> > > components is an essential aspect of web applications)
> >
> > No, this is definitely platform functionality here. I have no need for
> > managing components like you describe. My web applications read/write
> > data from a database and present them in a consistent way. What you
> > are talking about here sounds like a Content Management System, which
> > you could build using Tapestry.
> >
> > > 2. override of resources from top to bottom ...
> > Definitely, and best that I know this is possible with Tapestry. Do
> > you have a specific problem?
> >
> > > 3. caching of component UI ...
> > Eh... whether this should be built into the framework is debatable
> > (and has been debated). As I recall Howard isn't a fan of caching at
> > that level. I built a page level cache for my app within the framework
> > (very slow changing data), someone on this list has built a component
> > version.
> >
> >
> > Anyway, good luck getting some sleep tonight!
> >
> > Josh
> >
> > On Fri, May 2, 2008 at 8:25 AM, János Jarecsni <ja...@gmail.com>
> > wrote:
> > > one more thing :)
> > >
> > > "At that point you're sort of building a
> > > framework on a framework."
> > >
> > > No, really not. I just try to work out some best practices for my own
> > use on
> > > how to create truly reusable components, and how to build web sites (not
> > > portals, cause I think the "normal" website let it be an e-commerce site
> > or
> > > a blog site or whatever is significantly different from a portal, and
> > there
> > > are quite good portal engines out there anyway :)). I like T5 quite much
> > (I
> > > don't know a lot of core stuff, I only read Alexander Kolesnikov's book
> > > which is a great introduction by the way). But I found a few things
> > which
> > > are not supported directly and I would need these for my large scale
> > goal:
> > >
> > > 1. automatic admin site generation (the administration or configuration
> > of
> > > components is an essential aspect of web applications)
> > > 2. override of resources from top to bottom (I mean, that the
> > application
> > > assembler should be able to replace the i18n and CSS resources of a
> > > component with stuff of his/her liking. According to what I currently
> > know
> > > this is not possible, only the opposite way)
> > > 3. caching of component UI (for instance, I should be able to say in a
> > > component which generates graphs that the framework should cache the
> > result
> > > for 5 minutes or until a certain event is not triggered)
> > >
> > > and maybe more as I go ahead. Once more, I definitely don't want to
> > build a
> > > new framework, but these issues are quite important if you really after
> > > creating a repository of a few dozen components which can save you the
> > bulk
> > > of the work when creating a new site.
> > >
> > > I have finished my second 5 o' clock coffee and still I'm sleepy and
> > tired.
> > > Yesterday night there was a party in the appartment above us, and the
> > young
> > > guys stopped at 4am. I had a hard time remembering what it was like when
> > I
> > > was doing the same thing :P
> > >
> > > Cheers,
> > > Janos
> > >
> > >
> > > 2008/4/30 Josh Canfield <jo...@thedailytube.com>:
> > >
> > >
> > > > Are you trying to keep the news id out of the url? Doesn't sound like
> > > > it from your response to not doing the redirect. Since that's the
> > > > case, why not add it to the page context?
> > > >
> > > > I suppose if you were building a portal with several components then
> > > > keeping track of component parameters could get unwieldy. If you were
> > > > showing a news article from the news portlet, and a stock highlight
> > > > from the stock portlet... At that point you're sort of building a
> > > > framework on a framework.
> > > >
> > > > You could build your page such that it accumulated context from it's
> > > > components. Push a ComponentContext object into the Environment
> > > > onActivate, and setupRender in your page (env gets cleared before
> > > > render phase, not sure if there is a better way than doing it in
> > > > both.) Then collect component parameter mappings. onPassivate for your
> > > > page would organize and return these as it's context (you might want
> > > > to sort them to get consistent results)
> > > >
> > > > Your url might look like this:
> > > >
> > > > http://localhost/context/mypage/cc/news/4527/stock/MCD
> > > >
> > > > Then onactivate you init the ComponentContext from the url keying off
> > > > the "cc" to grab the remaining parameters and use them as key/value
> > > > for the components. The your components do something like:
> > > >
> > > > @Environmental
> > > > private ComponentContext _compContext;
> > > >
> > > > void setupRender() {
> > > >  Long newsId = _compContext.getLong(_resources.getId());
> > > > }
> > > >
> > > > void onPickNewsItem(Long id) {
> > > >  _compContext.put(_resources.getId(), id);
> > > > }
> > > >
> > > >
> > > > Josh
> > > >
> > > > On Wed, Apr 30, 2008 at 5:23 AM, János Jarecsni
> > > > <ja...@gmail.com> wrote:
> > > > > Hi Chris,
> > > > >
> > > > > I try to explain :)
> > > > > Say, you have a "NewsQuote" component, which shows a few lines from
> > the
> > > > 5
> > > > > latest news. At the and of each quotations, there a "More" link.
> > Now,
> > > > when
> > > > > the user clicks on this link (an action link, for that matter), the
> > > > > NewsQuote component will set a request scope info saying that the
> > news
> > > > with
> > > > > ID=4527 is requested. And when it comes to the "News" component (it
> > is
> > > > able
> > > > > to show the text of a given news in full), it simply looks at this
> > piece
> > > > of
> > > > > info, and loads the news with id 4527 (or gets it from an app level
> > > > cache
> > > > > :)) and renders it.
> > > > >
> > > > > Hope it tells something about what I am up to :)
> > > > >
> > > > > thx
> > > > > Janos
> > > > >
> > > > > 2008/4/30 Chris Lewis <ch...@bellsouth.net>:
> > > > >
> > > > >
> > > > > > Honestly it's difficult for me to imagine a situation where I'd do
> > > > that
> > > > > > because it seems to violate a degree of encapsulation that
> > tapestry
> > > > > > imposes as a "freeing law" of the framework. The epicenter of that
> > > > being
> > > > > > that one should not think in terms of low-level idioms such as
> > request
> > > > > > parameters, and instead replace those with a higher level of
> > > > application
> > > > > > logic that eclipses them entirely (when possible). That's not to
> > say
> > > > > > that your perspective is flawed, but from the small bit of
> > > > understanding
> > > > > > I've taken from your posts I can't see why one would do what you
> > want.
> > > > > > The thing that I've been saying is missing here is, what are you
> > > > trying
> > > > > > to do? I don't mean technically, I mean what is the end result for
> > the
> > > > > > user? Understanding this is critical, but even if I don't your
> > problem
> > > > > > can still be solved by using a session to serve as an arbitrary
> > > > holder.
> > > > > > If you've settled on this architecture, why not write such a
> > generic
> > > > > > service and move on?
> > > > > >
> > > > > > János Jarecsni wrote:
> > > > > > > Hi,
> > > > > > >
> > > > > > > I looked everywhere for usage of request scope variables, but
> > found
> > > > > > nothing
> > > > > > > (maybe I'm impatient a bit :)...
> > > > > > > Is it really that unrealistic to have two components in a page,
> > one
> > > > (A)
> > > > > > > having an action link eventhandler where it would set some
> > attribute
> > > > for
> > > > > > the
> > > > > > > request only (not the session!) and then component B could
> > render
> > > > itself
> > > > > > > according to the attribute set by component A?
> > > > > > >
> > > > > > > I think it should be a piece of cake :)
> > > > > > >
> > > > > > > thx
> > > > > > > Janos
> > > > > > >
> > > > > > > 2008/4/30 Filip S. Adamsen <fs...@fsadev.com>:
> > > > > > >
> > > > > > >
> > > > > > >> Nope, you're exactly right.
> > > > > > >>
> > > > > > >> -Filip
> > > > > > >>
> > > > > > >> Blower, Andy skrev:
> > > > > > >>
> > > > > > >>  This is not what I understood 'perthread' scope to be. I
> > thought
> > > > that
> > > > > > it
> > > > > > >>
> > > > > > >>> meant that each thread using a service gets its own instance
> > of
> > > > the
> > > > > > service
> > > > > > >>> to use, even though that instance may not be the same as any
> > > > previous
> > > > > > >>> instance it used. In other words, nothing to do with user
> > > > sessions,
> > > > > > it's
> > > > > > >>> just for services that are not thread safe and cannot be
> > > > singletons.
> > > > > > >>>
> > > > > > >>> Have I got the wrong end of the stick here?
> > > > > > >>>
> > > > > > >>>  -----Original Message-----
> > > > > > >>>
> > > > > > >>>> From: Andy Huhn [mailto:amhuhn@hrtc.net]
> > > > > > >>>> Sent: 29 April 2008 17:34
> > > > > > >>>> To: Tapestry users
> > > > > > >>>> Subject: Re: page activation + components
> > > > > > >>>>
> > > > > > >>>>
> > > > > > >>>> Hello,
> > > > > > >>>>
> > > > > > >>>> You can define the scope of each service...you can set that
> > > > > > particular
> > > > > > >>>> service to be tied to only one session.
> > > > > > >>>>
> > > > > > >>>> See
> > > > http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html,
> > > > > > >>>> and
> > > > > > >>>> search for "perthread".
> > > > > > >>>>
> > > > > > >>>> Thanks,
> > > > > > >>>> Andy
> > > > > > >>>>
> > > > > > >>>> On Tue, 29 Apr 2008 18:02:52 +0200, "János Jarecsni"
> > > > > > >>>> <ja...@gmail.com> wrote:
> > > > > > >>>>
> > > > > > >>>>
> > > > > > >>>>> Hi there,
> > > > > > >>>>>
> > > > > > >>>>> the service approach (as I expected) is session-agnostic
> > (and is
> > > > > > >>>>> page-independent so concurrent users would interfere badly),
> > > > > > >>>>>
> > > > > > >>>>>
> > > > > > >>>> therefore is
> > > > > > >>>>
> > > > > > >>>>
> > > > > > >>>>> not ok.
> > > > > > >>>>>
> > > > > > >>>>> I will now try the Environment approach... if that is
> > > > session-aware
> > > > > > >>>>>
> > > > > > >>>>>
> > > > > > >>>> :)
> > > > > > >>>>
> > > > > > >>>>
> > > > > > >>>>> thx again
> > > > > > >>>>> janos
> > > > > > >>>>>
> > > > > > >>>>> 2008/4/29 János Jarecsni <ja...@gmail.com>:
> > > > > > >>>>>
> > > > > > >>>>>  Hi Chris,
> > > > > > >>>>>
> > > > > > >>>>>> even so you could help :) I want this kind of generic way
> > of
> > > > > > >>>>>> passing
> > > > > > >>>>>> around information (component to component communication
> > :)) so
> > > > > > >>>>>> I'll
> > > > > > >>>>>>
> > > > > > >>>>>>
> > > > > > >>>>> look
> > > > > > >>>>>
> > > > > > >>>>>
> > > > > > >>>>>> for the solutions Kristian and you outlined.
> > > > > > >>>>>>
> > > > > > >>>>>> thanks!
> > > > > > >>>>>>
> > > > > > >>>>>> cheers,
> > > > > > >>>>>> janos
> > > > > > >>>>>>
> > > > > > >>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > > > > >>>>>>
> > > > > > >>>>>>  Janos,
> > > > > > >>>>>>
> > > > > > >>>>>>> Without code or a description of your actual goal, I'm
> > finding
> > > > > > >>>>>>>
> > > > > > >>>>>>>
> > > > > > >>>>>> your
> > > > > > >>>>>>
> > > > > > >>>>> situation too hypothetical to really digest. The one thing I
> > can
> > > > > > >>>>>
> > > > > > >>>>>> point
> > > > > > >>>>>>
> > > > > > >>>>> out is what you said about wanting a component to set a
> > property
> > > > > > >>>>>
> > > > > > >>>>>> in
> > > > > > >>>>>>
> > > > > > >>>>> the
> > > > > > >>>>>
> > > > > > >>>>>
> > > > > > >>>>>> page. If you want to do that, then you have to know the
> > class
> > > > of
> > > > > > >>>>>>
> > > > > > >>>>>> the
> > > > > > >>>>>>
> > > > > > >>>>> page and so injecting a page would make sense. Of course
> > that
> > > > > > >>>>>
> > > > > > >>>>>> means
> > > > > > >>>>>>
> > > > > > >>>>> tightly coupling a component to a page, which to me doesn't
> > make
> > > > > > >>>>>
> > > > > > >>>>>> sense.
> > > > > > >>>>>>
> > > > > > >>>>>> If you simply need a generic way of passing data between
> > pages
> > > > and
> > > > > > >>>>>>
> > > > > > >>>>>>> components, consider using a service that provides an
> > untyped
> > > > > > >>>>>>> list
> > > > > > >>>>>>>
> > > > > > >>>>>>>
> > > > > > >>>>>> or
> > > > > > >>>>>>
> > > > > > >>>>> putting something in the environment as Kristian suggested.
> > I'm
> > > > > > >>>>>
> > > > > > >>>>>> sorry
> > > > > > >>>>>>
> > > > > > >>>>> I
> > > > > > >>>>>
> > > > > > >>>>>
> > > > > > >>>>>> can't be more helpful but as I said I'm not clear on what
> > > > you're
> > > > > > >>>>>>
> > > > > > >>>>>> really
> > > > > > >>>>>>
> > > > > > >>>>>> trying to do.
> > > > > > >>>>>>
> > > > > > >>>>>>> good luck
> > > > > > >>>>>>> chris
> > > > > > >>>>>>>
> > > > > > >>>>>>> János Jarecsni wrote:
> > > > > > >>>>>>>
> > > > > > >>>>>>>
> > > > > > >>>>>>>> Hi Chris,
> > > > > > >>>>>>>>
> > > > > > >>>>>>>> I thought of pages as "contexts" for the components
> > embedded
> > > > > > >>>>>>>>
> > > > > > >>>>>>>>
> > > > > > >>>>>>> within
> > > > > > >>>>>>>
> > > > > > >>>>> them.
> > > > > > >>>>>
> > > > > > >>>>>>>> So, in one event handler of a component I would like to
> > set
> > > > > > >>>>>>>> some
> > > > > > >>>>>>>>
> > > > > > >>>>>>>>
> > > > > > >>>>>>> property or
> > > > > > >>>>>>>
> > > > > > >>>>>>>
> > > > > > >>>>>>>> another (in the page object), and the other components in
> > the
> > > > > > >>>>>>>>
> > > > > > >>>>>>>>
> > > > > > >>>>>>> page,
> > > > > > >>>>>>>
> > > > > > >>>>> which
> > > > > > >>>>>
> > > > > > >>>>>>>> are also able to access this property may change their
> > > > > > >>>>>>>>
> > > > > > >>>>>>>>
> > > > > > >>>>>>> appearance
> > > > > > >>>>>>>
> > > > > > >>>>> (say, the
> > > > > > >>>>>
> > > > > > >>>>>>>> .TML would test the property). Maybe I'm on a wrong
> > track,
> > > > > > >>>>>>>>
> > > > > > >>>>>>>>
> > > > > > >>>>>>> please
> > > > > > >>>>>>>
> > > > > > >>>>> let
> > > > > > >>>>>
> > > > > > >>>>>
> > > > > > >>>>>> me
> > > > > > >>>>>>
> > > > > > >>>>>>>> know :)
> > > > > > >>>>>>>>
> > > > > > >>>>>>>> thx
> > > > > > >>>>>>>> Cheers,
> > > > > > >>>>>>>> janos
> > > > > > >>>>>>>>
> > > > > > >>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > > > > >>>>>>>>
> > > > > > >>>>>>>>
> > > > > > >>>>>>>>  Janos,
> > > > > > >>>>>>>>
> > > > > > >>>>>>>>> I'm having a hard time understanding a case that a
> > component
> > > > > > >>>>>>>>>
> > > > > > >>>>>>>>>
> > > > > > >>>>>>>> should
> > > > > > >>>>>>>>
> > > > > > >>>>> know
> > > > > > >>>>>
> > > > > > >>>>>>>> in which page it is embedded, so my suggestion probably
> > > > wasn't
> > > > > > >>>>>>>>
> > > > > > >>>>>>>> a
> > > > > > >>>>>>>>
> > > > > > >>>>> good
> > > > > > >>>>>
> > > > > > >>>>>
> > > > > > >>>>>> one. Activation contexts aren't meant for components but
> > for
> > > > > > >>>>>>
> > > > > > >>>>>>>> pages
> > > > > > >>>>>>>>
> > > > > > >>>>> -
> > > > > > >>>>>
> > > > > > >>>>>
> > > > > > >>>>>> you
> > > > > > >>>>>>
> > > > > > >>>>>>>> should be using component parameters to configure them,
> > and
> > > > if
> > > > > > >>>>>>>>
> > > > > > >>>>>>>> it's
> > > > > > >>>>>>>>
> > > > > > >>>>> a
> > > > > > >>>>>
> > > > > > >>>>>
> > > > > > >>>>>> more sophisticated component, probably a service.
> > > > > > >>>>>>
> > > > > > >>>>>>>>> chris
> > > > > > >>>>>>>>>
> > > > > > >>>>>>>>> János Jarecsni wrote:
> > > > > > >>>>>>>>>
> > > > > > >>>>>>>>>  and how a component can get to know the page in which
> > it is
> > > > > > >>>>>>>>>
> > > > > > >>>>>>>>> included? I
> > > > > > >>>>>>>>>
> > > > > > >>>>>>>> mean, I can't @InjectPage, as the component will be
> > included
> > > > > > >>>>>>>>
> > > > > > >>>>>>>>> in
> > > > > > >>>>>>>>>
> > > > > > >>>>> many
> > > > > > >>>>>
> > > > > > >>>>>
> > > > > > >>>>>> kinds
> > > > > > >>>>>>
> > > > > > >>>>>>>>>  of pages.
> > > > > > >>>>>>>>>
> > > > > > >>>>>>>>>> @Kristian: thx for the many ways :) I'll try these,
> > hope
> > > > > > >>>>>>>>>> that
> > > > > > >>>>>>>>>>
> > > > > > >>>>>>>>>>
> > > > > > >>>>>>>>> the
> > > > > > >>>>>>>>>
> > > > > > >>>>> @Environmental stuff is scalable (I'm trying to bypass
> > session
> > > > > > >>>>>
> > > > > > >>>>>>>>> creation
> > > > > > >>>>>>>>>
> > > > > > >>>>>>>> as
> > > > > > >>>>>>>>
> > > > > > >>>>>>>>>  much as possible)
> > > > > > >>>>>>>>>
> > > > > > >>>>>>>>>> Is there a doc on the various annotations available?
> > > > > > >>>>>>>>>>
> > > > > > >>>>>>>>>> @Michael:
> > > > > > >>>>>>>>>> Could you include a tiny bit of example? THX!
> > > > > > >>>>>>>>>>
> > > > > > >>>>>>>>>> Thx to you all
> > > > > > >>>>>>>>>> cheers
> > > > > > >>>>>>>>>> janos
> > > > > > >>>>>>>>>>
> > > > > > >>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > > > > >>>>>>>>>>
> > > > > > >>>>>>>>>>
> > > > > > >>>>>>>>>>
> > > > > > >>>>>>>>>>  5) @InjectPage the page and call the getter
> > > > > > >>>>>>>>>>
> > > > > > >>>>>>>>>>> Kristian Marinkovic wrote:
> > > > > > >>>>>>>>>>>
> > > > > > >>>>>>>>>>>
> > > > > > >>>>>>>>>>>  hi janos,
> > > > > > >>>>>>>>>>>
> > > > > > >>>>>>>>>>>> there are several possibilities:
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>> 1) declare a component parameter and pass in the
> > > > > > >>>>>>>>>>>> variable
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>> 2) put it in a ASO and inject the ASO in all your
> > > > > > >>>>>>>>>>>> components
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>> (using
> > > > > > >>>>>>>>>>>
> > > > > > >>>>>>>> @ApplicationState)
> > > > > > >>>>>>>>
> > > > > > >>>>>>>>>>>> the drawback is that any other page or component will
> > > > > > >>>>>>>>>>>> be
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>> able to
> > > > > > >>>>>>>>>>>
> > > > > > >>>>> access
> > > > > > >>>>>
> > > > > > >>>>>>>>>  the ASO
> > > > > > >>>>>>>>>
> > > > > > >>>>>>>>>>>> 3) put it into the Environment and read it whereever
> > > > > > >>>>>>>>>>>> you
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>> need it
> > > > > > >>>>>>>>>>>
> > > > > > >>>>> in
> > > > > > >>>>>
> > > > > > >>>>>>>> your
> > > > > > >>>>>>>>
> > > > > > >>>>>>>>>  nested components.
> > > > > > >>>>>>>>>
> > > > > > >>>>>>>>>>>> be careful when you put your object in your
> > > > > > >>>>>>>>>>>> environment. if
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>> you
> > > > > > >>>>>>>>>>>
> > > > > > >>>>> put it
> > > > > > >>>>>
> > > > > > >>>>>>>>>>>>  in
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>  during the action
> > > > > > >>>>>>>>>>>
> > > > > > >>>>>>>>>>>> request it will not be able in the render request
> > > > > > >>>>>>>>>>>> (because
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>> of
> > > > > > >>>>>>>>>>>
> > > > > > >>>>> the
> > > > > > >>>>>
> > > > > > >>>>>
> > > > > > >>>>>> page
> > > > > > >>>>>>
> > > > > > >>>>>>>> redirect).
> > > > > > >>>>>>>>
> > > > > > >>>>>>>>>>>> page:
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>> @Inject Environment env;
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>> @Persist("flash") whateverclass w;
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>> onActivate(w) {  this.w= w }
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>> setupRender() { env.push(whateverclass.class,w);}
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>> components:
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>> @Environmental Whateverclass var;
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>> 4) define a service that can take this variable (and
> > > > > > >>>>>>>>>>>> saves
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>> it
> > > > > > >>>>>>>>>>>
> > > > > > >>>>>>>>>>>>  appropriatly
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>  so it is not
> > > > > > >>>>>>>>>>>
> > > > > > >>>>>>>>>>>> lost on a redirect:)) and inject your service in the
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>> components
> > > > > > >>>>>>>>>>>
> > > > > > >>>>> where
> > > > > > >>>>>
> > > > > > >>>>>>>> needed
> > > > > > >>>>>>>>
> > > > > > >>>>>>>>>>>> to retrieve the value.
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>> maybe there are some more possibilities :)
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>> g,
> > > > > > >>>>>>>>>>>> kris
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>> "János Jarecsni" <ja...@gmail.com>
> > > > > > >>>>>>>>>>>> 29.04.2008 08:15
> > > > > > >>>>>>>>>>>> Bitte antworten an
> > > > > > >>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>> An
> > > > > > >>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
> > > > > > >>>>>>>>>>>> Kopie
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>> Thema
> > > > > > >>>>>>>>>>>> page activation + components
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>> Hi there,
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>> I have an activatable page, in its onActivate(String
> > > > > > >>>>>>>>>>>> param)
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>> method
> > > > > > >>>>>>>>>>>
> > > > > > >>>>>> I
> > > > > > >>>>>>
> > > > > > >>>>>>>>>>>>  save
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>  the param to a normal instance variable of the page
> > > > > > >>>>>>>>>>>
> > > > > > >>>>>>>>>>>> class
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>> (no
> > > > > > >>>>>>>>>>>
> > > > > > >>>>> persistence!).
> > > > > > >>>>>
> > > > > > >>>>>>>>>>>> How can any component embedded within this page
> > access
> > > > > > >>>>>>>>>>>> this
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>> variable?
> > > > > > >>>>>>>>>>>
> > > > > > >>>>>>>> the page class:
> > > > > > >>>>>>>>
> > > > > > >>>>>>>>>>>> //...
> > > > > > >>>>>>>>>>>> private String param;
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>> public void onActivate(String param) {
> > > > > > >>>>>>>>>>>>   this.param = param;
> > > > > > >>>>>>>>>>>> }
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>> public String getParam() {...}
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>> Thx in advance!
> > > > > > >>>>>>>>>>>> Janos
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>>>  --
> > > > > > >>>>>>>>>>>>
> > > > > > >>>>>>>>>>> http://thegodcode.net
> > > > > > >>>>>>>>>>>
> > > > > > >>>>>>>>>>>
> > > > > > >>>>>>>>>>>
> > > > > > >>>>>>>>>>>
> > > > > > ------------------------------------------------------------------
> > > > > > >>>>>>>>>>>
> > > > > > >>>>>> ---
> > > > > > >>>>>>
> > > > > > >>>>> To unsubscribe, e-mail:
> > users-unsubscribe@tapestry.apache.org
> > > > > > >>>>>
> > > > > > >>>>>>>>>>> For additional commands, e-mail: users-
> > > > > > >>>>>>>>>>>
> > > > > > >>>>>>>>>>>
> > > > > > >>>>>>>>>> help@tapestry.apache.org
> > > > > > >>>>>>>>>>
> > > > > > >>>>>>>>>>>  --
> > > > > > >>>>>>>>>>>
> > > > > > >>>>>>>>> http://thegodcode.net
> > > > > > >>>>>>>>>
> > > > > > >>>>>>>>>
> > > > > > >>>>>>>>>
> > > > > > >>>>>>>>>
> > > > > >
> > ---------------------------------------------------------------------
> > > > > > >>>>>>>>>
> > > > > > >>>>>> To unsubscribe, e-mail:
> > users-unsubscribe@tapestry.apache.org
> > > > > > >>>>>>
> > > > > > >>>>>>>>> For additional commands, e-mail:
> > > > > > >>>>>>>>> users-help@tapestry.apache.org
> > > > > > >>>>>>>>>
> > > > > > >>>>>>>>>
> > > > > > >>>>>>>>>
> > > > > > >>>>>>>>>  --
> > > > > > >>>>>>>>>
> > > > > > >>>>>>> http://thegodcode.net
> > > > > > >>>>>>>
> > > > > > >>>>>>>
> > > > > > >>>>>>>
> > > > > > >>>>>>>
> > > > ------------------------------------------------------------------
> > > > > > >>>>>>>
> > > > > > >>>>>>>
> > > > > > >>>>>> ---
> > > > > > >>>>>>
> > > > > > >>>>> 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
> > > > > > >>>>
> > > > > > >>>>
> > > > > > >>>
> > > > > > >>
> > > > ---------------------------------------------------------------------
> > > > > > >>
> > > > > > >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > > > >> For additional commands, e-mail: users-help@tapestry.apache.org
> > > > > > >>
> > > > > > >>
> > > > > > >>
> > > > > >
> > > > > > --
> > > > > > http://thegodcode.net
> > > > > >
> > > > > >
> > > > > >
> > ---------------------------------------------------------------------
> > > > > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > > > For additional commands, e-mail: users-help@tapestry.apache.org
> > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > --
> > > > TheDailyTube.com. Sign up and get the best new videos on the internet
> > > > delivered fresh to your inbox.
> > > >
> > > > ---------------------------------------------------------------------
> > >
> > > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > For additional commands, e-mail: users-help@tapestry.apache.org
> > > >
> > > >
> > >
> >
> >
> >
> > --
> > --
> > TheDailyTube.com. Sign up and get the best new videos on the internet
> > delivered fresh to your inbox.
> >
> > ---------------------------------------------------------------------
>
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>



-- 
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.

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


Re: page activation + components

Posted by János Jarecsni <ja...@gmail.com>.
hi Josh

well I think if I have a reusable (pluggable) component, the ability to
configure it comes in handy when putting the site together. Say, I have a
voter component. Week by week there's another question, or I'd like to add
three instances of a stock monitor each configured to poll a different
paper's data. All this can be done in the admin site accompanying the base
site. I would not reserve this model for CMS, manageability is an important
feature for any application.

Regarding localization, say we have some component C residing in the
com.foo.components package. It has its own message catalogue, C.properties.
Question is how and where to put a C.properties file to override the
"factory defaults" for this component? Say the component author defined a
label like username=User name whereas in the current application I'd like to
have this as: username=Employee name. I want to use the component but with a
different message catalogue. All this without modifying the component JAR.

Is there some info on your page cache implementation (and the component
version as well)? In my vision caching is also something to be configured on
the admin site :)

Maybe it's time to cache myself in bed now or I'll miss this night too, and
that would be baaad :)

Cheers
janos

2008/5/2 Josh Canfield <jo...@thedailytube.com>:

> Hey Janos,
>
> Perhaps a building platform on a framework then?  :)
>
> > 1. automatic admin site generation (the administration or configuration
> of
> > components is an essential aspect of web applications)
>
> No, this is definitely platform functionality here. I have no need for
> managing components like you describe. My web applications read/write
> data from a database and present them in a consistent way. What you
> are talking about here sounds like a Content Management System, which
> you could build using Tapestry.
>
> > 2. override of resources from top to bottom ...
> Definitely, and best that I know this is possible with Tapestry. Do
> you have a specific problem?
>
> > 3. caching of component UI ...
> Eh... whether this should be built into the framework is debatable
> (and has been debated). As I recall Howard isn't a fan of caching at
> that level. I built a page level cache for my app within the framework
> (very slow changing data), someone on this list has built a component
> version.
>
>
> Anyway, good luck getting some sleep tonight!
>
> Josh
>
> On Fri, May 2, 2008 at 8:25 AM, János Jarecsni <ja...@gmail.com>
> wrote:
> > one more thing :)
> >
> > "At that point you're sort of building a
> > framework on a framework."
> >
> > No, really not. I just try to work out some best practices for my own
> use on
> > how to create truly reusable components, and how to build web sites (not
> > portals, cause I think the "normal" website let it be an e-commerce site
> or
> > a blog site or whatever is significantly different from a portal, and
> there
> > are quite good portal engines out there anyway :)). I like T5 quite much
> (I
> > don't know a lot of core stuff, I only read Alexander Kolesnikov's book
> > which is a great introduction by the way). But I found a few things
> which
> > are not supported directly and I would need these for my large scale
> goal:
> >
> > 1. automatic admin site generation (the administration or configuration
> of
> > components is an essential aspect of web applications)
> > 2. override of resources from top to bottom (I mean, that the
> application
> > assembler should be able to replace the i18n and CSS resources of a
> > component with stuff of his/her liking. According to what I currently
> know
> > this is not possible, only the opposite way)
> > 3. caching of component UI (for instance, I should be able to say in a
> > component which generates graphs that the framework should cache the
> result
> > for 5 minutes or until a certain event is not triggered)
> >
> > and maybe more as I go ahead. Once more, I definitely don't want to
> build a
> > new framework, but these issues are quite important if you really after
> > creating a repository of a few dozen components which can save you the
> bulk
> > of the work when creating a new site.
> >
> > I have finished my second 5 o' clock coffee and still I'm sleepy and
> tired.
> > Yesterday night there was a party in the appartment above us, and the
> young
> > guys stopped at 4am. I had a hard time remembering what it was like when
> I
> > was doing the same thing :P
> >
> > Cheers,
> > Janos
> >
> >
> > 2008/4/30 Josh Canfield <jo...@thedailytube.com>:
> >
> >
> > > Are you trying to keep the news id out of the url? Doesn't sound like
> > > it from your response to not doing the redirect. Since that's the
> > > case, why not add it to the page context?
> > >
> > > I suppose if you were building a portal with several components then
> > > keeping track of component parameters could get unwieldy. If you were
> > > showing a news article from the news portlet, and a stock highlight
> > > from the stock portlet... At that point you're sort of building a
> > > framework on a framework.
> > >
> > > You could build your page such that it accumulated context from it's
> > > components. Push a ComponentContext object into the Environment
> > > onActivate, and setupRender in your page (env gets cleared before
> > > render phase, not sure if there is a better way than doing it in
> > > both.) Then collect component parameter mappings. onPassivate for your
> > > page would organize and return these as it's context (you might want
> > > to sort them to get consistent results)
> > >
> > > Your url might look like this:
> > >
> > > http://localhost/context/mypage/cc/news/4527/stock/MCD
> > >
> > > Then onactivate you init the ComponentContext from the url keying off
> > > the "cc" to grab the remaining parameters and use them as key/value
> > > for the components. The your components do something like:
> > >
> > > @Environmental
> > > private ComponentContext _compContext;
> > >
> > > void setupRender() {
> > >  Long newsId = _compContext.getLong(_resources.getId());
> > > }
> > >
> > > void onPickNewsItem(Long id) {
> > >  _compContext.put(_resources.getId(), id);
> > > }
> > >
> > >
> > > Josh
> > >
> > > On Wed, Apr 30, 2008 at 5:23 AM, János Jarecsni
> > > <ja...@gmail.com> wrote:
> > > > Hi Chris,
> > > >
> > > > I try to explain :)
> > > > Say, you have a "NewsQuote" component, which shows a few lines from
> the
> > > 5
> > > > latest news. At the and of each quotations, there a "More" link.
> Now,
> > > when
> > > > the user clicks on this link (an action link, for that matter), the
> > > > NewsQuote component will set a request scope info saying that the
> news
> > > with
> > > > ID=4527 is requested. And when it comes to the "News" component (it
> is
> > > able
> > > > to show the text of a given news in full), it simply looks at this
> piece
> > > of
> > > > info, and loads the news with id 4527 (or gets it from an app level
> > > cache
> > > > :)) and renders it.
> > > >
> > > > Hope it tells something about what I am up to :)
> > > >
> > > > thx
> > > > Janos
> > > >
> > > > 2008/4/30 Chris Lewis <ch...@bellsouth.net>:
> > > >
> > > >
> > > > > Honestly it's difficult for me to imagine a situation where I'd do
> > > that
> > > > > because it seems to violate a degree of encapsulation that
> tapestry
> > > > > imposes as a "freeing law" of the framework. The epicenter of that
> > > being
> > > > > that one should not think in terms of low-level idioms such as
> request
> > > > > parameters, and instead replace those with a higher level of
> > > application
> > > > > logic that eclipses them entirely (when possible). That's not to
> say
> > > > > that your perspective is flawed, but from the small bit of
> > > understanding
> > > > > I've taken from your posts I can't see why one would do what you
> want.
> > > > > The thing that I've been saying is missing here is, what are you
> > > trying
> > > > > to do? I don't mean technically, I mean what is the end result for
> the
> > > > > user? Understanding this is critical, but even if I don't your
> problem
> > > > > can still be solved by using a session to serve as an arbitrary
> > > holder.
> > > > > If you've settled on this architecture, why not write such a
> generic
> > > > > service and move on?
> > > > >
> > > > > János Jarecsni wrote:
> > > > > > Hi,
> > > > > >
> > > > > > I looked everywhere for usage of request scope variables, but
> found
> > > > > nothing
> > > > > > (maybe I'm impatient a bit :)...
> > > > > > Is it really that unrealistic to have two components in a page,
> one
> > > (A)
> > > > > > having an action link eventhandler where it would set some
> attribute
> > > for
> > > > > the
> > > > > > request only (not the session!) and then component B could
> render
> > > itself
> > > > > > according to the attribute set by component A?
> > > > > >
> > > > > > I think it should be a piece of cake :)
> > > > > >
> > > > > > thx
> > > > > > Janos
> > > > > >
> > > > > > 2008/4/30 Filip S. Adamsen <fs...@fsadev.com>:
> > > > > >
> > > > > >
> > > > > >> Nope, you're exactly right.
> > > > > >>
> > > > > >> -Filip
> > > > > >>
> > > > > >> Blower, Andy skrev:
> > > > > >>
> > > > > >>  This is not what I understood 'perthread' scope to be. I
> thought
> > > that
> > > > > it
> > > > > >>
> > > > > >>> meant that each thread using a service gets its own instance
> of
> > > the
> > > > > service
> > > > > >>> to use, even though that instance may not be the same as any
> > > previous
> > > > > >>> instance it used. In other words, nothing to do with user
> > > sessions,
> > > > > it's
> > > > > >>> just for services that are not thread safe and cannot be
> > > singletons.
> > > > > >>>
> > > > > >>> Have I got the wrong end of the stick here?
> > > > > >>>
> > > > > >>>  -----Original Message-----
> > > > > >>>
> > > > > >>>> From: Andy Huhn [mailto:amhuhn@hrtc.net]
> > > > > >>>> Sent: 29 April 2008 17:34
> > > > > >>>> To: Tapestry users
> > > > > >>>> Subject: Re: page activation + components
> > > > > >>>>
> > > > > >>>>
> > > > > >>>> Hello,
> > > > > >>>>
> > > > > >>>> You can define the scope of each service...you can set that
> > > > > particular
> > > > > >>>> service to be tied to only one session.
> > > > > >>>>
> > > > > >>>> See
> > > http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html,
> > > > > >>>> and
> > > > > >>>> search for "perthread".
> > > > > >>>>
> > > > > >>>> Thanks,
> > > > > >>>> Andy
> > > > > >>>>
> > > > > >>>> On Tue, 29 Apr 2008 18:02:52 +0200, "János Jarecsni"
> > > > > >>>> <ja...@gmail.com> wrote:
> > > > > >>>>
> > > > > >>>>
> > > > > >>>>> Hi there,
> > > > > >>>>>
> > > > > >>>>> the service approach (as I expected) is session-agnostic
> (and is
> > > > > >>>>> page-independent so concurrent users would interfere badly),
> > > > > >>>>>
> > > > > >>>>>
> > > > > >>>> therefore is
> > > > > >>>>
> > > > > >>>>
> > > > > >>>>> not ok.
> > > > > >>>>>
> > > > > >>>>> I will now try the Environment approach... if that is
> > > session-aware
> > > > > >>>>>
> > > > > >>>>>
> > > > > >>>> :)
> > > > > >>>>
> > > > > >>>>
> > > > > >>>>> thx again
> > > > > >>>>> janos
> > > > > >>>>>
> > > > > >>>>> 2008/4/29 János Jarecsni <ja...@gmail.com>:
> > > > > >>>>>
> > > > > >>>>>  Hi Chris,
> > > > > >>>>>
> > > > > >>>>>> even so you could help :) I want this kind of generic way
> of
> > > > > >>>>>> passing
> > > > > >>>>>> around information (component to component communication
> :)) so
> > > > > >>>>>> I'll
> > > > > >>>>>>
> > > > > >>>>>>
> > > > > >>>>> look
> > > > > >>>>>
> > > > > >>>>>
> > > > > >>>>>> for the solutions Kristian and you outlined.
> > > > > >>>>>>
> > > > > >>>>>> thanks!
> > > > > >>>>>>
> > > > > >>>>>> cheers,
> > > > > >>>>>> janos
> > > > > >>>>>>
> > > > > >>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > > > >>>>>>
> > > > > >>>>>>  Janos,
> > > > > >>>>>>
> > > > > >>>>>>> Without code or a description of your actual goal, I'm
> finding
> > > > > >>>>>>>
> > > > > >>>>>>>
> > > > > >>>>>> your
> > > > > >>>>>>
> > > > > >>>>> situation too hypothetical to really digest. The one thing I
> can
> > > > > >>>>>
> > > > > >>>>>> point
> > > > > >>>>>>
> > > > > >>>>> out is what you said about wanting a component to set a
> property
> > > > > >>>>>
> > > > > >>>>>> in
> > > > > >>>>>>
> > > > > >>>>> the
> > > > > >>>>>
> > > > > >>>>>
> > > > > >>>>>> page. If you want to do that, then you have to know the
> class
> > > of
> > > > > >>>>>>
> > > > > >>>>>> the
> > > > > >>>>>>
> > > > > >>>>> page and so injecting a page would make sense. Of course
> that
> > > > > >>>>>
> > > > > >>>>>> means
> > > > > >>>>>>
> > > > > >>>>> tightly coupling a component to a page, which to me doesn't
> make
> > > > > >>>>>
> > > > > >>>>>> sense.
> > > > > >>>>>>
> > > > > >>>>>> If you simply need a generic way of passing data between
> pages
> > > and
> > > > > >>>>>>
> > > > > >>>>>>> components, consider using a service that provides an
> untyped
> > > > > >>>>>>> list
> > > > > >>>>>>>
> > > > > >>>>>>>
> > > > > >>>>>> or
> > > > > >>>>>>
> > > > > >>>>> putting something in the environment as Kristian suggested.
> I'm
> > > > > >>>>>
> > > > > >>>>>> sorry
> > > > > >>>>>>
> > > > > >>>>> I
> > > > > >>>>>
> > > > > >>>>>
> > > > > >>>>>> can't be more helpful but as I said I'm not clear on what
> > > you're
> > > > > >>>>>>
> > > > > >>>>>> really
> > > > > >>>>>>
> > > > > >>>>>> trying to do.
> > > > > >>>>>>
> > > > > >>>>>>> good luck
> > > > > >>>>>>> chris
> > > > > >>>>>>>
> > > > > >>>>>>> János Jarecsni wrote:
> > > > > >>>>>>>
> > > > > >>>>>>>
> > > > > >>>>>>>> Hi Chris,
> > > > > >>>>>>>>
> > > > > >>>>>>>> I thought of pages as "contexts" for the components
> embedded
> > > > > >>>>>>>>
> > > > > >>>>>>>>
> > > > > >>>>>>> within
> > > > > >>>>>>>
> > > > > >>>>> them.
> > > > > >>>>>
> > > > > >>>>>>>> So, in one event handler of a component I would like to
> set
> > > > > >>>>>>>> some
> > > > > >>>>>>>>
> > > > > >>>>>>>>
> > > > > >>>>>>> property or
> > > > > >>>>>>>
> > > > > >>>>>>>
> > > > > >>>>>>>> another (in the page object), and the other components in
> the
> > > > > >>>>>>>>
> > > > > >>>>>>>>
> > > > > >>>>>>> page,
> > > > > >>>>>>>
> > > > > >>>>> which
> > > > > >>>>>
> > > > > >>>>>>>> are also able to access this property may change their
> > > > > >>>>>>>>
> > > > > >>>>>>>>
> > > > > >>>>>>> appearance
> > > > > >>>>>>>
> > > > > >>>>> (say, the
> > > > > >>>>>
> > > > > >>>>>>>> .TML would test the property). Maybe I'm on a wrong
> track,
> > > > > >>>>>>>>
> > > > > >>>>>>>>
> > > > > >>>>>>> please
> > > > > >>>>>>>
> > > > > >>>>> let
> > > > > >>>>>
> > > > > >>>>>
> > > > > >>>>>> me
> > > > > >>>>>>
> > > > > >>>>>>>> know :)
> > > > > >>>>>>>>
> > > > > >>>>>>>> thx
> > > > > >>>>>>>> Cheers,
> > > > > >>>>>>>> janos
> > > > > >>>>>>>>
> > > > > >>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > > > >>>>>>>>
> > > > > >>>>>>>>
> > > > > >>>>>>>>  Janos,
> > > > > >>>>>>>>
> > > > > >>>>>>>>> I'm having a hard time understanding a case that a
> component
> > > > > >>>>>>>>>
> > > > > >>>>>>>>>
> > > > > >>>>>>>> should
> > > > > >>>>>>>>
> > > > > >>>>> know
> > > > > >>>>>
> > > > > >>>>>>>> in which page it is embedded, so my suggestion probably
> > > wasn't
> > > > > >>>>>>>>
> > > > > >>>>>>>> a
> > > > > >>>>>>>>
> > > > > >>>>> good
> > > > > >>>>>
> > > > > >>>>>
> > > > > >>>>>> one. Activation contexts aren't meant for components but
> for
> > > > > >>>>>>
> > > > > >>>>>>>> pages
> > > > > >>>>>>>>
> > > > > >>>>> -
> > > > > >>>>>
> > > > > >>>>>
> > > > > >>>>>> you
> > > > > >>>>>>
> > > > > >>>>>>>> should be using component parameters to configure them,
> and
> > > if
> > > > > >>>>>>>>
> > > > > >>>>>>>> it's
> > > > > >>>>>>>>
> > > > > >>>>> a
> > > > > >>>>>
> > > > > >>>>>
> > > > > >>>>>> more sophisticated component, probably a service.
> > > > > >>>>>>
> > > > > >>>>>>>>> chris
> > > > > >>>>>>>>>
> > > > > >>>>>>>>> János Jarecsni wrote:
> > > > > >>>>>>>>>
> > > > > >>>>>>>>>  and how a component can get to know the page in which
> it is
> > > > > >>>>>>>>>
> > > > > >>>>>>>>> included? I
> > > > > >>>>>>>>>
> > > > > >>>>>>>> mean, I can't @InjectPage, as the component will be
> included
> > > > > >>>>>>>>
> > > > > >>>>>>>>> in
> > > > > >>>>>>>>>
> > > > > >>>>> many
> > > > > >>>>>
> > > > > >>>>>
> > > > > >>>>>> kinds
> > > > > >>>>>>
> > > > > >>>>>>>>>  of pages.
> > > > > >>>>>>>>>
> > > > > >>>>>>>>>> @Kristian: thx for the many ways :) I'll try these,
> hope
> > > > > >>>>>>>>>> that
> > > > > >>>>>>>>>>
> > > > > >>>>>>>>>>
> > > > > >>>>>>>>> the
> > > > > >>>>>>>>>
> > > > > >>>>> @Environmental stuff is scalable (I'm trying to bypass
> session
> > > > > >>>>>
> > > > > >>>>>>>>> creation
> > > > > >>>>>>>>>
> > > > > >>>>>>>> as
> > > > > >>>>>>>>
> > > > > >>>>>>>>>  much as possible)
> > > > > >>>>>>>>>
> > > > > >>>>>>>>>> Is there a doc on the various annotations available?
> > > > > >>>>>>>>>>
> > > > > >>>>>>>>>> @Michael:
> > > > > >>>>>>>>>> Could you include a tiny bit of example? THX!
> > > > > >>>>>>>>>>
> > > > > >>>>>>>>>> Thx to you all
> > > > > >>>>>>>>>> cheers
> > > > > >>>>>>>>>> janos
> > > > > >>>>>>>>>>
> > > > > >>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > > > >>>>>>>>>>
> > > > > >>>>>>>>>>
> > > > > >>>>>>>>>>
> > > > > >>>>>>>>>>  5) @InjectPage the page and call the getter
> > > > > >>>>>>>>>>
> > > > > >>>>>>>>>>> Kristian Marinkovic wrote:
> > > > > >>>>>>>>>>>
> > > > > >>>>>>>>>>>
> > > > > >>>>>>>>>>>  hi janos,
> > > > > >>>>>>>>>>>
> > > > > >>>>>>>>>>>> there are several possibilities:
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> 1) declare a component parameter and pass in the
> > > > > >>>>>>>>>>>> variable
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> 2) put it in a ASO and inject the ASO in all your
> > > > > >>>>>>>>>>>> components
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>> (using
> > > > > >>>>>>>>>>>
> > > > > >>>>>>>> @ApplicationState)
> > > > > >>>>>>>>
> > > > > >>>>>>>>>>>> the drawback is that any other page or component will
> > > > > >>>>>>>>>>>> be
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>> able to
> > > > > >>>>>>>>>>>
> > > > > >>>>> access
> > > > > >>>>>
> > > > > >>>>>>>>>  the ASO
> > > > > >>>>>>>>>
> > > > > >>>>>>>>>>>> 3) put it into the Environment and read it whereever
> > > > > >>>>>>>>>>>> you
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>> need it
> > > > > >>>>>>>>>>>
> > > > > >>>>> in
> > > > > >>>>>
> > > > > >>>>>>>> your
> > > > > >>>>>>>>
> > > > > >>>>>>>>>  nested components.
> > > > > >>>>>>>>>
> > > > > >>>>>>>>>>>> be careful when you put your object in your
> > > > > >>>>>>>>>>>> environment. if
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>> you
> > > > > >>>>>>>>>>>
> > > > > >>>>> put it
> > > > > >>>>>
> > > > > >>>>>>>>>>>>  in
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>  during the action
> > > > > >>>>>>>>>>>
> > > > > >>>>>>>>>>>> request it will not be able in the render request
> > > > > >>>>>>>>>>>> (because
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>> of
> > > > > >>>>>>>>>>>
> > > > > >>>>> the
> > > > > >>>>>
> > > > > >>>>>
> > > > > >>>>>> page
> > > > > >>>>>>
> > > > > >>>>>>>> redirect).
> > > > > >>>>>>>>
> > > > > >>>>>>>>>>>> page:
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> @Inject Environment env;
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> @Persist("flash") whateverclass w;
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> onActivate(w) {  this.w= w }
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> setupRender() { env.push(whateverclass.class,w);}
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> components:
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> @Environmental Whateverclass var;
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> 4) define a service that can take this variable (and
> > > > > >>>>>>>>>>>> saves
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>> it
> > > > > >>>>>>>>>>>
> > > > > >>>>>>>>>>>>  appropriatly
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>  so it is not
> > > > > >>>>>>>>>>>
> > > > > >>>>>>>>>>>> lost on a redirect:)) and inject your service in the
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>> components
> > > > > >>>>>>>>>>>
> > > > > >>>>> where
> > > > > >>>>>
> > > > > >>>>>>>> needed
> > > > > >>>>>>>>
> > > > > >>>>>>>>>>>> to retrieve the value.
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> maybe there are some more possibilities :)
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> g,
> > > > > >>>>>>>>>>>> kris
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> "János Jarecsni" <ja...@gmail.com>
> > > > > >>>>>>>>>>>> 29.04.2008 08:15
> > > > > >>>>>>>>>>>> Bitte antworten an
> > > > > >>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> An
> > > > > >>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
> > > > > >>>>>>>>>>>> Kopie
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> Thema
> > > > > >>>>>>>>>>>> page activation + components
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> Hi there,
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> I have an activatable page, in its onActivate(String
> > > > > >>>>>>>>>>>> param)
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>> method
> > > > > >>>>>>>>>>>
> > > > > >>>>>> I
> > > > > >>>>>>
> > > > > >>>>>>>>>>>>  save
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>  the param to a normal instance variable of the page
> > > > > >>>>>>>>>>>
> > > > > >>>>>>>>>>>> class
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>> (no
> > > > > >>>>>>>>>>>
> > > > > >>>>> persistence!).
> > > > > >>>>>
> > > > > >>>>>>>>>>>> How can any component embedded within this page
> access
> > > > > >>>>>>>>>>>> this
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>> variable?
> > > > > >>>>>>>>>>>
> > > > > >>>>>>>> the page class:
> > > > > >>>>>>>>
> > > > > >>>>>>>>>>>> //...
> > > > > >>>>>>>>>>>> private String param;
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> public void onActivate(String param) {
> > > > > >>>>>>>>>>>>   this.param = param;
> > > > > >>>>>>>>>>>> }
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> public String getParam() {...}
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>> Thx in advance!
> > > > > >>>>>>>>>>>> Janos
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>>>  --
> > > > > >>>>>>>>>>>>
> > > > > >>>>>>>>>>> http://thegodcode.net
> > > > > >>>>>>>>>>>
> > > > > >>>>>>>>>>>
> > > > > >>>>>>>>>>>
> > > > > >>>>>>>>>>>
> > > > > ------------------------------------------------------------------
> > > > > >>>>>>>>>>>
> > > > > >>>>>> ---
> > > > > >>>>>>
> > > > > >>>>> To unsubscribe, e-mail:
> users-unsubscribe@tapestry.apache.org
> > > > > >>>>>
> > > > > >>>>>>>>>>> For additional commands, e-mail: users-
> > > > > >>>>>>>>>>>
> > > > > >>>>>>>>>>>
> > > > > >>>>>>>>>> help@tapestry.apache.org
> > > > > >>>>>>>>>>
> > > > > >>>>>>>>>>>  --
> > > > > >>>>>>>>>>>
> > > > > >>>>>>>>> http://thegodcode.net
> > > > > >>>>>>>>>
> > > > > >>>>>>>>>
> > > > > >>>>>>>>>
> > > > > >>>>>>>>>
> > > > >
> ---------------------------------------------------------------------
> > > > > >>>>>>>>>
> > > > > >>>>>> To unsubscribe, e-mail:
> users-unsubscribe@tapestry.apache.org
> > > > > >>>>>>
> > > > > >>>>>>>>> For additional commands, e-mail:
> > > > > >>>>>>>>> users-help@tapestry.apache.org
> > > > > >>>>>>>>>
> > > > > >>>>>>>>>
> > > > > >>>>>>>>>
> > > > > >>>>>>>>>  --
> > > > > >>>>>>>>>
> > > > > >>>>>>> http://thegodcode.net
> > > > > >>>>>>>
> > > > > >>>>>>>
> > > > > >>>>>>>
> > > > > >>>>>>>
> > > ------------------------------------------------------------------
> > > > > >>>>>>>
> > > > > >>>>>>>
> > > > > >>>>>> ---
> > > > > >>>>>>
> > > > > >>>>> 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
> > > > > >>>>
> > > > > >>>>
> > > > > >>>
> > > > > >>
> > > ---------------------------------------------------------------------
> > > > > >>
> > > > > >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > > >> For additional commands, e-mail: users-help@tapestry.apache.org
> > > > > >>
> > > > > >>
> > > > > >>
> > > > >
> > > > > --
> > > > > http://thegodcode.net
> > > > >
> > > > >
> > > > >
> ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > > For additional commands, e-mail: users-help@tapestry.apache.org
> > > > >
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > --
> > > TheDailyTube.com. Sign up and get the best new videos on the internet
> > > delivered fresh to your inbox.
> > >
> > > ---------------------------------------------------------------------
> >
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
>
>
>
> --
> --
> TheDailyTube.com. Sign up and get the best new videos on the internet
> delivered fresh to your inbox.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: page activation + components

Posted by Josh Canfield <jo...@thedailytube.com>.
Hey Janos,

Perhaps a building platform on a framework then?  :)

> 1. automatic admin site generation (the administration or configuration of
> components is an essential aspect of web applications)

No, this is definitely platform functionality here. I have no need for
managing components like you describe. My web applications read/write
data from a database and present them in a consistent way. What you
are talking about here sounds like a Content Management System, which
you could build using Tapestry.

> 2. override of resources from top to bottom ...
Definitely, and best that I know this is possible with Tapestry. Do
you have a specific problem?

> 3. caching of component UI ...
Eh... whether this should be built into the framework is debatable
(and has been debated). As I recall Howard isn't a fan of caching at
that level. I built a page level cache for my app within the framework
(very slow changing data), someone on this list has built a component
version.


Anyway, good luck getting some sleep tonight!

Josh

On Fri, May 2, 2008 at 8:25 AM, János Jarecsni <ja...@gmail.com> wrote:
> one more thing :)
>
> "At that point you're sort of building a
> framework on a framework."
>
> No, really not. I just try to work out some best practices for my own use on
> how to create truly reusable components, and how to build web sites (not
> portals, cause I think the "normal" website let it be an e-commerce site or
> a blog site or whatever is significantly different from a portal, and there
> are quite good portal engines out there anyway :)). I like T5 quite much (I
> don't know a lot of core stuff, I only read Alexander Kolesnikov's book
> which is a great introduction by the way). But I found a few things which
> are not supported directly and I would need these for my large scale goal:
>
> 1. automatic admin site generation (the administration or configuration of
> components is an essential aspect of web applications)
> 2. override of resources from top to bottom (I mean, that the application
> assembler should be able to replace the i18n and CSS resources of a
> component with stuff of his/her liking. According to what I currently know
> this is not possible, only the opposite way)
> 3. caching of component UI (for instance, I should be able to say in a
> component which generates graphs that the framework should cache the result
> for 5 minutes or until a certain event is not triggered)
>
> and maybe more as I go ahead. Once more, I definitely don't want to build a
> new framework, but these issues are quite important if you really after
> creating a repository of a few dozen components which can save you the bulk
> of the work when creating a new site.
>
> I have finished my second 5 o' clock coffee and still I'm sleepy and tired.
> Yesterday night there was a party in the appartment above us, and the young
> guys stopped at 4am. I had a hard time remembering what it was like when I
> was doing the same thing :P
>
> Cheers,
> Janos
>
>
> 2008/4/30 Josh Canfield <jo...@thedailytube.com>:
>
>
> > Are you trying to keep the news id out of the url? Doesn't sound like
> > it from your response to not doing the redirect. Since that's the
> > case, why not add it to the page context?
> >
> > I suppose if you were building a portal with several components then
> > keeping track of component parameters could get unwieldy. If you were
> > showing a news article from the news portlet, and a stock highlight
> > from the stock portlet... At that point you're sort of building a
> > framework on a framework.
> >
> > You could build your page such that it accumulated context from it's
> > components. Push a ComponentContext object into the Environment
> > onActivate, and setupRender in your page (env gets cleared before
> > render phase, not sure if there is a better way than doing it in
> > both.) Then collect component parameter mappings. onPassivate for your
> > page would organize and return these as it's context (you might want
> > to sort them to get consistent results)
> >
> > Your url might look like this:
> >
> > http://localhost/context/mypage/cc/news/4527/stock/MCD
> >
> > Then onactivate you init the ComponentContext from the url keying off
> > the "cc" to grab the remaining parameters and use them as key/value
> > for the components. The your components do something like:
> >
> > @Environmental
> > private ComponentContext _compContext;
> >
> > void setupRender() {
> >  Long newsId = _compContext.getLong(_resources.getId());
> > }
> >
> > void onPickNewsItem(Long id) {
> >  _compContext.put(_resources.getId(), id);
> > }
> >
> >
> > Josh
> >
> > On Wed, Apr 30, 2008 at 5:23 AM, János Jarecsni
> > <ja...@gmail.com> wrote:
> > > Hi Chris,
> > >
> > > I try to explain :)
> > > Say, you have a "NewsQuote" component, which shows a few lines from the
> > 5
> > > latest news. At the and of each quotations, there a "More" link. Now,
> > when
> > > the user clicks on this link (an action link, for that matter), the
> > > NewsQuote component will set a request scope info saying that the news
> > with
> > > ID=4527 is requested. And when it comes to the "News" component (it is
> > able
> > > to show the text of a given news in full), it simply looks at this piece
> > of
> > > info, and loads the news with id 4527 (or gets it from an app level
> > cache
> > > :)) and renders it.
> > >
> > > Hope it tells something about what I am up to :)
> > >
> > > thx
> > > Janos
> > >
> > > 2008/4/30 Chris Lewis <ch...@bellsouth.net>:
> > >
> > >
> > > > Honestly it's difficult for me to imagine a situation where I'd do
> > that
> > > > because it seems to violate a degree of encapsulation that tapestry
> > > > imposes as a "freeing law" of the framework. The epicenter of that
> > being
> > > > that one should not think in terms of low-level idioms such as request
> > > > parameters, and instead replace those with a higher level of
> > application
> > > > logic that eclipses them entirely (when possible). That's not to say
> > > > that your perspective is flawed, but from the small bit of
> > understanding
> > > > I've taken from your posts I can't see why one would do what you want.
> > > > The thing that I've been saying is missing here is, what are you
> > trying
> > > > to do? I don't mean technically, I mean what is the end result for the
> > > > user? Understanding this is critical, but even if I don't your problem
> > > > can still be solved by using a session to serve as an arbitrary
> > holder.
> > > > If you've settled on this architecture, why not write such a generic
> > > > service and move on?
> > > >
> > > > János Jarecsni wrote:
> > > > > Hi,
> > > > >
> > > > > I looked everywhere for usage of request scope variables, but found
> > > > nothing
> > > > > (maybe I'm impatient a bit :)...
> > > > > Is it really that unrealistic to have two components in a page, one
> > (A)
> > > > > having an action link eventhandler where it would set some attribute
> > for
> > > > the
> > > > > request only (not the session!) and then component B could render
> > itself
> > > > > according to the attribute set by component A?
> > > > >
> > > > > I think it should be a piece of cake :)
> > > > >
> > > > > thx
> > > > > Janos
> > > > >
> > > > > 2008/4/30 Filip S. Adamsen <fs...@fsadev.com>:
> > > > >
> > > > >
> > > > >> Nope, you're exactly right.
> > > > >>
> > > > >> -Filip
> > > > >>
> > > > >> Blower, Andy skrev:
> > > > >>
> > > > >>  This is not what I understood 'perthread' scope to be. I thought
> > that
> > > > it
> > > > >>
> > > > >>> meant that each thread using a service gets its own instance of
> > the
> > > > service
> > > > >>> to use, even though that instance may not be the same as any
> > previous
> > > > >>> instance it used. In other words, nothing to do with user
> > sessions,
> > > > it's
> > > > >>> just for services that are not thread safe and cannot be
> > singletons.
> > > > >>>
> > > > >>> Have I got the wrong end of the stick here?
> > > > >>>
> > > > >>>  -----Original Message-----
> > > > >>>
> > > > >>>> From: Andy Huhn [mailto:amhuhn@hrtc.net]
> > > > >>>> Sent: 29 April 2008 17:34
> > > > >>>> To: Tapestry users
> > > > >>>> Subject: Re: page activation + components
> > > > >>>>
> > > > >>>>
> > > > >>>> Hello,
> > > > >>>>
> > > > >>>> You can define the scope of each service...you can set that
> > > > particular
> > > > >>>> service to be tied to only one session.
> > > > >>>>
> > > > >>>> See
> > http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html,
> > > > >>>> and
> > > > >>>> search for "perthread".
> > > > >>>>
> > > > >>>> Thanks,
> > > > >>>> Andy
> > > > >>>>
> > > > >>>> On Tue, 29 Apr 2008 18:02:52 +0200, "János Jarecsni"
> > > > >>>> <ja...@gmail.com> wrote:
> > > > >>>>
> > > > >>>>
> > > > >>>>> Hi there,
> > > > >>>>>
> > > > >>>>> the service approach (as I expected) is session-agnostic (and is
> > > > >>>>> page-independent so concurrent users would interfere badly),
> > > > >>>>>
> > > > >>>>>
> > > > >>>> therefore is
> > > > >>>>
> > > > >>>>
> > > > >>>>> not ok.
> > > > >>>>>
> > > > >>>>> I will now try the Environment approach... if that is
> > session-aware
> > > > >>>>>
> > > > >>>>>
> > > > >>>> :)
> > > > >>>>
> > > > >>>>
> > > > >>>>> thx again
> > > > >>>>> janos
> > > > >>>>>
> > > > >>>>> 2008/4/29 János Jarecsni <ja...@gmail.com>:
> > > > >>>>>
> > > > >>>>>  Hi Chris,
> > > > >>>>>
> > > > >>>>>> even so you could help :) I want this kind of generic way of
> > > > >>>>>> passing
> > > > >>>>>> around information (component to component communication :)) so
> > > > >>>>>> I'll
> > > > >>>>>>
> > > > >>>>>>
> > > > >>>>> look
> > > > >>>>>
> > > > >>>>>
> > > > >>>>>> for the solutions Kristian and you outlined.
> > > > >>>>>>
> > > > >>>>>> thanks!
> > > > >>>>>>
> > > > >>>>>> cheers,
> > > > >>>>>> janos
> > > > >>>>>>
> > > > >>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > > >>>>>>
> > > > >>>>>>  Janos,
> > > > >>>>>>
> > > > >>>>>>> Without code or a description of your actual goal, I'm finding
> > > > >>>>>>>
> > > > >>>>>>>
> > > > >>>>>> your
> > > > >>>>>>
> > > > >>>>> situation too hypothetical to really digest. The one thing I can
> > > > >>>>>
> > > > >>>>>> point
> > > > >>>>>>
> > > > >>>>> out is what you said about wanting a component to set a property
> > > > >>>>>
> > > > >>>>>> in
> > > > >>>>>>
> > > > >>>>> the
> > > > >>>>>
> > > > >>>>>
> > > > >>>>>> page. If you want to do that, then you have to know the class
> > of
> > > > >>>>>>
> > > > >>>>>> the
> > > > >>>>>>
> > > > >>>>> page and so injecting a page would make sense. Of course that
> > > > >>>>>
> > > > >>>>>> means
> > > > >>>>>>
> > > > >>>>> tightly coupling a component to a page, which to me doesn't make
> > > > >>>>>
> > > > >>>>>> sense.
> > > > >>>>>>
> > > > >>>>>> If you simply need a generic way of passing data between pages
> > and
> > > > >>>>>>
> > > > >>>>>>> components, consider using a service that provides an untyped
> > > > >>>>>>> list
> > > > >>>>>>>
> > > > >>>>>>>
> > > > >>>>>> or
> > > > >>>>>>
> > > > >>>>> putting something in the environment as Kristian suggested. I'm
> > > > >>>>>
> > > > >>>>>> sorry
> > > > >>>>>>
> > > > >>>>> I
> > > > >>>>>
> > > > >>>>>
> > > > >>>>>> can't be more helpful but as I said I'm not clear on what
> > you're
> > > > >>>>>>
> > > > >>>>>> really
> > > > >>>>>>
> > > > >>>>>> trying to do.
> > > > >>>>>>
> > > > >>>>>>> good luck
> > > > >>>>>>> chris
> > > > >>>>>>>
> > > > >>>>>>> János Jarecsni wrote:
> > > > >>>>>>>
> > > > >>>>>>>
> > > > >>>>>>>> Hi Chris,
> > > > >>>>>>>>
> > > > >>>>>>>> I thought of pages as "contexts" for the components embedded
> > > > >>>>>>>>
> > > > >>>>>>>>
> > > > >>>>>>> within
> > > > >>>>>>>
> > > > >>>>> them.
> > > > >>>>>
> > > > >>>>>>>> So, in one event handler of a component I would like to set
> > > > >>>>>>>> some
> > > > >>>>>>>>
> > > > >>>>>>>>
> > > > >>>>>>> property or
> > > > >>>>>>>
> > > > >>>>>>>
> > > > >>>>>>>> another (in the page object), and the other components in the
> > > > >>>>>>>>
> > > > >>>>>>>>
> > > > >>>>>>> page,
> > > > >>>>>>>
> > > > >>>>> which
> > > > >>>>>
> > > > >>>>>>>> are also able to access this property may change their
> > > > >>>>>>>>
> > > > >>>>>>>>
> > > > >>>>>>> appearance
> > > > >>>>>>>
> > > > >>>>> (say, the
> > > > >>>>>
> > > > >>>>>>>> .TML would test the property). Maybe I'm on a wrong track,
> > > > >>>>>>>>
> > > > >>>>>>>>
> > > > >>>>>>> please
> > > > >>>>>>>
> > > > >>>>> let
> > > > >>>>>
> > > > >>>>>
> > > > >>>>>> me
> > > > >>>>>>
> > > > >>>>>>>> know :)
> > > > >>>>>>>>
> > > > >>>>>>>> thx
> > > > >>>>>>>> Cheers,
> > > > >>>>>>>> janos
> > > > >>>>>>>>
> > > > >>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > > >>>>>>>>
> > > > >>>>>>>>
> > > > >>>>>>>>  Janos,
> > > > >>>>>>>>
> > > > >>>>>>>>> I'm having a hard time understanding a case that a component
> > > > >>>>>>>>>
> > > > >>>>>>>>>
> > > > >>>>>>>> should
> > > > >>>>>>>>
> > > > >>>>> know
> > > > >>>>>
> > > > >>>>>>>> in which page it is embedded, so my suggestion probably
> > wasn't
> > > > >>>>>>>>
> > > > >>>>>>>> a
> > > > >>>>>>>>
> > > > >>>>> good
> > > > >>>>>
> > > > >>>>>
> > > > >>>>>> one. Activation contexts aren't meant for components but for
> > > > >>>>>>
> > > > >>>>>>>> pages
> > > > >>>>>>>>
> > > > >>>>> -
> > > > >>>>>
> > > > >>>>>
> > > > >>>>>> you
> > > > >>>>>>
> > > > >>>>>>>> should be using component parameters to configure them, and
> > if
> > > > >>>>>>>>
> > > > >>>>>>>> it's
> > > > >>>>>>>>
> > > > >>>>> a
> > > > >>>>>
> > > > >>>>>
> > > > >>>>>> more sophisticated component, probably a service.
> > > > >>>>>>
> > > > >>>>>>>>> chris
> > > > >>>>>>>>>
> > > > >>>>>>>>> János Jarecsni wrote:
> > > > >>>>>>>>>
> > > > >>>>>>>>>  and how a component can get to know the page in which it is
> > > > >>>>>>>>>
> > > > >>>>>>>>> included? I
> > > > >>>>>>>>>
> > > > >>>>>>>> mean, I can't @InjectPage, as the component will be included
> > > > >>>>>>>>
> > > > >>>>>>>>> in
> > > > >>>>>>>>>
> > > > >>>>> many
> > > > >>>>>
> > > > >>>>>
> > > > >>>>>> kinds
> > > > >>>>>>
> > > > >>>>>>>>>  of pages.
> > > > >>>>>>>>>
> > > > >>>>>>>>>> @Kristian: thx for the many ways :) I'll try these, hope
> > > > >>>>>>>>>> that
> > > > >>>>>>>>>>
> > > > >>>>>>>>>>
> > > > >>>>>>>>> the
> > > > >>>>>>>>>
> > > > >>>>> @Environmental stuff is scalable (I'm trying to bypass session
> > > > >>>>>
> > > > >>>>>>>>> creation
> > > > >>>>>>>>>
> > > > >>>>>>>> as
> > > > >>>>>>>>
> > > > >>>>>>>>>  much as possible)
> > > > >>>>>>>>>
> > > > >>>>>>>>>> Is there a doc on the various annotations available?
> > > > >>>>>>>>>>
> > > > >>>>>>>>>> @Michael:
> > > > >>>>>>>>>> Could you include a tiny bit of example? THX!
> > > > >>>>>>>>>>
> > > > >>>>>>>>>> Thx to you all
> > > > >>>>>>>>>> cheers
> > > > >>>>>>>>>> janos
> > > > >>>>>>>>>>
> > > > >>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > > >>>>>>>>>>
> > > > >>>>>>>>>>
> > > > >>>>>>>>>>
> > > > >>>>>>>>>>  5) @InjectPage the page and call the getter
> > > > >>>>>>>>>>
> > > > >>>>>>>>>>> Kristian Marinkovic wrote:
> > > > >>>>>>>>>>>
> > > > >>>>>>>>>>>
> > > > >>>>>>>>>>>  hi janos,
> > > > >>>>>>>>>>>
> > > > >>>>>>>>>>>> there are several possibilities:
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> 1) declare a component parameter and pass in the
> > > > >>>>>>>>>>>> variable
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> 2) put it in a ASO and inject the ASO in all your
> > > > >>>>>>>>>>>> components
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>> (using
> > > > >>>>>>>>>>>
> > > > >>>>>>>> @ApplicationState)
> > > > >>>>>>>>
> > > > >>>>>>>>>>>> the drawback is that any other page or component will
> > > > >>>>>>>>>>>> be
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>> able to
> > > > >>>>>>>>>>>
> > > > >>>>> access
> > > > >>>>>
> > > > >>>>>>>>>  the ASO
> > > > >>>>>>>>>
> > > > >>>>>>>>>>>> 3) put it into the Environment and read it whereever
> > > > >>>>>>>>>>>> you
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>> need it
> > > > >>>>>>>>>>>
> > > > >>>>> in
> > > > >>>>>
> > > > >>>>>>>> your
> > > > >>>>>>>>
> > > > >>>>>>>>>  nested components.
> > > > >>>>>>>>>
> > > > >>>>>>>>>>>> be careful when you put your object in your
> > > > >>>>>>>>>>>> environment. if
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>> you
> > > > >>>>>>>>>>>
> > > > >>>>> put it
> > > > >>>>>
> > > > >>>>>>>>>>>>  in
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>  during the action
> > > > >>>>>>>>>>>
> > > > >>>>>>>>>>>> request it will not be able in the render request
> > > > >>>>>>>>>>>> (because
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>> of
> > > > >>>>>>>>>>>
> > > > >>>>> the
> > > > >>>>>
> > > > >>>>>
> > > > >>>>>> page
> > > > >>>>>>
> > > > >>>>>>>> redirect).
> > > > >>>>>>>>
> > > > >>>>>>>>>>>> page:
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> @Inject Environment env;
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> @Persist("flash") whateverclass w;
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> onActivate(w) {  this.w= w }
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> setupRender() { env.push(whateverclass.class,w);}
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> components:
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> @Environmental Whateverclass var;
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> 4) define a service that can take this variable (and
> > > > >>>>>>>>>>>> saves
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>> it
> > > > >>>>>>>>>>>
> > > > >>>>>>>>>>>>  appropriatly
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>  so it is not
> > > > >>>>>>>>>>>
> > > > >>>>>>>>>>>> lost on a redirect:)) and inject your service in the
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>> components
> > > > >>>>>>>>>>>
> > > > >>>>> where
> > > > >>>>>
> > > > >>>>>>>> needed
> > > > >>>>>>>>
> > > > >>>>>>>>>>>> to retrieve the value.
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> maybe there are some more possibilities :)
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> g,
> > > > >>>>>>>>>>>> kris
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> "János Jarecsni" <ja...@gmail.com>
> > > > >>>>>>>>>>>> 29.04.2008 08:15
> > > > >>>>>>>>>>>> Bitte antworten an
> > > > >>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> An
> > > > >>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
> > > > >>>>>>>>>>>> Kopie
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> Thema
> > > > >>>>>>>>>>>> page activation + components
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> Hi there,
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> I have an activatable page, in its onActivate(String
> > > > >>>>>>>>>>>> param)
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>> method
> > > > >>>>>>>>>>>
> > > > >>>>>> I
> > > > >>>>>>
> > > > >>>>>>>>>>>>  save
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>  the param to a normal instance variable of the page
> > > > >>>>>>>>>>>
> > > > >>>>>>>>>>>> class
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>> (no
> > > > >>>>>>>>>>>
> > > > >>>>> persistence!).
> > > > >>>>>
> > > > >>>>>>>>>>>> How can any component embedded within this page access
> > > > >>>>>>>>>>>> this
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>> variable?
> > > > >>>>>>>>>>>
> > > > >>>>>>>> the page class:
> > > > >>>>>>>>
> > > > >>>>>>>>>>>> //...
> > > > >>>>>>>>>>>> private String param;
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> public void onActivate(String param) {
> > > > >>>>>>>>>>>>   this.param = param;
> > > > >>>>>>>>>>>> }
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> public String getParam() {...}
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>> Thx in advance!
> > > > >>>>>>>>>>>> Janos
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>>>  --
> > > > >>>>>>>>>>>>
> > > > >>>>>>>>>>> http://thegodcode.net
> > > > >>>>>>>>>>>
> > > > >>>>>>>>>>>
> > > > >>>>>>>>>>>
> > > > >>>>>>>>>>>
> > > > ------------------------------------------------------------------
> > > > >>>>>>>>>>>
> > > > >>>>>> ---
> > > > >>>>>>
> > > > >>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > >>>>>
> > > > >>>>>>>>>>> For additional commands, e-mail: users-
> > > > >>>>>>>>>>>
> > > > >>>>>>>>>>>
> > > > >>>>>>>>>> help@tapestry.apache.org
> > > > >>>>>>>>>>
> > > > >>>>>>>>>>>  --
> > > > >>>>>>>>>>>
> > > > >>>>>>>>> http://thegodcode.net
> > > > >>>>>>>>>
> > > > >>>>>>>>>
> > > > >>>>>>>>>
> > > > >>>>>>>>>
> > > > ---------------------------------------------------------------------
> > > > >>>>>>>>>
> > > > >>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > >>>>>>
> > > > >>>>>>>>> For additional commands, e-mail:
> > > > >>>>>>>>> users-help@tapestry.apache.org
> > > > >>>>>>>>>
> > > > >>>>>>>>>
> > > > >>>>>>>>>
> > > > >>>>>>>>>  --
> > > > >>>>>>>>>
> > > > >>>>>>> http://thegodcode.net
> > > > >>>>>>>
> > > > >>>>>>>
> > > > >>>>>>>
> > > > >>>>>>>
> > ------------------------------------------------------------------
> > > > >>>>>>>
> > > > >>>>>>>
> > > > >>>>>> ---
> > > > >>>>>>
> > > > >>>>> 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
> > > > >>>>
> > > > >>>>
> > > > >>>
> > > > >>
> > ---------------------------------------------------------------------
> > > > >>
> > > > >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > >> For additional commands, e-mail: users-help@tapestry.apache.org
> > > > >>
> > > > >>
> > > > >>
> > > >
> > > > --
> > > > http://thegodcode.net
> > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > For additional commands, e-mail: users-help@tapestry.apache.org
> > > >
> > > >
> > >
> >
> >
> >
> > --
> > --
> > TheDailyTube.com. Sign up and get the best new videos on the internet
> > delivered fresh to your inbox.
> >
> > ---------------------------------------------------------------------
>
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>



-- 
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.

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


Re: page activation + components

Posted by János Jarecsni <ja...@gmail.com>.
one more thing :)

"At that point you're sort of building a
framework on a framework."

No, really not. I just try to work out some best practices for my own use on
how to create truly reusable components, and how to build web sites (not
portals, cause I think the "normal" website let it be an e-commerce site or
a blog site or whatever is significantly different from a portal, and there
are quite good portal engines out there anyway :)). I like T5 quite much (I
don't know a lot of core stuff, I only read Alexander Kolesnikov's book
which is a great introduction by the way). But I found a few things which
are not supported directly and I would need these for my large scale goal:

1. automatic admin site generation (the administration or configuration of
components is an essential aspect of web applications)
2. override of resources from top to bottom (I mean, that the application
assembler should be able to replace the i18n and CSS resources of a
component with stuff of his/her liking. According to what I currently know
this is not possible, only the opposite way)
3. caching of component UI (for instance, I should be able to say in a
component which generates graphs that the framework should cache the result
for 5 minutes or until a certain event is not triggered)

and maybe more as I go ahead. Once more, I definitely don't want to build a
new framework, but these issues are quite important if you really after
creating a repository of a few dozen components which can save you the bulk
of the work when creating a new site.

I have finished my second 5 o' clock coffee and still I'm sleepy and tired.
Yesterday night there was a party in the appartment above us, and the young
guys stopped at 4am. I had a hard time remembering what it was like when I
was doing the same thing :P

Cheers,
Janos


2008/4/30 Josh Canfield <jo...@thedailytube.com>:

> Are you trying to keep the news id out of the url? Doesn't sound like
> it from your response to not doing the redirect. Since that's the
> case, why not add it to the page context?
>
> I suppose if you were building a portal with several components then
> keeping track of component parameters could get unwieldy. If you were
> showing a news article from the news portlet, and a stock highlight
> from the stock portlet... At that point you're sort of building a
> framework on a framework.
>
> You could build your page such that it accumulated context from it's
> components. Push a ComponentContext object into the Environment
> onActivate, and setupRender in your page (env gets cleared before
> render phase, not sure if there is a better way than doing it in
> both.) Then collect component parameter mappings. onPassivate for your
> page would organize and return these as it's context (you might want
> to sort them to get consistent results)
>
> Your url might look like this:
>
> http://localhost/context/mypage/cc/news/4527/stock/MCD
>
> Then onactivate you init the ComponentContext from the url keying off
> the "cc" to grab the remaining parameters and use them as key/value
> for the components. The your components do something like:
>
> @Environmental
> private ComponentContext _compContext;
>
> void setupRender() {
>  Long newsId = _compContext.getLong(_resources.getId());
> }
>
> void onPickNewsItem(Long id) {
>  _compContext.put(_resources.getId(), id);
> }
>
>
> Josh
>
> On Wed, Apr 30, 2008 at 5:23 AM, János Jarecsni
> <ja...@gmail.com> wrote:
> > Hi Chris,
> >
> > I try to explain :)
> > Say, you have a "NewsQuote" component, which shows a few lines from the
> 5
> > latest news. At the and of each quotations, there a "More" link. Now,
> when
> > the user clicks on this link (an action link, for that matter), the
> > NewsQuote component will set a request scope info saying that the news
> with
> > ID=4527 is requested. And when it comes to the "News" component (it is
> able
> > to show the text of a given news in full), it simply looks at this piece
> of
> > info, and loads the news with id 4527 (or gets it from an app level
> cache
> > :)) and renders it.
> >
> > Hope it tells something about what I am up to :)
> >
> > thx
> > Janos
> >
> > 2008/4/30 Chris Lewis <ch...@bellsouth.net>:
> >
> >
> > > Honestly it's difficult for me to imagine a situation where I'd do
> that
> > > because it seems to violate a degree of encapsulation that tapestry
> > > imposes as a "freeing law" of the framework. The epicenter of that
> being
> > > that one should not think in terms of low-level idioms such as request
> > > parameters, and instead replace those with a higher level of
> application
> > > logic that eclipses them entirely (when possible). That's not to say
> > > that your perspective is flawed, but from the small bit of
> understanding
> > > I've taken from your posts I can't see why one would do what you want.
> > > The thing that I've been saying is missing here is, what are you
> trying
> > > to do? I don't mean technically, I mean what is the end result for the
> > > user? Understanding this is critical, but even if I don't your problem
> > > can still be solved by using a session to serve as an arbitrary
> holder.
> > > If you've settled on this architecture, why not write such a generic
> > > service and move on?
> > >
> > > János Jarecsni wrote:
> > > > Hi,
> > > >
> > > > I looked everywhere for usage of request scope variables, but found
> > > nothing
> > > > (maybe I'm impatient a bit :)...
> > > > Is it really that unrealistic to have two components in a page, one
> (A)
> > > > having an action link eventhandler where it would set some attribute
> for
> > > the
> > > > request only (not the session!) and then component B could render
> itself
> > > > according to the attribute set by component A?
> > > >
> > > > I think it should be a piece of cake :)
> > > >
> > > > thx
> > > > Janos
> > > >
> > > > 2008/4/30 Filip S. Adamsen <fs...@fsadev.com>:
> > > >
> > > >
> > > >> Nope, you're exactly right.
> > > >>
> > > >> -Filip
> > > >>
> > > >> Blower, Andy skrev:
> > > >>
> > > >>  This is not what I understood 'perthread' scope to be. I thought
> that
> > > it
> > > >>
> > > >>> meant that each thread using a service gets its own instance of
> the
> > > service
> > > >>> to use, even though that instance may not be the same as any
> previous
> > > >>> instance it used. In other words, nothing to do with user
> sessions,
> > > it's
> > > >>> just for services that are not thread safe and cannot be
> singletons.
> > > >>>
> > > >>> Have I got the wrong end of the stick here?
> > > >>>
> > > >>>  -----Original Message-----
> > > >>>
> > > >>>> From: Andy Huhn [mailto:amhuhn@hrtc.net]
> > > >>>> Sent: 29 April 2008 17:34
> > > >>>> To: Tapestry users
> > > >>>> Subject: Re: page activation + components
> > > >>>>
> > > >>>>
> > > >>>> Hello,
> > > >>>>
> > > >>>> You can define the scope of each service...you can set that
> > > particular
> > > >>>> service to be tied to only one session.
> > > >>>>
> > > >>>> See
> http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html,
> > > >>>> and
> > > >>>> search for "perthread".
> > > >>>>
> > > >>>> Thanks,
> > > >>>> Andy
> > > >>>>
> > > >>>> On Tue, 29 Apr 2008 18:02:52 +0200, "János Jarecsni"
> > > >>>> <ja...@gmail.com> wrote:
> > > >>>>
> > > >>>>
> > > >>>>> Hi there,
> > > >>>>>
> > > >>>>> the service approach (as I expected) is session-agnostic (and is
> > > >>>>> page-independent so concurrent users would interfere badly),
> > > >>>>>
> > > >>>>>
> > > >>>> therefore is
> > > >>>>
> > > >>>>
> > > >>>>> not ok.
> > > >>>>>
> > > >>>>> I will now try the Environment approach... if that is
> session-aware
> > > >>>>>
> > > >>>>>
> > > >>>> :)
> > > >>>>
> > > >>>>
> > > >>>>> thx again
> > > >>>>> janos
> > > >>>>>
> > > >>>>> 2008/4/29 János Jarecsni <ja...@gmail.com>:
> > > >>>>>
> > > >>>>>  Hi Chris,
> > > >>>>>
> > > >>>>>> even so you could help :) I want this kind of generic way of
> > > >>>>>> passing
> > > >>>>>> around information (component to component communication :)) so
> > > >>>>>> I'll
> > > >>>>>>
> > > >>>>>>
> > > >>>>> look
> > > >>>>>
> > > >>>>>
> > > >>>>>> for the solutions Kristian and you outlined.
> > > >>>>>>
> > > >>>>>> thanks!
> > > >>>>>>
> > > >>>>>> cheers,
> > > >>>>>> janos
> > > >>>>>>
> > > >>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > >>>>>>
> > > >>>>>>  Janos,
> > > >>>>>>
> > > >>>>>>> Without code or a description of your actual goal, I'm finding
> > > >>>>>>>
> > > >>>>>>>
> > > >>>>>> your
> > > >>>>>>
> > > >>>>> situation too hypothetical to really digest. The one thing I can
> > > >>>>>
> > > >>>>>> point
> > > >>>>>>
> > > >>>>> out is what you said about wanting a component to set a property
> > > >>>>>
> > > >>>>>> in
> > > >>>>>>
> > > >>>>> the
> > > >>>>>
> > > >>>>>
> > > >>>>>> page. If you want to do that, then you have to know the class
> of
> > > >>>>>>
> > > >>>>>> the
> > > >>>>>>
> > > >>>>> page and so injecting a page would make sense. Of course that
> > > >>>>>
> > > >>>>>> means
> > > >>>>>>
> > > >>>>> tightly coupling a component to a page, which to me doesn't make
> > > >>>>>
> > > >>>>>> sense.
> > > >>>>>>
> > > >>>>>> If you simply need a generic way of passing data between pages
> and
> > > >>>>>>
> > > >>>>>>> components, consider using a service that provides an untyped
> > > >>>>>>> list
> > > >>>>>>>
> > > >>>>>>>
> > > >>>>>> or
> > > >>>>>>
> > > >>>>> putting something in the environment as Kristian suggested. I'm
> > > >>>>>
> > > >>>>>> sorry
> > > >>>>>>
> > > >>>>> I
> > > >>>>>
> > > >>>>>
> > > >>>>>> can't be more helpful but as I said I'm not clear on what
> you're
> > > >>>>>>
> > > >>>>>> really
> > > >>>>>>
> > > >>>>>> trying to do.
> > > >>>>>>
> > > >>>>>>> good luck
> > > >>>>>>> chris
> > > >>>>>>>
> > > >>>>>>> János Jarecsni wrote:
> > > >>>>>>>
> > > >>>>>>>
> > > >>>>>>>> Hi Chris,
> > > >>>>>>>>
> > > >>>>>>>> I thought of pages as "contexts" for the components embedded
> > > >>>>>>>>
> > > >>>>>>>>
> > > >>>>>>> within
> > > >>>>>>>
> > > >>>>> them.
> > > >>>>>
> > > >>>>>>>> So, in one event handler of a component I would like to set
> > > >>>>>>>> some
> > > >>>>>>>>
> > > >>>>>>>>
> > > >>>>>>> property or
> > > >>>>>>>
> > > >>>>>>>
> > > >>>>>>>> another (in the page object), and the other components in the
> > > >>>>>>>>
> > > >>>>>>>>
> > > >>>>>>> page,
> > > >>>>>>>
> > > >>>>> which
> > > >>>>>
> > > >>>>>>>> are also able to access this property may change their
> > > >>>>>>>>
> > > >>>>>>>>
> > > >>>>>>> appearance
> > > >>>>>>>
> > > >>>>> (say, the
> > > >>>>>
> > > >>>>>>>> .TML would test the property). Maybe I'm on a wrong track,
> > > >>>>>>>>
> > > >>>>>>>>
> > > >>>>>>> please
> > > >>>>>>>
> > > >>>>> let
> > > >>>>>
> > > >>>>>
> > > >>>>>> me
> > > >>>>>>
> > > >>>>>>>> know :)
> > > >>>>>>>>
> > > >>>>>>>> thx
> > > >>>>>>>> Cheers,
> > > >>>>>>>> janos
> > > >>>>>>>>
> > > >>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > >>>>>>>>
> > > >>>>>>>>
> > > >>>>>>>>  Janos,
> > > >>>>>>>>
> > > >>>>>>>>> I'm having a hard time understanding a case that a component
> > > >>>>>>>>>
> > > >>>>>>>>>
> > > >>>>>>>> should
> > > >>>>>>>>
> > > >>>>> know
> > > >>>>>
> > > >>>>>>>> in which page it is embedded, so my suggestion probably
> wasn't
> > > >>>>>>>>
> > > >>>>>>>> a
> > > >>>>>>>>
> > > >>>>> good
> > > >>>>>
> > > >>>>>
> > > >>>>>> one. Activation contexts aren't meant for components but for
> > > >>>>>>
> > > >>>>>>>> pages
> > > >>>>>>>>
> > > >>>>> -
> > > >>>>>
> > > >>>>>
> > > >>>>>> you
> > > >>>>>>
> > > >>>>>>>> should be using component parameters to configure them, and
> if
> > > >>>>>>>>
> > > >>>>>>>> it's
> > > >>>>>>>>
> > > >>>>> a
> > > >>>>>
> > > >>>>>
> > > >>>>>> more sophisticated component, probably a service.
> > > >>>>>>
> > > >>>>>>>>> chris
> > > >>>>>>>>>
> > > >>>>>>>>> János Jarecsni wrote:
> > > >>>>>>>>>
> > > >>>>>>>>>  and how a component can get to know the page in which it is
> > > >>>>>>>>>
> > > >>>>>>>>> included? I
> > > >>>>>>>>>
> > > >>>>>>>> mean, I can't @InjectPage, as the component will be included
> > > >>>>>>>>
> > > >>>>>>>>> in
> > > >>>>>>>>>
> > > >>>>> many
> > > >>>>>
> > > >>>>>
> > > >>>>>> kinds
> > > >>>>>>
> > > >>>>>>>>>  of pages.
> > > >>>>>>>>>
> > > >>>>>>>>>> @Kristian: thx for the many ways :) I'll try these, hope
> > > >>>>>>>>>> that
> > > >>>>>>>>>>
> > > >>>>>>>>>>
> > > >>>>>>>>> the
> > > >>>>>>>>>
> > > >>>>> @Environmental stuff is scalable (I'm trying to bypass session
> > > >>>>>
> > > >>>>>>>>> creation
> > > >>>>>>>>>
> > > >>>>>>>> as
> > > >>>>>>>>
> > > >>>>>>>>>  much as possible)
> > > >>>>>>>>>
> > > >>>>>>>>>> Is there a doc on the various annotations available?
> > > >>>>>>>>>>
> > > >>>>>>>>>> @Michael:
> > > >>>>>>>>>> Could you include a tiny bit of example? THX!
> > > >>>>>>>>>>
> > > >>>>>>>>>> Thx to you all
> > > >>>>>>>>>> cheers
> > > >>>>>>>>>> janos
> > > >>>>>>>>>>
> > > >>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > >>>>>>>>>>
> > > >>>>>>>>>>
> > > >>>>>>>>>>
> > > >>>>>>>>>>  5) @InjectPage the page and call the getter
> > > >>>>>>>>>>
> > > >>>>>>>>>>> Kristian Marinkovic wrote:
> > > >>>>>>>>>>>
> > > >>>>>>>>>>>
> > > >>>>>>>>>>>  hi janos,
> > > >>>>>>>>>>>
> > > >>>>>>>>>>>> there are several possibilities:
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> 1) declare a component parameter and pass in the
> > > >>>>>>>>>>>> variable
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> 2) put it in a ASO and inject the ASO in all your
> > > >>>>>>>>>>>> components
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>> (using
> > > >>>>>>>>>>>
> > > >>>>>>>> @ApplicationState)
> > > >>>>>>>>
> > > >>>>>>>>>>>> the drawback is that any other page or component will
> > > >>>>>>>>>>>> be
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>> able to
> > > >>>>>>>>>>>
> > > >>>>> access
> > > >>>>>
> > > >>>>>>>>>  the ASO
> > > >>>>>>>>>
> > > >>>>>>>>>>>> 3) put it into the Environment and read it whereever
> > > >>>>>>>>>>>> you
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>> need it
> > > >>>>>>>>>>>
> > > >>>>> in
> > > >>>>>
> > > >>>>>>>> your
> > > >>>>>>>>
> > > >>>>>>>>>  nested components.
> > > >>>>>>>>>
> > > >>>>>>>>>>>> be careful when you put your object in your
> > > >>>>>>>>>>>> environment. if
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>> you
> > > >>>>>>>>>>>
> > > >>>>> put it
> > > >>>>>
> > > >>>>>>>>>>>>  in
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>  during the action
> > > >>>>>>>>>>>
> > > >>>>>>>>>>>> request it will not be able in the render request
> > > >>>>>>>>>>>> (because
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>> of
> > > >>>>>>>>>>>
> > > >>>>> the
> > > >>>>>
> > > >>>>>
> > > >>>>>> page
> > > >>>>>>
> > > >>>>>>>> redirect).
> > > >>>>>>>>
> > > >>>>>>>>>>>> page:
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> @Inject Environment env;
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> @Persist("flash") whateverclass w;
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> onActivate(w) {  this.w= w }
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> setupRender() { env.push(whateverclass.class,w);}
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> components:
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> @Environmental Whateverclass var;
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> 4) define a service that can take this variable (and
> > > >>>>>>>>>>>> saves
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>> it
> > > >>>>>>>>>>>
> > > >>>>>>>>>>>>  appropriatly
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>  so it is not
> > > >>>>>>>>>>>
> > > >>>>>>>>>>>> lost on a redirect:)) and inject your service in the
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>> components
> > > >>>>>>>>>>>
> > > >>>>> where
> > > >>>>>
> > > >>>>>>>> needed
> > > >>>>>>>>
> > > >>>>>>>>>>>> to retrieve the value.
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> maybe there are some more possibilities :)
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> g,
> > > >>>>>>>>>>>> kris
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> "János Jarecsni" <ja...@gmail.com>
> > > >>>>>>>>>>>> 29.04.2008 08:15
> > > >>>>>>>>>>>> Bitte antworten an
> > > >>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> An
> > > >>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
> > > >>>>>>>>>>>> Kopie
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> Thema
> > > >>>>>>>>>>>> page activation + components
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> Hi there,
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> I have an activatable page, in its onActivate(String
> > > >>>>>>>>>>>> param)
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>> method
> > > >>>>>>>>>>>
> > > >>>>>> I
> > > >>>>>>
> > > >>>>>>>>>>>>  save
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>  the param to a normal instance variable of the page
> > > >>>>>>>>>>>
> > > >>>>>>>>>>>> class
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>> (no
> > > >>>>>>>>>>>
> > > >>>>> persistence!).
> > > >>>>>
> > > >>>>>>>>>>>> How can any component embedded within this page access
> > > >>>>>>>>>>>> this
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>> variable?
> > > >>>>>>>>>>>
> > > >>>>>>>> the page class:
> > > >>>>>>>>
> > > >>>>>>>>>>>> //...
> > > >>>>>>>>>>>> private String param;
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> public void onActivate(String param) {
> > > >>>>>>>>>>>>   this.param = param;
> > > >>>>>>>>>>>> }
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> public String getParam() {...}
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> Thx in advance!
> > > >>>>>>>>>>>> Janos
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>  --
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>> http://thegodcode.net
> > > >>>>>>>>>>>
> > > >>>>>>>>>>>
> > > >>>>>>>>>>>
> > > >>>>>>>>>>>
> > > ------------------------------------------------------------------
> > > >>>>>>>>>>>
> > > >>>>>> ---
> > > >>>>>>
> > > >>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > >>>>>
> > > >>>>>>>>>>> For additional commands, e-mail: users-
> > > >>>>>>>>>>>
> > > >>>>>>>>>>>
> > > >>>>>>>>>> help@tapestry.apache.org
> > > >>>>>>>>>>
> > > >>>>>>>>>>>  --
> > > >>>>>>>>>>>
> > > >>>>>>>>> http://thegodcode.net
> > > >>>>>>>>>
> > > >>>>>>>>>
> > > >>>>>>>>>
> > > >>>>>>>>>
> > > ---------------------------------------------------------------------
> > > >>>>>>>>>
> > > >>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > >>>>>>
> > > >>>>>>>>> For additional commands, e-mail:
> > > >>>>>>>>> users-help@tapestry.apache.org
> > > >>>>>>>>>
> > > >>>>>>>>>
> > > >>>>>>>>>
> > > >>>>>>>>>  --
> > > >>>>>>>>>
> > > >>>>>>> http://thegodcode.net
> > > >>>>>>>
> > > >>>>>>>
> > > >>>>>>>
> > > >>>>>>>
> ------------------------------------------------------------------
> > > >>>>>>>
> > > >>>>>>>
> > > >>>>>> ---
> > > >>>>>>
> > > >>>>> 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
> > > >>>>
> > > >>>>
> > > >>>
> > > >>
> ---------------------------------------------------------------------
> > > >>
> > > >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > >> For additional commands, e-mail: users-help@tapestry.apache.org
> > > >>
> > > >>
> > > >>
> > >
> > > --
> > > http://thegodcode.net
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
>
>
>
> --
> --
> TheDailyTube.com. Sign up and get the best new videos on the internet
> delivered fresh to your inbox.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: page activation + components

Posted by Chris Lewis <ch...@bellsouth.net>.
Josh,

Yeah that looks like it would do it, working much like what proposed
with pagelinks. Given a choice I would use the pagelink based way
because architecturally it works the same (news page collects the id via
context), but using pagelinks reduces the round-trips and the need to
deal with events.
Janos if you're still listening ;-), I think we've found the best ways
possible to do what you want. The missing piece is that you said your
News component was a component and not a page, so in that case use a
page property (like Josh said) and in your page's template, testing for
a valid newsId, provide the News component with it. These are the best
methods we've seen, I just can't figure out why my mind keeps saying
there's a better way :-|.

chris

Josh Canfield wrote:
> Here's an app that does what I believe is trying to be done:
>
> // Page
> public class News {
> 	@Property
> 	private Integer _newsId;
> 	public void onActivate(Integer newsId) {
> 		_newsId = newsId;
> 	}
> 	
> 	public Integer onPassivate() {
> 		return _newsId;
> 	}
> }
>
> // Page Template
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
>   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
>
> <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
> <body>
> <t:newsQuote newsId="newsId" />
> </body>
> </html>
>
> // Component
> public class NewsQuote {
>
> 	@Parameter
> 	private Integer _newsId;
>
> 	@Inject
> 	private ComponentResources _resources;
>
> 	void beginRender(MarkupWriter writer) {
> 		writer.element("ul");
> 		for (int i = 0; i < 5; ++i) {
> 			writer.element("li");
> 			Link link = _resources.createActionLink("show", false, i);
> 			writer.element("a", "href", link.toURI());
> 			writer.write("News number " + i);
> 			writer.end();
> 			if (_newsId != null && _newsId.equals(i)) {
> 				writer.write(" You picked " + _newsId);
> 			}
> 			writer.end();
> 		}
> 		writer.end();
> 	}
> 	
> 	// The Action handler
> 	void onShow(Integer id) {
> 		// stored into the bound parameter, feeding it back into the page
> 		_newsId = id;
> 	}
> }
>
> The url http://localhost:8080/news/4
>
> Renders
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>
>   <link href="/assets/tapestry/default.css" rel="stylesheet" type="text/css">
> </head>
> <body>
> <ul>
> <li><a href="/news.newsquote:show/0?t:ac=4">News number 0</a></li>
> <li><a href="/news.newsquote:show/1?t:ac=4">News number 1</a></li>
> <li><a href="/news.newsquote:show/2?t:ac=4">News number 2</a></li>
> <li><a href="/news.newsquote:show/3?t:ac=4">News number 3</a></li>
> <li><a href="/news.newsquote:show/4?t:ac=4">News number 4</a> You picked 4</li>
> </ul>
> </body>
> </html>
>
> Josh
>
> On Wed, Apr 30, 2008 at 2:49 PM, Chris Lewis <ch...@bellsouth.net> wrote:
>   
>> I do hope we've missed a simpler way, but I don't think it's surfaced
>> yet. Regarding parameters, how would that address the issue? NewsQuote
>> displays a collection of items as links that represent selectable items
>> (expressed as links). The action must be taken based on the user's
>> selection, so a component parameter doesn't apply here.
>> The event-based approach seems a theoretical perfect fit, but I can't
>> see how to do it without using @Persist (which Janos wants to avoid).
>> The only other thing I thought of is to have the NewsQuote component
>> generate pagelinks based on the containing page instead of action links.
>> This circumvents entirely the need for the events as the value will be
>> in the page context, does not not make 2 requests, and ultimately gets
>> the job done. It doesn't seem as elegant to me, but does the job and is
>> completely decoupled from the page.
>>
>> Still not sure if we've had our epiphany yet :-)
>>
>> chris
>>
>>
>> Josh Canfield wrote:
>>     
>>>> I mean really, how is that any simpler than
>>>> dealing directly with query parameters?
>>>>
>>>>         
>>> Hehe... I have to admit that I was solving a much more complicated
>>> problem than the original question, probably brought on by an earlier
>>> request about dynamic component rendering... I was shooting for
>>> completely decoupled context handling for an unknown assortment of
>>> components. Say you have 50 potential portlet components on a page
>>> that may get included multiple times and may or may not add to the
>>> context of the page, you probably don't want to manage that through
>>> individual page properties.
>>>
>>> Anyway,
>>> Isn't the straight forward solution to this problem to use component
>>> parameters as Joel pointed out? If your NewsQuote component accepts a
>>> newsId parameter, that binding is bi-directional. When the event
>>> occurs in the component it calls the setter of the bound parameter,
>>> which updates the value in the page and gets put back into the url via
>>> context returned by onPassivate. When the value is set during render
>>> time the component grabs the news item and renders it, if not it grabs
>>> the top five and displays them...
>>>
>>> Perhaps as Joel pointed out we're just making this too complicated and
>>> we should be the ones kicked out!
>>>
>>> Josh
>>>
>>> On Wed, Apr 30, 2008 at 1:27 PM, Chris Lewis <ch...@bellsouth.net> wrote:
>>>
>>>       
>>>> I see how this whole push on/pull off environment will solve the issue,
>>>> but it just seems so nasty. I mean really, how is that any simpler than
>>>> dealing directly with query parameters? I point at this only to
>>>> highlight that perhaps Janos has brought to light a legitimately rough
>>>> edge in T5, or else there's a cleaner way to do it and we're all just
>>>> missing it. I'm convinced that the event system is the way to go as it
>>>> seems a natural fit, but the redirect-after-action part is rendering it
>>>> useless without using @Persist! Let me share what I've put together, and
>>>> maybe someone will find the missing piece. I have a working test and
>>>> I'll abbreviate the code here and assume a few things:
>>>>
>>>> (coming in another message - i tripped the spam filter :-| )
>>>>
>>>>
>>>> Josh Canfield wrote:
>>>>
>>>>         
>>>>> Are you trying to keep the news id out of the url? Doesn't sound like
>>>>> it from your response to not doing the redirect. Since that's the
>>>>> case, why not add it to the page context?
>>>>>
>>>>> I suppose if you were building a portal with several components then
>>>>> keeping track of component parameters could get unwieldy. If you were
>>>>> showing a news article from the news portlet, and a stock highlight
>>>>> from the stock portlet... At that point you're sort of building a
>>>>> framework on a framework.
>>>>>
>>>>> You could build your page such that it accumulated context from it's
>>>>> components. Push a ComponentContext object into the Environment
>>>>> onActivate, and setupRender in your page (env gets cleared before
>>>>> render phase, not sure if there is a better way than doing it in
>>>>> both.) Then collect component parameter mappings. onPassivate for your
>>>>> page would organize and return these as it's context (you might want
>>>>> to sort them to get consistent results)
>>>>>
>>>>> Your url might look like this:
>>>>>
>>>>> http://localhost/context/mypage/cc/news/4527/stock/MCD
>>>>>
>>>>> Then onactivate you init the ComponentContext from the url keying off
>>>>> the "cc" to grab the remaining parameters and use them as key/value
>>>>> for the components. The your components do something like:
>>>>>
>>>>> @Environmental
>>>>> private ComponentContext _compContext;
>>>>>
>>>>> void setupRender() {
>>>>>   Long newsId = _compContext.getLong(_resources.getId());
>>>>> }
>>>>>
>>>>> void onPickNewsItem(Long id) {
>>>>>   _compContext.put(_resources.getId(), id);
>>>>> }
>>>>>
>>>>>
>>>>> Josh
>>>>>
>>>>> On Wed, Apr 30, 2008 at 5:23 AM, János Jarecsni
>>>>> <ja...@gmail.com> wrote:
>>>>>
>>>>>
>>>>>           
>>>>>> Hi Chris,
>>>>>>
>>>>>> I try to explain :)
>>>>>> Say, you have a "NewsQuote" component, which shows a few lines from the 5
>>>>>> latest news. At the and of each quotations, there a "More" link. Now, when
>>>>>> the user clicks on this link (an action link, for that matter), the
>>>>>> NewsQuote component will set a request scope info saying that the news with
>>>>>> ID=4527 is requested. And when it comes to the "News" component (it is able
>>>>>> to show the text of a given news in full), it simply looks at this piece of
>>>>>> info, and loads the news with id 4527 (or gets it from an app level cache
>>>>>> :)) and renders it.
>>>>>>
>>>>>> Hope it tells something about what I am up to :)
>>>>>>
>>>>>> thx
>>>>>> Janos
>>>>>>
>>>>>> 2008/4/30 Chris Lewis <ch...@bellsouth.net>:
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>             
>>>>>>> Honestly it's difficult for me to imagine a situation where I'd do that
>>>>>>> because it seems to violate a degree of encapsulation that tapestry
>>>>>>> imposes as a "freeing law" of the framework. The epicenter of that being
>>>>>>> that one should not think in terms of low-level idioms such as request
>>>>>>> parameters, and instead replace those with a higher level of application
>>>>>>> logic that eclipses them entirely (when possible). That's not to say
>>>>>>> that your perspective is flawed, but from the small bit of understanding
>>>>>>> I've taken from your posts I can't see why one would do what you want.
>>>>>>> The thing that I've been saying is missing here is, what are you trying
>>>>>>> to do? I don't mean technically, I mean what is the end result for the
>>>>>>> user? Understanding this is critical, but even if I don't your problem
>>>>>>> can still be solved by using a session to serve as an arbitrary holder.
>>>>>>> If you've settled on this architecture, why not write such a generic
>>>>>>> service and move on?
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>               
>> --
>> http://thegodcode.net
>>
>>
>>     
>
>
>
>   

-- 
http://thegodcode.net


Re: page activation + components

Posted by Josh Canfield <jo...@thedailytube.com>.
Here's an app that does what I believe is trying to be done:

// Page
public class News {
	@Property
	private Integer _newsId;
	public void onActivate(Integer newsId) {
		_newsId = newsId;
	}
	
	public Integer onPassivate() {
		return _newsId;
	}
}

// Page Template
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
<body>
<t:newsQuote newsId="newsId" />
</body>
</html>

// Component
public class NewsQuote {

	@Parameter
	private Integer _newsId;

	@Inject
	private ComponentResources _resources;

	void beginRender(MarkupWriter writer) {
		writer.element("ul");
		for (int i = 0; i < 5; ++i) {
			writer.element("li");
			Link link = _resources.createActionLink("show", false, i);
			writer.element("a", "href", link.toURI());
			writer.write("News number " + i);
			writer.end();
			if (_newsId != null && _newsId.equals(i)) {
				writer.write(" You picked " + _newsId);
			}
			writer.end();
		}
		writer.end();
	}
	
	// The Action handler
	void onShow(Integer id) {
		// stored into the bound parameter, feeding it back into the page
		_newsId = id;
	}
}

The url http://localhost:8080/news/4

Renders

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <link href="/assets/tapestry/default.css" rel="stylesheet" type="text/css">
</head>
<body>
<ul>
<li><a href="/news.newsquote:show/0?t:ac=4">News number 0</a></li>
<li><a href="/news.newsquote:show/1?t:ac=4">News number 1</a></li>
<li><a href="/news.newsquote:show/2?t:ac=4">News number 2</a></li>
<li><a href="/news.newsquote:show/3?t:ac=4">News number 3</a></li>
<li><a href="/news.newsquote:show/4?t:ac=4">News number 4</a> You picked 4</li>
</ul>
</body>
</html>

Josh

On Wed, Apr 30, 2008 at 2:49 PM, Chris Lewis <ch...@bellsouth.net> wrote:
> I do hope we've missed a simpler way, but I don't think it's surfaced
> yet. Regarding parameters, how would that address the issue? NewsQuote
> displays a collection of items as links that represent selectable items
> (expressed as links). The action must be taken based on the user's
> selection, so a component parameter doesn't apply here.
> The event-based approach seems a theoretical perfect fit, but I can't
> see how to do it without using @Persist (which Janos wants to avoid).
> The only other thing I thought of is to have the NewsQuote component
> generate pagelinks based on the containing page instead of action links.
> This circumvents entirely the need for the events as the value will be
> in the page context, does not not make 2 requests, and ultimately gets
> the job done. It doesn't seem as elegant to me, but does the job and is
> completely decoupled from the page.
>
> Still not sure if we've had our epiphany yet :-)
>
> chris
>
>
> Josh Canfield wrote:
> >> I mean really, how is that any simpler than
> >> dealing directly with query parameters?
> >>
> >
> > Hehe... I have to admit that I was solving a much more complicated
> > problem than the original question, probably brought on by an earlier
> > request about dynamic component rendering... I was shooting for
> > completely decoupled context handling for an unknown assortment of
> > components. Say you have 50 potential portlet components on a page
> > that may get included multiple times and may or may not add to the
> > context of the page, you probably don't want to manage that through
> > individual page properties.
> >
> > Anyway,
> > Isn't the straight forward solution to this problem to use component
> > parameters as Joel pointed out? If your NewsQuote component accepts a
> > newsId parameter, that binding is bi-directional. When the event
> > occurs in the component it calls the setter of the bound parameter,
> > which updates the value in the page and gets put back into the url via
> > context returned by onPassivate. When the value is set during render
> > time the component grabs the news item and renders it, if not it grabs
> > the top five and displays them...
> >
> > Perhaps as Joel pointed out we're just making this too complicated and
> > we should be the ones kicked out!
> >
> > Josh
> >
> > On Wed, Apr 30, 2008 at 1:27 PM, Chris Lewis <ch...@bellsouth.net> wrote:
> >
> >> I see how this whole push on/pull off environment will solve the issue,
> >> but it just seems so nasty. I mean really, how is that any simpler than
> >> dealing directly with query parameters? I point at this only to
> >> highlight that perhaps Janos has brought to light a legitimately rough
> >> edge in T5, or else there's a cleaner way to do it and we're all just
> >> missing it. I'm convinced that the event system is the way to go as it
> >> seems a natural fit, but the redirect-after-action part is rendering it
> >> useless without using @Persist! Let me share what I've put together, and
> >> maybe someone will find the missing piece. I have a working test and
> >> I'll abbreviate the code here and assume a few things:
> >>
> >> (coming in another message - i tripped the spam filter :-| )
> >>
> >>
> >> Josh Canfield wrote:
> >>
> >>> Are you trying to keep the news id out of the url? Doesn't sound like
> >>> it from your response to not doing the redirect. Since that's the
> >>> case, why not add it to the page context?
> >>>
> >>> I suppose if you were building a portal with several components then
> >>> keeping track of component parameters could get unwieldy. If you were
> >>> showing a news article from the news portlet, and a stock highlight
> >>> from the stock portlet... At that point you're sort of building a
> >>> framework on a framework.
> >>>
> >>> You could build your page such that it accumulated context from it's
> >>> components. Push a ComponentContext object into the Environment
> >>> onActivate, and setupRender in your page (env gets cleared before
> >>> render phase, not sure if there is a better way than doing it in
> >>> both.) Then collect component parameter mappings. onPassivate for your
> >>> page would organize and return these as it's context (you might want
> >>> to sort them to get consistent results)
> >>>
> >>> Your url might look like this:
> >>>
> >>> http://localhost/context/mypage/cc/news/4527/stock/MCD
> >>>
> >>> Then onactivate you init the ComponentContext from the url keying off
> >>> the "cc" to grab the remaining parameters and use them as key/value
> >>> for the components. The your components do something like:
> >>>
> >>> @Environmental
> >>> private ComponentContext _compContext;
> >>>
> >>> void setupRender() {
> >>>   Long newsId = _compContext.getLong(_resources.getId());
> >>> }
> >>>
> >>> void onPickNewsItem(Long id) {
> >>>   _compContext.put(_resources.getId(), id);
> >>> }
> >>>
> >>>
> >>> Josh
> >>>
> >>> On Wed, Apr 30, 2008 at 5:23 AM, János Jarecsni
> >>> <ja...@gmail.com> wrote:
> >>>
> >>>
> >>>> Hi Chris,
> >>>>
> >>>> I try to explain :)
> >>>> Say, you have a "NewsQuote" component, which shows a few lines from the 5
> >>>> latest news. At the and of each quotations, there a "More" link. Now, when
> >>>> the user clicks on this link (an action link, for that matter), the
> >>>> NewsQuote component will set a request scope info saying that the news with
> >>>> ID=4527 is requested. And when it comes to the "News" component (it is able
> >>>> to show the text of a given news in full), it simply looks at this piece of
> >>>> info, and loads the news with id 4527 (or gets it from an app level cache
> >>>> :)) and renders it.
> >>>>
> >>>> Hope it tells something about what I am up to :)
> >>>>
> >>>> thx
> >>>> Janos
> >>>>
> >>>> 2008/4/30 Chris Lewis <ch...@bellsouth.net>:
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>> Honestly it's difficult for me to imagine a situation where I'd do that
> >>>>> because it seems to violate a degree of encapsulation that tapestry
> >>>>> imposes as a "freeing law" of the framework. The epicenter of that being
> >>>>> that one should not think in terms of low-level idioms such as request
> >>>>> parameters, and instead replace those with a higher level of application
> >>>>> logic that eclipses them entirely (when possible). That's not to say
> >>>>> that your perspective is flawed, but from the small bit of understanding
> >>>>> I've taken from your posts I can't see why one would do what you want.
> >>>>> The thing that I've been saying is missing here is, what are you trying
> >>>>> to do? I don't mean technically, I mean what is the end result for the
> >>>>> user? Understanding this is critical, but even if I don't your problem
> >>>>> can still be solved by using a session to serve as an arbitrary holder.
> >>>>> If you've settled on this architecture, why not write such a generic
> >>>>> service and move on?
> >>>>>
> >>>>>
> >>>>>
>
> --
> http://thegodcode.net
>
>



-- 
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.

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


Re: page activation + components

Posted by Chris Lewis <ch...@bellsouth.net>.
I do hope we've missed a simpler way, but I don't think it's surfaced
yet. Regarding parameters, how would that address the issue? NewsQuote
displays a collection of items as links that represent selectable items
(expressed as links). The action must be taken based on the user's
selection, so a component parameter doesn't apply here.
The event-based approach seems a theoretical perfect fit, but I can't
see how to do it without using @Persist (which Janos wants to avoid).
The only other thing I thought of is to have the NewsQuote component
generate pagelinks based on the containing page instead of action links.
This circumvents entirely the need for the events as the value will be
in the page context, does not not make 2 requests, and ultimately gets
the job done. It doesn't seem as elegant to me, but does the job and is
completely decoupled from the page.

Still not sure if we've had our epiphany yet :-)

chris

Josh Canfield wrote:
>> I mean really, how is that any simpler than
>> dealing directly with query parameters?
>>     
>
> Hehe... I have to admit that I was solving a much more complicated
> problem than the original question, probably brought on by an earlier
> request about dynamic component rendering... I was shooting for
> completely decoupled context handling for an unknown assortment of
> components. Say you have 50 potential portlet components on a page
> that may get included multiple times and may or may not add to the
> context of the page, you probably don't want to manage that through
> individual page properties.
>
> Anyway,
> Isn't the straight forward solution to this problem to use component
> parameters as Joel pointed out? If your NewsQuote component accepts a
> newsId parameter, that binding is bi-directional. When the event
> occurs in the component it calls the setter of the bound parameter,
> which updates the value in the page and gets put back into the url via
> context returned by onPassivate. When the value is set during render
> time the component grabs the news item and renders it, if not it grabs
> the top five and displays them...
>
> Perhaps as Joel pointed out we're just making this too complicated and
> we should be the ones kicked out!
>
> Josh
>
> On Wed, Apr 30, 2008 at 1:27 PM, Chris Lewis <ch...@bellsouth.net> wrote:
>   
>> I see how this whole push on/pull off environment will solve the issue,
>> but it just seems so nasty. I mean really, how is that any simpler than
>> dealing directly with query parameters? I point at this only to
>> highlight that perhaps Janos has brought to light a legitimately rough
>> edge in T5, or else there's a cleaner way to do it and we're all just
>> missing it. I'm convinced that the event system is the way to go as it
>> seems a natural fit, but the redirect-after-action part is rendering it
>> useless without using @Persist! Let me share what I've put together, and
>> maybe someone will find the missing piece. I have a working test and
>> I'll abbreviate the code here and assume a few things:
>>
>> (coming in another message - i tripped the spam filter :-| )
>>
>>
>> Josh Canfield wrote:
>>     
>>> Are you trying to keep the news id out of the url? Doesn't sound like
>>> it from your response to not doing the redirect. Since that's the
>>> case, why not add it to the page context?
>>>
>>> I suppose if you were building a portal with several components then
>>> keeping track of component parameters could get unwieldy. If you were
>>> showing a news article from the news portlet, and a stock highlight
>>> from the stock portlet... At that point you're sort of building a
>>> framework on a framework.
>>>
>>> You could build your page such that it accumulated context from it's
>>> components. Push a ComponentContext object into the Environment
>>> onActivate, and setupRender in your page (env gets cleared before
>>> render phase, not sure if there is a better way than doing it in
>>> both.) Then collect component parameter mappings. onPassivate for your
>>> page would organize and return these as it's context (you might want
>>> to sort them to get consistent results)
>>>
>>> Your url might look like this:
>>>
>>> http://localhost/context/mypage/cc/news/4527/stock/MCD
>>>
>>> Then onactivate you init the ComponentContext from the url keying off
>>> the "cc" to grab the remaining parameters and use them as key/value
>>> for the components. The your components do something like:
>>>
>>> @Environmental
>>> private ComponentContext _compContext;
>>>
>>> void setupRender() {
>>>   Long newsId = _compContext.getLong(_resources.getId());
>>> }
>>>
>>> void onPickNewsItem(Long id) {
>>>   _compContext.put(_resources.getId(), id);
>>> }
>>>
>>>
>>> Josh
>>>
>>> On Wed, Apr 30, 2008 at 5:23 AM, János Jarecsni
>>> <ja...@gmail.com> wrote:
>>>
>>>       
>>>> Hi Chris,
>>>>
>>>> I try to explain :)
>>>> Say, you have a "NewsQuote" component, which shows a few lines from the 5
>>>> latest news. At the and of each quotations, there a "More" link. Now, when
>>>> the user clicks on this link (an action link, for that matter), the
>>>> NewsQuote component will set a request scope info saying that the news with
>>>> ID=4527 is requested. And when it comes to the "News" component (it is able
>>>> to show the text of a given news in full), it simply looks at this piece of
>>>> info, and loads the news with id 4527 (or gets it from an app level cache
>>>> :)) and renders it.
>>>>
>>>> Hope it tells something about what I am up to :)
>>>>
>>>> thx
>>>> Janos
>>>>
>>>> 2008/4/30 Chris Lewis <ch...@bellsouth.net>:
>>>>
>>>>
>>>>
>>>>         
>>>>> Honestly it's difficult for me to imagine a situation where I'd do that
>>>>> because it seems to violate a degree of encapsulation that tapestry
>>>>> imposes as a "freeing law" of the framework. The epicenter of that being
>>>>> that one should not think in terms of low-level idioms such as request
>>>>> parameters, and instead replace those with a higher level of application
>>>>> logic that eclipses them entirely (when possible). That's not to say
>>>>> that your perspective is flawed, but from the small bit of understanding
>>>>> I've taken from your posts I can't see why one would do what you want.
>>>>> The thing that I've been saying is missing here is, what are you trying
>>>>> to do? I don't mean technically, I mean what is the end result for the
>>>>> user? Understanding this is critical, but even if I don't your problem
>>>>> can still be solved by using a session to serve as an arbitrary holder.
>>>>> If you've settled on this architecture, why not write such a generic
>>>>> service and move on?
>>>>>
>>>>>
>>>>>           

-- 
http://thegodcode.net


Re: page activation + components

Posted by Josh Canfield <jo...@thedailytube.com>.
> I mean really, how is that any simpler than
> dealing directly with query parameters?

Hehe... I have to admit that I was solving a much more complicated
problem than the original question, probably brought on by an earlier
request about dynamic component rendering... I was shooting for
completely decoupled context handling for an unknown assortment of
components. Say you have 50 potential portlet components on a page
that may get included multiple times and may or may not add to the
context of the page, you probably don't want to manage that through
individual page properties.

Anyway,
Isn't the straight forward solution to this problem to use component
parameters as Joel pointed out? If your NewsQuote component accepts a
newsId parameter, that binding is bi-directional. When the event
occurs in the component it calls the setter of the bound parameter,
which updates the value in the page and gets put back into the url via
context returned by onPassivate. When the value is set during render
time the component grabs the news item and renders it, if not it grabs
the top five and displays them...

Perhaps as Joel pointed out we're just making this too complicated and
we should be the ones kicked out!

Josh

On Wed, Apr 30, 2008 at 1:27 PM, Chris Lewis <ch...@bellsouth.net> wrote:
> I see how this whole push on/pull off environment will solve the issue,
> but it just seems so nasty. I mean really, how is that any simpler than
> dealing directly with query parameters? I point at this only to
> highlight that perhaps Janos has brought to light a legitimately rough
> edge in T5, or else there's a cleaner way to do it and we're all just
> missing it. I'm convinced that the event system is the way to go as it
> seems a natural fit, but the redirect-after-action part is rendering it
> useless without using @Persist! Let me share what I've put together, and
> maybe someone will find the missing piece. I have a working test and
> I'll abbreviate the code here and assume a few things:
>
> (coming in another message - i tripped the spam filter :-| )
>
>
> Josh Canfield wrote:
> > Are you trying to keep the news id out of the url? Doesn't sound like
> > it from your response to not doing the redirect. Since that's the
> > case, why not add it to the page context?
> >
> > I suppose if you were building a portal with several components then
> > keeping track of component parameters could get unwieldy. If you were
> > showing a news article from the news portlet, and a stock highlight
> > from the stock portlet... At that point you're sort of building a
> > framework on a framework.
> >
> > You could build your page such that it accumulated context from it's
> > components. Push a ComponentContext object into the Environment
> > onActivate, and setupRender in your page (env gets cleared before
> > render phase, not sure if there is a better way than doing it in
> > both.) Then collect component parameter mappings. onPassivate for your
> > page would organize and return these as it's context (you might want
> > to sort them to get consistent results)
> >
> > Your url might look like this:
> >
> > http://localhost/context/mypage/cc/news/4527/stock/MCD
> >
> > Then onactivate you init the ComponentContext from the url keying off
> > the "cc" to grab the remaining parameters and use them as key/value
> > for the components. The your components do something like:
> >
> > @Environmental
> > private ComponentContext _compContext;
> >
> > void setupRender() {
> >   Long newsId = _compContext.getLong(_resources.getId());
> > }
> >
> > void onPickNewsItem(Long id) {
> >   _compContext.put(_resources.getId(), id);
> > }
> >
> >
> > Josh
> >
> > On Wed, Apr 30, 2008 at 5:23 AM, János Jarecsni
> > <ja...@gmail.com> wrote:
> >
> >> Hi Chris,
> >>
> >> I try to explain :)
> >> Say, you have a "NewsQuote" component, which shows a few lines from the 5
> >> latest news. At the and of each quotations, there a "More" link. Now, when
> >> the user clicks on this link (an action link, for that matter), the
> >> NewsQuote component will set a request scope info saying that the news with
> >> ID=4527 is requested. And when it comes to the "News" component (it is able
> >> to show the text of a given news in full), it simply looks at this piece of
> >> info, and loads the news with id 4527 (or gets it from an app level cache
> >> :)) and renders it.
> >>
> >> Hope it tells something about what I am up to :)
> >>
> >> thx
> >> Janos
> >>
> >> 2008/4/30 Chris Lewis <ch...@bellsouth.net>:
> >>
> >>
> >>
> >>> Honestly it's difficult for me to imagine a situation where I'd do that
> >>> because it seems to violate a degree of encapsulation that tapestry
> >>> imposes as a "freeing law" of the framework. The epicenter of that being
> >>> that one should not think in terms of low-level idioms such as request
> >>> parameters, and instead replace those with a higher level of application
> >>> logic that eclipses them entirely (when possible). That's not to say
> >>> that your perspective is flawed, but from the small bit of understanding
> >>> I've taken from your posts I can't see why one would do what you want.
> >>> The thing that I've been saying is missing here is, what are you trying
> >>> to do? I don't mean technically, I mean what is the end result for the
> >>> user? Understanding this is critical, but even if I don't your problem
> >>> can still be solved by using a session to serve as an arbitrary holder.
> >>> If you've settled on this architecture, why not write such a generic
> >>> service and move on?
> >>>
> >>> János Jarecsni wrote:
> >>>
> >>>> Hi,
> >>>>
> >>>> I looked everywhere for usage of request scope variables, but found
> >>>>
> >>> nothing
> >>>
> >>>> (maybe I'm impatient a bit :)...
> >>>> Is it really that unrealistic to have two components in a page, one (A)
> >>>> having an action link eventhandler where it would set some attribute for
> >>>>
> >>> the
> >>>
> >>>> request only (not the session!) and then component B could render itself
> >>>> according to the attribute set by component A?
> >>>>
> >>>> I think it should be a piece of cake :)
> >>>>
> >>>> thx
> >>>> Janos
> >>>>
> >>>> 2008/4/30 Filip S. Adamsen <fs...@fsadev.com>:
> >>>>
> >>>>
> >>>>
> >>>>> Nope, you're exactly right.
> >>>>>
> >>>>> -Filip
> >>>>>
> >>>>> Blower, Andy skrev:
> >>>>>
> >>>>>  This is not what I understood 'perthread' scope to be. I thought that
> >>>>>
> >>> it
> >>>
> >>>>>> meant that each thread using a service gets its own instance of the
> >>>>>>
> >>> service
> >>>
> >>>>>> to use, even though that instance may not be the same as any previous
> >>>>>> instance it used. In other words, nothing to do with user sessions,
> >>>>>>
> >>> it's
> >>>
> >>>>>> just for services that are not thread safe and cannot be singletons.
> >>>>>>
> >>>>>> Have I got the wrong end of the stick here?
> >>>>>>
> >>>>>>  -----Original Message-----
> >>>>>>
> >>>>>>
> >>>>>>> From: Andy Huhn [mailto:amhuhn@hrtc.net]
> >>>>>>> Sent: 29 April 2008 17:34
> >>>>>>> To: Tapestry users
> >>>>>>> Subject: Re: page activation + components
> >>>>>>>
> >>>>>>>
> >>>>>>> Hello,
> >>>>>>>
> >>>>>>> You can define the scope of each service...you can set that
> >>>>>>>
> >>> particular
> >>>
> >>>>>>> service to be tied to only one session.
> >>>>>>>
> >>>>>>> See http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html,
> >>>>>>> and
> >>>>>>> search for "perthread".
> >>>>>>>
> >>>>>>> Thanks,
> >>>>>>> Andy
> >>>>>>>
> >>>>>>> On Tue, 29 Apr 2008 18:02:52 +0200, "János Jarecsni"
> >>>>>>> <ja...@gmail.com> wrote:
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>> Hi there,
> >>>>>>>>
> >>>>>>>> the service approach (as I expected) is session-agnostic (and is
> >>>>>>>> page-independent so concurrent users would interfere badly),
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>> therefore is
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>> not ok.
> >>>>>>>>
> >>>>>>>> I will now try the Environment approach... if that is session-aware
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>> :)
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>> thx again
> >>>>>>>> janos
> >>>>>>>>
> >>>>>>>> 2008/4/29 János Jarecsni <ja...@gmail.com>:
> >>>>>>>>
> >>>>>>>>  Hi Chris,
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>> even so you could help :) I want this kind of generic way of
> >>>>>>>>> passing
> >>>>>>>>> around information (component to component communication :)) so
> >>>>>>>>> I'll
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>> look
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>> for the solutions Kristian and you outlined.
> >>>>>>>>>
> >>>>>>>>> thanks!
> >>>>>>>>>
> >>>>>>>>> cheers,
> >>>>>>>>> janos
> >>>>>>>>>
> >>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> >>>>>>>>>
> >>>>>>>>>  Janos,
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>> Without code or a description of your actual goal, I'm finding
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>> your
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>> situation too hypothetical to really digest. The one thing I can
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>> point
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>> out is what you said about wanting a component to set a property
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>> in
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>> the
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>> page. If you want to do that, then you have to know the class of
> >>>>>>>>>
> >>>>>>>>> the
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>> page and so injecting a page would make sense. Of course that
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>> means
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>> tightly coupling a component to a page, which to me doesn't make
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>> sense.
> >>>>>>>>>
> >>>>>>>>> If you simply need a generic way of passing data between pages and
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>> components, consider using a service that provides an untyped
> >>>>>>>>>> list
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>> or
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>> putting something in the environment as Kristian suggested. I'm
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>> sorry
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>> I
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>> can't be more helpful but as I said I'm not clear on what you're
> >>>>>>>>>
> >>>>>>>>> really
> >>>>>>>>>
> >>>>>>>>> trying to do.
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>> good luck
> >>>>>>>>>> chris
> >>>>>>>>>>
> >>>>>>>>>> János Jarecsni wrote:
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>> Hi Chris,
> >>>>>>>>>>>
> >>>>>>>>>>> I thought of pages as "contexts" for the components embedded
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>> within
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>> them.
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>>> So, in one event handler of a component I would like to set
> >>>>>>>>>>> some
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>> property or
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>> another (in the page object), and the other components in the
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>> page,
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>> which
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>>> are also able to access this property may change their
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>> appearance
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>> (say, the
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>>> .TML would test the property). Maybe I'm on a wrong track,
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>> please
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>> let
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>> me
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>>> know :)
> >>>>>>>>>>>
> >>>>>>>>>>> thx
> >>>>>>>>>>> Cheers,
> >>>>>>>>>>> janos
> >>>>>>>>>>>
> >>>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>  Janos,
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>> I'm having a hard time understanding a case that a component
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>> should
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>> know
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>>> in which page it is embedded, so my suggestion probably wasn't
> >>>>>>>>>>>
> >>>>>>>>>>> a
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>> good
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>> one. Activation contexts aren't meant for components but for
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>>> pages
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>> -
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>> you
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>>> should be using component parameters to configure them, and if
> >>>>>>>>>>>
> >>>>>>>>>>> it's
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>> a
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>> more sophisticated component, probably a service.
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>>>> chris
> >>>>>>>>>>>>
> >>>>>>>>>>>> János Jarecsni wrote:
> >>>>>>>>>>>>
> >>>>>>>>>>>>  and how a component can get to know the page in which it is
> >>>>>>>>>>>>
> >>>>>>>>>>>> included? I
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>> mean, I can't @InjectPage, as the component will be included
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>> in
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>> many
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>> kinds
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>>>>  of pages.
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>> @Kristian: thx for the many ways :) I'll try these, hope
> >>>>>>>>>>>>> that
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>> the
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>> @Environmental stuff is scalable (I'm trying to bypass session
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>>>> creation
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>> as
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>>  much as possible)
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>> Is there a doc on the various annotations available?
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> @Michael:
> >>>>>>>>>>>>> Could you include a tiny bit of example? THX!
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> Thx to you all
> >>>>>>>>>>>>> cheers
> >>>>>>>>>>>>> janos
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>  5) @InjectPage the page and call the getter
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>> Kristian Marinkovic wrote:
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>  hi janos,
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> there are several possibilities:
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> 1) declare a component parameter and pass in the
> >>>>>>>>>>>>>>> variable
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> 2) put it in a ASO and inject the ASO in all your
> >>>>>>>>>>>>>>> components
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>> (using
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>> @ApplicationState)
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>>>>> the drawback is that any other page or component will
> >>>>>>>>>>>>>>> be
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>> able to
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>> access
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>>>>  the ASO
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>>>> 3) put it into the Environment and read it whereever
> >>>>>>>>>>>>>>> you
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>> need it
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>> in
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>>> your
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>>  nested components.
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>>>> be careful when you put your object in your
> >>>>>>>>>>>>>>> environment. if
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>> you
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>> put it
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>>>>>>>  in
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>  during the action
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> request it will not be able in the render request
> >>>>>>>>>>>>>>> (because
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>> of
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>> the
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>> page
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>>> redirect).
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>>>>> page:
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> @Inject Environment env;
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> @Persist("flash") whateverclass w;
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> onActivate(w) {  this.w= w }
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> setupRender() { env.push(whateverclass.class,w);}
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> components:
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> @Environmental Whateverclass var;
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> 4) define a service that can take this variable (and
> >>>>>>>>>>>>>>> saves
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>> it
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>  appropriatly
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>  so it is not
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> lost on a redirect:)) and inject your service in the
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>> components
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>> where
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>>> needed
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>>>>> to retrieve the value.
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> maybe there are some more possibilities :)
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> g,
> >>>>>>>>>>>>>>> kris
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> "János Jarecsni" <ja...@gmail.com>
> >>>>>>>>>>>>>>> 29.04.2008 08:15
> >>>>>>>>>>>>>>> Bitte antworten an
> >>>>>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> An
> >>>>>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
> >>>>>>>>>>>>>>> Kopie
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> Thema
> >>>>>>>>>>>>>>> page activation + components
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> Hi there,
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> I have an activatable page, in its onActivate(String
> >>>>>>>>>>>>>>> param)
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>> method
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>> I
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>>>>>>>  save
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>  the param to a normal instance variable of the page
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> class
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>> (no
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>> persistence!).
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>>>>>>> How can any component embedded within this page access
> >>>>>>>>>>>>>>> this
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>> variable?
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>> the page class:
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>>>>> //...
> >>>>>>>>>>>>>>> private String param;
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> public void onActivate(String param) {
> >>>>>>>>>>>>>>>   this.param = param;
> >>>>>>>>>>>>>>> }
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> public String getParam() {...}
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> Thx in advance!
> >>>>>>>>>>>>>>> Janos
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>  --
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>> http://thegodcode.net
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>> ------------------------------------------------------------------
> >>>
> >>>>>>>>> ---
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>>>>>> For additional commands, e-mail: users-
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>> help@tapestry.apache.org
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>>  --
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>> http://thegodcode.net
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>> ---------------------------------------------------------------------
> >>>
> >>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>>>> For additional commands, e-mail:
> >>>>>>>>>>>> users-help@tapestry.apache.org
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>  --
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>> http://thegodcode.net
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>> ------------------------------------------------------------------
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>> ---
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>> 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
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>> ---------------------------------------------------------------------
> >>>>>
> >>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >>>>> For additional commands, e-mail: users-help@tapestry.apache.org
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>> --
> >>> http://thegodcode.net
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >>> For additional commands, e-mail: users-help@tapestry.apache.org
> >>>
> >>>
> >>>
> >
> >
> >
> >
>
> --
> http://thegodcode.net
>
>



-- 
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.

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


RE: page activation + components

Posted by Joel Wiegman <Jo...@dswinc.com>.
I may be chiming in a little late on this, but if Janos is just trying to communicate activation context values to child components, isn't this what the @Parameter annotation of a component is for?

http://tapestry.apache.org/tapestry5/tapestry-core/guide/parameters.html

Just kick me out if I'm off base... I only skimmed the thread.
 

-----Original Message-----
From: Chris Lewis [mailto:chris_lewis@bellsouth.net] 
Sent: Wednesday, April 30, 2008 4:27 PM
To: Tapestry users
Subject: Re: page activation + components

I see how this whole push on/pull off environment will solve the issue, but it just seems so nasty. I mean really, how is that any simpler than dealing directly with query parameters? I point at this only to highlight that perhaps Janos has brought to light a legitimately rough edge in T5, or else there's a cleaner way to do it and we're all just missing it. I'm convinced that the event system is the way to go as it seems a natural fit, but the redirect-after-action part is rendering it useless without using @Persist! Let me share what I've put together, and maybe someone will find the missing piece. I have a working test and I'll abbreviate the code here and assume a few things:

(coming in another message - i tripped the spam filter :-| )

Josh Canfield wrote:
> Are you trying to keep the news id out of the url? Doesn't sound like 
> it from your response to not doing the redirect. Since that's the 
> case, why not add it to the page context?
>
> I suppose if you were building a portal with several components then 
> keeping track of component parameters could get unwieldy. If you were 
> showing a news article from the news portlet, and a stock highlight 
> from the stock portlet... At that point you're sort of building a 
> framework on a framework.
>
> You could build your page such that it accumulated context from it's 
> components. Push a ComponentContext object into the Environment 
> onActivate, and setupRender in your page (env gets cleared before 
> render phase, not sure if there is a better way than doing it in
> both.) Then collect component parameter mappings. onPassivate for your 
> page would organize and return these as it's context (you might want 
> to sort them to get consistent results)
>
> Your url might look like this:
>
> http://localhost/context/mypage/cc/news/4527/stock/MCD
>
> Then onactivate you init the ComponentContext from the url keying off 
> the "cc" to grab the remaining parameters and use them as key/value 
> for the components. The your components do something like:
>
> @Environmental
> private ComponentContext _compContext;
>
> void setupRender() {
>   Long newsId = _compContext.getLong(_resources.getId());
> }
>
> void onPickNewsItem(Long id) {
>   _compContext.put(_resources.getId(), id); }
>
>
> Josh
>
> On Wed, Apr 30, 2008 at 5:23 AM, János Jarecsni
> <ja...@gmail.com> wrote:
>   
>> Hi Chris,
>>
>> I try to explain :)
>> Say, you have a "NewsQuote" component, which shows a few lines from the 5
>> latest news. At the and of each quotations, there a "More" link. Now, when
>> the user clicks on this link (an action link, for that matter), the
>> NewsQuote component will set a request scope info saying that the news with
>> ID=4527 is requested. And when it comes to the "News" component (it is able
>> to show the text of a given news in full), it simply looks at this piece of
>> info, and loads the news with id 4527 (or gets it from an app level cache
>> :)) and renders it.
>>
>> Hope it tells something about what I am up to :)
>>
>> thx
>> Janos
>>
>> 2008/4/30 Chris Lewis <ch...@bellsouth.net>:
>>
>>
>>     
>>> Honestly it's difficult for me to imagine a situation where I'd do that
>>> because it seems to violate a degree of encapsulation that tapestry
>>> imposes as a "freeing law" of the framework. The epicenter of that being
>>> that one should not think in terms of low-level idioms such as request
>>> parameters, and instead replace those with a higher level of application
>>> logic that eclipses them entirely (when possible). That's not to say
>>> that your perspective is flawed, but from the small bit of understanding
>>> I've taken from your posts I can't see why one would do what you want.
>>> The thing that I've been saying is missing here is, what are you trying
>>> to do? I don't mean technically, I mean what is the end result for the
>>> user? Understanding this is critical, but even if I don't your problem
>>> can still be solved by using a session to serve as an arbitrary holder.
>>> If you've settled on this architecture, why not write such a generic
>>> service and move on?
>>>
>>> János Jarecsni wrote:
>>>       
>>>> Hi,
>>>>
>>>> I looked everywhere for usage of request scope variables, but found
>>>>         
>>> nothing
>>>       
>>>> (maybe I'm impatient a bit :)...
>>>> Is it really that unrealistic to have two components in a page, one (A)
>>>> having an action link eventhandler where it would set some attribute for
>>>>         
>>> the
>>>       
>>>> request only (not the session!) and then component B could render itself
>>>> according to the attribute set by component A?
>>>>
>>>> I think it should be a piece of cake :)
>>>>
>>>> thx
>>>> Janos
>>>>
>>>> 2008/4/30 Filip S. Adamsen <fs...@fsadev.com>:
>>>>
>>>>
>>>>         
>>>>> Nope, you're exactly right.
>>>>>
>>>>> -Filip
>>>>>
>>>>> Blower, Andy skrev:
>>>>>
>>>>>  This is not what I understood 'perthread' scope to be. I thought that
>>>>>           
>>> it
>>>       
>>>>>> meant that each thread using a service gets its own instance of the
>>>>>>             
>>> service
>>>       
>>>>>> to use, even though that instance may not be the same as any previous
>>>>>> instance it used. In other words, nothing to do with user sessions,
>>>>>>             
>>> it's
>>>       
>>>>>> just for services that are not thread safe and cannot be singletons.
>>>>>>
>>>>>> Have I got the wrong end of the stick here?
>>>>>>
>>>>>>  -----Original Message-----
>>>>>>
>>>>>>             
>>>>>>> From: Andy Huhn [mailto:amhuhn@hrtc.net]
>>>>>>> Sent: 29 April 2008 17:34
>>>>>>> To: Tapestry users
>>>>>>> Subject: Re: page activation + components
>>>>>>>
>>>>>>>
>>>>>>> Hello,
>>>>>>>
>>>>>>> You can define the scope of each service...you can set that
>>>>>>>               
>>> particular
>>>       
>>>>>>> service to be tied to only one session.
>>>>>>>
>>>>>>> See http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html,
>>>>>>> and
>>>>>>> search for "perthread".
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Andy
>>>>>>>
>>>>>>> On Tue, 29 Apr 2008 18:02:52 +0200, "János Jarecsni"
>>>>>>> <ja...@gmail.com> wrote:
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> Hi there,
>>>>>>>>
>>>>>>>> the service approach (as I expected) is session-agnostic (and is
>>>>>>>> page-independent so concurrent users would interfere badly),
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>> therefore is
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> not ok.
>>>>>>>>
>>>>>>>> I will now try the Environment approach... if that is session-aware
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>> :)
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> thx again
>>>>>>>> janos
>>>>>>>>
>>>>>>>> 2008/4/29 János Jarecsni <ja...@gmail.com>:
>>>>>>>>
>>>>>>>>  Hi Chris,
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> even so you could help :) I want this kind of generic way of
>>>>>>>>> passing
>>>>>>>>> around information (component to component communication :)) so
>>>>>>>>> I'll
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> look
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> for the solutions Kristian and you outlined.
>>>>>>>>>
>>>>>>>>> thanks!
>>>>>>>>>
>>>>>>>>> cheers,
>>>>>>>>> janos
>>>>>>>>>
>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>>>>>>>>>
>>>>>>>>>  Janos,
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> Without code or a description of your actual goal, I'm finding
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> your
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> situation too hypothetical to really digest. The one thing I can
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> point
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> out is what you said about wanting a component to set a property
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> in
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> the
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> page. If you want to do that, then you have to know the class of
>>>>>>>>>
>>>>>>>>> the
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> page and so injecting a page would make sense. Of course that
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> means
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> tightly coupling a component to a page, which to me doesn't make
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> sense.
>>>>>>>>>
>>>>>>>>> If you simply need a generic way of passing data between pages and
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> components, consider using a service that provides an untyped
>>>>>>>>>> list
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> or
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> putting something in the environment as Kristian suggested. I'm
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> sorry
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> I
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> can't be more helpful but as I said I'm not clear on what you're
>>>>>>>>>
>>>>>>>>> really
>>>>>>>>>
>>>>>>>>> trying to do.
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> good luck
>>>>>>>>>> chris
>>>>>>>>>>
>>>>>>>>>> János Jarecsni wrote:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>> Hi Chris,
>>>>>>>>>>>
>>>>>>>>>>> I thought of pages as "contexts" for the components embedded
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> within
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>> them.
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>> So, in one event handler of a component I would like to set
>>>>>>>>>>> some
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> property or
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>> another (in the page object), and the other components in the
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> page,
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>> which
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>> are also able to access this property may change their
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> appearance
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>> (say, the
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>> .TML would test the property). Maybe I'm on a wrong track,
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> please
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>> let
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> me
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>> know :)
>>>>>>>>>>>
>>>>>>>>>>> thx
>>>>>>>>>>> Cheers,
>>>>>>>>>>> janos
>>>>>>>>>>>
>>>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>  Janos,
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>> I'm having a hard time understanding a case that a component
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> should
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>> know
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>> in which page it is embedded, so my suggestion probably wasn't
>>>>>>>>>>>
>>>>>>>>>>> a
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>> good
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> one. Activation contexts aren't meant for components but for
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>> pages
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>> -
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> you
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>> should be using component parameters to configure them, and if
>>>>>>>>>>>
>>>>>>>>>>> it's
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>> a
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> more sophisticated component, probably a service.
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>>> chris
>>>>>>>>>>>>
>>>>>>>>>>>> János Jarecsni wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>  and how a component can get to know the page in which it is
>>>>>>>>>>>>
>>>>>>>>>>>> included? I
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> mean, I can't @InjectPage, as the component will be included
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>> in
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>> many
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> kinds
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>>>  of pages.
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>> @Kristian: thx for the many ways :) I'll try these, hope
>>>>>>>>>>>>> that
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>> the
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>> @Environmental stuff is scalable (I'm trying to bypass session
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>>> creation
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> as
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>>  much as possible)
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>> Is there a doc on the various annotations available?
>>>>>>>>>>>>>
>>>>>>>>>>>>> @Michael:
>>>>>>>>>>>>> Could you include a tiny bit of example? THX!
>>>>>>>>>>>>>
>>>>>>>>>>>>> Thx to you all
>>>>>>>>>>>>> cheers
>>>>>>>>>>>>> janos
>>>>>>>>>>>>>
>>>>>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>  5) @InjectPage the page and call the getter
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>> Kristian Marinkovic wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  hi janos,
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>> there are several possibilities:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> 1) declare a component parameter and pass in the
>>>>>>>>>>>>>>> variable
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> 2) put it in a ASO and inject the ASO in all your
>>>>>>>>>>>>>>> components
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> (using
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>> @ApplicationState)
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>>>>> the drawback is that any other page or component will
>>>>>>>>>>>>>>> be
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> able to
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>> access
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>>>  the ASO
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>>>> 3) put it into the Environment and read it whereever
>>>>>>>>>>>>>>> you
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> need it
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>> in
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>> your
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>>  nested components.
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>>>> be careful when you put your object in your
>>>>>>>>>>>>>>> environment. if
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> you
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>> put it
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>>>>>>  in
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>>  during the action
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>> request it will not be able in the render request
>>>>>>>>>>>>>>> (because
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> of
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>> the
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> page
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>> redirect).
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>>>>> page:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> @Inject Environment env;
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> @Persist("flash") whateverclass w;
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> onActivate(w) {  this.w= w }
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> setupRender() { env.push(whateverclass.class,w);}
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> components:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> @Environmental Whateverclass var;
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> 4) define a service that can take this variable (and
>>>>>>>>>>>>>>> saves
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> it
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>>  appropriatly
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>>  so it is not
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>> lost on a redirect:)) and inject your service in the
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> components
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>> where
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>> needed
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>>>>> to retrieve the value.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> maybe there are some more possibilities :)
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> g,
>>>>>>>>>>>>>>> kris
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> "János Jarecsni" <ja...@gmail.com>
>>>>>>>>>>>>>>> 29.04.2008 08:15
>>>>>>>>>>>>>>> Bitte antworten an
>>>>>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> An
>>>>>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
>>>>>>>>>>>>>>> Kopie
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Thema
>>>>>>>>>>>>>>> page activation + components
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Hi there,
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> I have an activatable page, in its onActivate(String
>>>>>>>>>>>>>>> param)
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> method
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>> I
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>>>>>>  save
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>>  the param to a normal instance variable of the page
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>> class
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> (no
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>> persistence!).
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>>>>>> How can any component embedded within this page access
>>>>>>>>>>>>>>> this
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> variable?
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>> the page class:
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>>>>> //...
>>>>>>>>>>>>>>> private String param;
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> public void onActivate(String param) {
>>>>>>>>>>>>>>>   this.param = param;
>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> public String getParam() {...}
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Thx in advance!
>>>>>>>>>>>>>>> Janos
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>  --
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> http://thegodcode.net
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>> ------------------------------------------------------------------
>>>       
>>>>>>>>> ---
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>>>>> For additional commands, e-mail: users-
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>> help@tapestry.apache.org
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>>  --
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>> http://thegodcode.net
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>> ---------------------------------------------------------------------
>>>       
>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>>> For additional commands, e-mail:
>>>>>>>>>>>> users-help@tapestry.apache.org
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>  --
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>> http://thegodcode.net
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> ------------------------------------------------------------------
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> ---
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> 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
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>> ---------------------------------------------------------------------
>>>>>
>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>
>>>>>
>>>>>
>>>>>           
>>> --
>>> http://thegodcode.net
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>>       
>
>
>
>   

-- 
http://thegodcode.net


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


Re: page activation + components

Posted by Chris Lewis <ch...@bellsouth.net>.
I see how this whole push on/pull off environment will solve the issue,
but it just seems so nasty. I mean really, how is that any simpler than
dealing directly with query parameters? I point at this only to
highlight that perhaps Janos has brought to light a legitimately rough
edge in T5, or else there's a cleaner way to do it and we're all just
missing it. I'm convinced that the event system is the way to go as it
seems a natural fit, but the redirect-after-action part is rendering it
useless without using @Persist! Let me share what I've put together, and
maybe someone will find the missing piece. I have a working test and
I'll abbreviate the code here and assume a few things:

(coming in another message - i tripped the spam filter :-| )

Josh Canfield wrote:
> Are you trying to keep the news id out of the url? Doesn't sound like
> it from your response to not doing the redirect. Since that's the
> case, why not add it to the page context?
>
> I suppose if you were building a portal with several components then
> keeping track of component parameters could get unwieldy. If you were
> showing a news article from the news portlet, and a stock highlight
> from the stock portlet... At that point you're sort of building a
> framework on a framework.
>
> You could build your page such that it accumulated context from it's
> components. Push a ComponentContext object into the Environment
> onActivate, and setupRender in your page (env gets cleared before
> render phase, not sure if there is a better way than doing it in
> both.) Then collect component parameter mappings. onPassivate for your
> page would organize and return these as it's context (you might want
> to sort them to get consistent results)
>
> Your url might look like this:
>
> http://localhost/context/mypage/cc/news/4527/stock/MCD
>
> Then onactivate you init the ComponentContext from the url keying off
> the "cc" to grab the remaining parameters and use them as key/value
> for the components. The your components do something like:
>
> @Environmental
> private ComponentContext _compContext;
>
> void setupRender() {
>   Long newsId = _compContext.getLong(_resources.getId());
> }
>
> void onPickNewsItem(Long id) {
>   _compContext.put(_resources.getId(), id);
> }
>
>
> Josh
>
> On Wed, Apr 30, 2008 at 5:23 AM, János Jarecsni
> <ja...@gmail.com> wrote:
>   
>> Hi Chris,
>>
>> I try to explain :)
>> Say, you have a "NewsQuote" component, which shows a few lines from the 5
>> latest news. At the and of each quotations, there a "More" link. Now, when
>> the user clicks on this link (an action link, for that matter), the
>> NewsQuote component will set a request scope info saying that the news with
>> ID=4527 is requested. And when it comes to the "News" component (it is able
>> to show the text of a given news in full), it simply looks at this piece of
>> info, and loads the news with id 4527 (or gets it from an app level cache
>> :)) and renders it.
>>
>> Hope it tells something about what I am up to :)
>>
>> thx
>> Janos
>>
>> 2008/4/30 Chris Lewis <ch...@bellsouth.net>:
>>
>>
>>     
>>> Honestly it's difficult for me to imagine a situation where I'd do that
>>> because it seems to violate a degree of encapsulation that tapestry
>>> imposes as a "freeing law" of the framework. The epicenter of that being
>>> that one should not think in terms of low-level idioms such as request
>>> parameters, and instead replace those with a higher level of application
>>> logic that eclipses them entirely (when possible). That's not to say
>>> that your perspective is flawed, but from the small bit of understanding
>>> I've taken from your posts I can't see why one would do what you want.
>>> The thing that I've been saying is missing here is, what are you trying
>>> to do? I don't mean technically, I mean what is the end result for the
>>> user? Understanding this is critical, but even if I don't your problem
>>> can still be solved by using a session to serve as an arbitrary holder.
>>> If you've settled on this architecture, why not write such a generic
>>> service and move on?
>>>
>>> János Jarecsni wrote:
>>>       
>>>> Hi,
>>>>
>>>> I looked everywhere for usage of request scope variables, but found
>>>>         
>>> nothing
>>>       
>>>> (maybe I'm impatient a bit :)...
>>>> Is it really that unrealistic to have two components in a page, one (A)
>>>> having an action link eventhandler where it would set some attribute for
>>>>         
>>> the
>>>       
>>>> request only (not the session!) and then component B could render itself
>>>> according to the attribute set by component A?
>>>>
>>>> I think it should be a piece of cake :)
>>>>
>>>> thx
>>>> Janos
>>>>
>>>> 2008/4/30 Filip S. Adamsen <fs...@fsadev.com>:
>>>>
>>>>
>>>>         
>>>>> Nope, you're exactly right.
>>>>>
>>>>> -Filip
>>>>>
>>>>> Blower, Andy skrev:
>>>>>
>>>>>  This is not what I understood 'perthread' scope to be. I thought that
>>>>>           
>>> it
>>>       
>>>>>> meant that each thread using a service gets its own instance of the
>>>>>>             
>>> service
>>>       
>>>>>> to use, even though that instance may not be the same as any previous
>>>>>> instance it used. In other words, nothing to do with user sessions,
>>>>>>             
>>> it's
>>>       
>>>>>> just for services that are not thread safe and cannot be singletons.
>>>>>>
>>>>>> Have I got the wrong end of the stick here?
>>>>>>
>>>>>>  -----Original Message-----
>>>>>>
>>>>>>             
>>>>>>> From: Andy Huhn [mailto:amhuhn@hrtc.net]
>>>>>>> Sent: 29 April 2008 17:34
>>>>>>> To: Tapestry users
>>>>>>> Subject: Re: page activation + components
>>>>>>>
>>>>>>>
>>>>>>> Hello,
>>>>>>>
>>>>>>> You can define the scope of each service...you can set that
>>>>>>>               
>>> particular
>>>       
>>>>>>> service to be tied to only one session.
>>>>>>>
>>>>>>> See http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html,
>>>>>>> and
>>>>>>> search for "perthread".
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Andy
>>>>>>>
>>>>>>> On Tue, 29 Apr 2008 18:02:52 +0200, "János Jarecsni"
>>>>>>> <ja...@gmail.com> wrote:
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> Hi there,
>>>>>>>>
>>>>>>>> the service approach (as I expected) is session-agnostic (and is
>>>>>>>> page-independent so concurrent users would interfere badly),
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>> therefore is
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> not ok.
>>>>>>>>
>>>>>>>> I will now try the Environment approach... if that is session-aware
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>> :)
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> thx again
>>>>>>>> janos
>>>>>>>>
>>>>>>>> 2008/4/29 János Jarecsni <ja...@gmail.com>:
>>>>>>>>
>>>>>>>>  Hi Chris,
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> even so you could help :) I want this kind of generic way of
>>>>>>>>> passing
>>>>>>>>> around information (component to component communication :)) so
>>>>>>>>> I'll
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> look
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> for the solutions Kristian and you outlined.
>>>>>>>>>
>>>>>>>>> thanks!
>>>>>>>>>
>>>>>>>>> cheers,
>>>>>>>>> janos
>>>>>>>>>
>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>>>>>>>>>
>>>>>>>>>  Janos,
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> Without code or a description of your actual goal, I'm finding
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> your
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> situation too hypothetical to really digest. The one thing I can
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> point
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> out is what you said about wanting a component to set a property
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> in
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> the
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> page. If you want to do that, then you have to know the class of
>>>>>>>>>
>>>>>>>>> the
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> page and so injecting a page would make sense. Of course that
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> means
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> tightly coupling a component to a page, which to me doesn't make
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> sense.
>>>>>>>>>
>>>>>>>>> If you simply need a generic way of passing data between pages and
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> components, consider using a service that provides an untyped
>>>>>>>>>> list
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> or
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> putting something in the environment as Kristian suggested. I'm
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> sorry
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> I
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> can't be more helpful but as I said I'm not clear on what you're
>>>>>>>>>
>>>>>>>>> really
>>>>>>>>>
>>>>>>>>> trying to do.
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> good luck
>>>>>>>>>> chris
>>>>>>>>>>
>>>>>>>>>> János Jarecsni wrote:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>> Hi Chris,
>>>>>>>>>>>
>>>>>>>>>>> I thought of pages as "contexts" for the components embedded
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> within
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>> them.
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>> So, in one event handler of a component I would like to set
>>>>>>>>>>> some
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> property or
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>> another (in the page object), and the other components in the
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> page,
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>> which
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>> are also able to access this property may change their
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> appearance
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>> (say, the
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>> .TML would test the property). Maybe I'm on a wrong track,
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> please
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>> let
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> me
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>> know :)
>>>>>>>>>>>
>>>>>>>>>>> thx
>>>>>>>>>>> Cheers,
>>>>>>>>>>> janos
>>>>>>>>>>>
>>>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>  Janos,
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>> I'm having a hard time understanding a case that a component
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> should
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>> know
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>> in which page it is embedded, so my suggestion probably wasn't
>>>>>>>>>>>
>>>>>>>>>>> a
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>> good
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> one. Activation contexts aren't meant for components but for
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>> pages
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>> -
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> you
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>> should be using component parameters to configure them, and if
>>>>>>>>>>>
>>>>>>>>>>> it's
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>> a
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> more sophisticated component, probably a service.
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>>> chris
>>>>>>>>>>>>
>>>>>>>>>>>> János Jarecsni wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>  and how a component can get to know the page in which it is
>>>>>>>>>>>>
>>>>>>>>>>>> included? I
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> mean, I can't @InjectPage, as the component will be included
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>> in
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>> many
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> kinds
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>>>  of pages.
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>> @Kristian: thx for the many ways :) I'll try these, hope
>>>>>>>>>>>>> that
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>> the
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>> @Environmental stuff is scalable (I'm trying to bypass session
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>>> creation
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> as
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>>  much as possible)
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>> Is there a doc on the various annotations available?
>>>>>>>>>>>>>
>>>>>>>>>>>>> @Michael:
>>>>>>>>>>>>> Could you include a tiny bit of example? THX!
>>>>>>>>>>>>>
>>>>>>>>>>>>> Thx to you all
>>>>>>>>>>>>> cheers
>>>>>>>>>>>>> janos
>>>>>>>>>>>>>
>>>>>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>  5) @InjectPage the page and call the getter
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>> Kristian Marinkovic wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  hi janos,
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>> there are several possibilities:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> 1) declare a component parameter and pass in the
>>>>>>>>>>>>>>> variable
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> 2) put it in a ASO and inject the ASO in all your
>>>>>>>>>>>>>>> components
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> (using
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>> @ApplicationState)
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>>>>> the drawback is that any other page or component will
>>>>>>>>>>>>>>> be
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> able to
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>> access
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>>>  the ASO
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>>>> 3) put it into the Environment and read it whereever
>>>>>>>>>>>>>>> you
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> need it
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>> in
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>> your
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>>  nested components.
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>>>> be careful when you put your object in your
>>>>>>>>>>>>>>> environment. if
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> you
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>> put it
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>>>>>>  in
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>>  during the action
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>> request it will not be able in the render request
>>>>>>>>>>>>>>> (because
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> of
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>> the
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> page
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>> redirect).
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>>>>> page:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> @Inject Environment env;
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> @Persist("flash") whateverclass w;
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> onActivate(w) {  this.w= w }
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> setupRender() { env.push(whateverclass.class,w);}
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> components:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> @Environmental Whateverclass var;
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> 4) define a service that can take this variable (and
>>>>>>>>>>>>>>> saves
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> it
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>>  appropriatly
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>>  so it is not
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>> lost on a redirect:)) and inject your service in the
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> components
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>> where
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>> needed
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>>>>> to retrieve the value.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> maybe there are some more possibilities :)
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> g,
>>>>>>>>>>>>>>> kris
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> "János Jarecsni" <ja...@gmail.com>
>>>>>>>>>>>>>>> 29.04.2008 08:15
>>>>>>>>>>>>>>> Bitte antworten an
>>>>>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> An
>>>>>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
>>>>>>>>>>>>>>> Kopie
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Thema
>>>>>>>>>>>>>>> page activation + components
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Hi there,
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> I have an activatable page, in its onActivate(String
>>>>>>>>>>>>>>> param)
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> method
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>> I
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>>>>>>  save
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>>  the param to a normal instance variable of the page
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>> class
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> (no
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>> persistence!).
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>>>>>> How can any component embedded within this page access
>>>>>>>>>>>>>>> this
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> variable?
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>> the page class:
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>>>>> //...
>>>>>>>>>>>>>>> private String param;
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> public void onActivate(String param) {
>>>>>>>>>>>>>>>   this.param = param;
>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> public String getParam() {...}
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Thx in advance!
>>>>>>>>>>>>>>> Janos
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>  --
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> http://thegodcode.net
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>> ------------------------------------------------------------------
>>>       
>>>>>>>>> ---
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>>>>> For additional commands, e-mail: users-
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>> help@tapestry.apache.org
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>>  --
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>> http://thegodcode.net
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>> ---------------------------------------------------------------------
>>>       
>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>>> For additional commands, e-mail:
>>>>>>>>>>>> users-help@tapestry.apache.org
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>  --
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>> http://thegodcode.net
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> ------------------------------------------------------------------
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> ---
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> 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
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>> ---------------------------------------------------------------------
>>>>>
>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>
>>>>>
>>>>>
>>>>>           
>>> --
>>> http://thegodcode.net
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>>       
>
>
>
>   

-- 
http://thegodcode.net


Re: page activation + components

Posted by Josh Canfield <jo...@thedailytube.com>.
Are you trying to keep the news id out of the url? Doesn't sound like
it from your response to not doing the redirect. Since that's the
case, why not add it to the page context?

I suppose if you were building a portal with several components then
keeping track of component parameters could get unwieldy. If you were
showing a news article from the news portlet, and a stock highlight
from the stock portlet... At that point you're sort of building a
framework on a framework.

You could build your page such that it accumulated context from it's
components. Push a ComponentContext object into the Environment
onActivate, and setupRender in your page (env gets cleared before
render phase, not sure if there is a better way than doing it in
both.) Then collect component parameter mappings. onPassivate for your
page would organize and return these as it's context (you might want
to sort them to get consistent results)

Your url might look like this:

http://localhost/context/mypage/cc/news/4527/stock/MCD

Then onactivate you init the ComponentContext from the url keying off
the "cc" to grab the remaining parameters and use them as key/value
for the components. The your components do something like:

@Environmental
private ComponentContext _compContext;

void setupRender() {
  Long newsId = _compContext.getLong(_resources.getId());
}

void onPickNewsItem(Long id) {
  _compContext.put(_resources.getId(), id);
}


Josh

On Wed, Apr 30, 2008 at 5:23 AM, János Jarecsni
<ja...@gmail.com> wrote:
> Hi Chris,
>
> I try to explain :)
> Say, you have a "NewsQuote" component, which shows a few lines from the 5
> latest news. At the and of each quotations, there a "More" link. Now, when
> the user clicks on this link (an action link, for that matter), the
> NewsQuote component will set a request scope info saying that the news with
> ID=4527 is requested. And when it comes to the "News" component (it is able
> to show the text of a given news in full), it simply looks at this piece of
> info, and loads the news with id 4527 (or gets it from an app level cache
> :)) and renders it.
>
> Hope it tells something about what I am up to :)
>
> thx
> Janos
>
> 2008/4/30 Chris Lewis <ch...@bellsouth.net>:
>
>
> > Honestly it's difficult for me to imagine a situation where I'd do that
> > because it seems to violate a degree of encapsulation that tapestry
> > imposes as a "freeing law" of the framework. The epicenter of that being
> > that one should not think in terms of low-level idioms such as request
> > parameters, and instead replace those with a higher level of application
> > logic that eclipses them entirely (when possible). That's not to say
> > that your perspective is flawed, but from the small bit of understanding
> > I've taken from your posts I can't see why one would do what you want.
> > The thing that I've been saying is missing here is, what are you trying
> > to do? I don't mean technically, I mean what is the end result for the
> > user? Understanding this is critical, but even if I don't your problem
> > can still be solved by using a session to serve as an arbitrary holder.
> > If you've settled on this architecture, why not write such a generic
> > service and move on?
> >
> > János Jarecsni wrote:
> > > Hi,
> > >
> > > I looked everywhere for usage of request scope variables, but found
> > nothing
> > > (maybe I'm impatient a bit :)...
> > > Is it really that unrealistic to have two components in a page, one (A)
> > > having an action link eventhandler where it would set some attribute for
> > the
> > > request only (not the session!) and then component B could render itself
> > > according to the attribute set by component A?
> > >
> > > I think it should be a piece of cake :)
> > >
> > > thx
> > > Janos
> > >
> > > 2008/4/30 Filip S. Adamsen <fs...@fsadev.com>:
> > >
> > >
> > >> Nope, you're exactly right.
> > >>
> > >> -Filip
> > >>
> > >> Blower, Andy skrev:
> > >>
> > >>  This is not what I understood 'perthread' scope to be. I thought that
> > it
> > >>
> > >>> meant that each thread using a service gets its own instance of the
> > service
> > >>> to use, even though that instance may not be the same as any previous
> > >>> instance it used. In other words, nothing to do with user sessions,
> > it's
> > >>> just for services that are not thread safe and cannot be singletons.
> > >>>
> > >>> Have I got the wrong end of the stick here?
> > >>>
> > >>>  -----Original Message-----
> > >>>
> > >>>> From: Andy Huhn [mailto:amhuhn@hrtc.net]
> > >>>> Sent: 29 April 2008 17:34
> > >>>> To: Tapestry users
> > >>>> Subject: Re: page activation + components
> > >>>>
> > >>>>
> > >>>> Hello,
> > >>>>
> > >>>> You can define the scope of each service...you can set that
> > particular
> > >>>> service to be tied to only one session.
> > >>>>
> > >>>> See http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html,
> > >>>> and
> > >>>> search for "perthread".
> > >>>>
> > >>>> Thanks,
> > >>>> Andy
> > >>>>
> > >>>> On Tue, 29 Apr 2008 18:02:52 +0200, "János Jarecsni"
> > >>>> <ja...@gmail.com> wrote:
> > >>>>
> > >>>>
> > >>>>> Hi there,
> > >>>>>
> > >>>>> the service approach (as I expected) is session-agnostic (and is
> > >>>>> page-independent so concurrent users would interfere badly),
> > >>>>>
> > >>>>>
> > >>>> therefore is
> > >>>>
> > >>>>
> > >>>>> not ok.
> > >>>>>
> > >>>>> I will now try the Environment approach... if that is session-aware
> > >>>>>
> > >>>>>
> > >>>> :)
> > >>>>
> > >>>>
> > >>>>> thx again
> > >>>>> janos
> > >>>>>
> > >>>>> 2008/4/29 János Jarecsni <ja...@gmail.com>:
> > >>>>>
> > >>>>>  Hi Chris,
> > >>>>>
> > >>>>>> even so you could help :) I want this kind of generic way of
> > >>>>>> passing
> > >>>>>> around information (component to component communication :)) so
> > >>>>>> I'll
> > >>>>>>
> > >>>>>>
> > >>>>> look
> > >>>>>
> > >>>>>
> > >>>>>> for the solutions Kristian and you outlined.
> > >>>>>>
> > >>>>>> thanks!
> > >>>>>>
> > >>>>>> cheers,
> > >>>>>> janos
> > >>>>>>
> > >>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > >>>>>>
> > >>>>>>  Janos,
> > >>>>>>
> > >>>>>>> Without code or a description of your actual goal, I'm finding
> > >>>>>>>
> > >>>>>>>
> > >>>>>> your
> > >>>>>>
> > >>>>> situation too hypothetical to really digest. The one thing I can
> > >>>>>
> > >>>>>> point
> > >>>>>>
> > >>>>> out is what you said about wanting a component to set a property
> > >>>>>
> > >>>>>> in
> > >>>>>>
> > >>>>> the
> > >>>>>
> > >>>>>
> > >>>>>> page. If you want to do that, then you have to know the class of
> > >>>>>>
> > >>>>>> the
> > >>>>>>
> > >>>>> page and so injecting a page would make sense. Of course that
> > >>>>>
> > >>>>>> means
> > >>>>>>
> > >>>>> tightly coupling a component to a page, which to me doesn't make
> > >>>>>
> > >>>>>> sense.
> > >>>>>>
> > >>>>>> If you simply need a generic way of passing data between pages and
> > >>>>>>
> > >>>>>>> components, consider using a service that provides an untyped
> > >>>>>>> list
> > >>>>>>>
> > >>>>>>>
> > >>>>>> or
> > >>>>>>
> > >>>>> putting something in the environment as Kristian suggested. I'm
> > >>>>>
> > >>>>>> sorry
> > >>>>>>
> > >>>>> I
> > >>>>>
> > >>>>>
> > >>>>>> can't be more helpful but as I said I'm not clear on what you're
> > >>>>>>
> > >>>>>> really
> > >>>>>>
> > >>>>>> trying to do.
> > >>>>>>
> > >>>>>>> good luck
> > >>>>>>> chris
> > >>>>>>>
> > >>>>>>> János Jarecsni wrote:
> > >>>>>>>
> > >>>>>>>
> > >>>>>>>> Hi Chris,
> > >>>>>>>>
> > >>>>>>>> I thought of pages as "contexts" for the components embedded
> > >>>>>>>>
> > >>>>>>>>
> > >>>>>>> within
> > >>>>>>>
> > >>>>> them.
> > >>>>>
> > >>>>>>>> So, in one event handler of a component I would like to set
> > >>>>>>>> some
> > >>>>>>>>
> > >>>>>>>>
> > >>>>>>> property or
> > >>>>>>>
> > >>>>>>>
> > >>>>>>>> another (in the page object), and the other components in the
> > >>>>>>>>
> > >>>>>>>>
> > >>>>>>> page,
> > >>>>>>>
> > >>>>> which
> > >>>>>
> > >>>>>>>> are also able to access this property may change their
> > >>>>>>>>
> > >>>>>>>>
> > >>>>>>> appearance
> > >>>>>>>
> > >>>>> (say, the
> > >>>>>
> > >>>>>>>> .TML would test the property). Maybe I'm on a wrong track,
> > >>>>>>>>
> > >>>>>>>>
> > >>>>>>> please
> > >>>>>>>
> > >>>>> let
> > >>>>>
> > >>>>>
> > >>>>>> me
> > >>>>>>
> > >>>>>>>> know :)
> > >>>>>>>>
> > >>>>>>>> thx
> > >>>>>>>> Cheers,
> > >>>>>>>> janos
> > >>>>>>>>
> > >>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > >>>>>>>>
> > >>>>>>>>
> > >>>>>>>>  Janos,
> > >>>>>>>>
> > >>>>>>>>> I'm having a hard time understanding a case that a component
> > >>>>>>>>>
> > >>>>>>>>>
> > >>>>>>>> should
> > >>>>>>>>
> > >>>>> know
> > >>>>>
> > >>>>>>>> in which page it is embedded, so my suggestion probably wasn't
> > >>>>>>>>
> > >>>>>>>> a
> > >>>>>>>>
> > >>>>> good
> > >>>>>
> > >>>>>
> > >>>>>> one. Activation contexts aren't meant for components but for
> > >>>>>>
> > >>>>>>>> pages
> > >>>>>>>>
> > >>>>> -
> > >>>>>
> > >>>>>
> > >>>>>> you
> > >>>>>>
> > >>>>>>>> should be using component parameters to configure them, and if
> > >>>>>>>>
> > >>>>>>>> it's
> > >>>>>>>>
> > >>>>> a
> > >>>>>
> > >>>>>
> > >>>>>> more sophisticated component, probably a service.
> > >>>>>>
> > >>>>>>>>> chris
> > >>>>>>>>>
> > >>>>>>>>> János Jarecsni wrote:
> > >>>>>>>>>
> > >>>>>>>>>  and how a component can get to know the page in which it is
> > >>>>>>>>>
> > >>>>>>>>> included? I
> > >>>>>>>>>
> > >>>>>>>> mean, I can't @InjectPage, as the component will be included
> > >>>>>>>>
> > >>>>>>>>> in
> > >>>>>>>>>
> > >>>>> many
> > >>>>>
> > >>>>>
> > >>>>>> kinds
> > >>>>>>
> > >>>>>>>>>  of pages.
> > >>>>>>>>>
> > >>>>>>>>>> @Kristian: thx for the many ways :) I'll try these, hope
> > >>>>>>>>>> that
> > >>>>>>>>>>
> > >>>>>>>>>>
> > >>>>>>>>> the
> > >>>>>>>>>
> > >>>>> @Environmental stuff is scalable (I'm trying to bypass session
> > >>>>>
> > >>>>>>>>> creation
> > >>>>>>>>>
> > >>>>>>>> as
> > >>>>>>>>
> > >>>>>>>>>  much as possible)
> > >>>>>>>>>
> > >>>>>>>>>> Is there a doc on the various annotations available?
> > >>>>>>>>>>
> > >>>>>>>>>> @Michael:
> > >>>>>>>>>> Could you include a tiny bit of example? THX!
> > >>>>>>>>>>
> > >>>>>>>>>> Thx to you all
> > >>>>>>>>>> cheers
> > >>>>>>>>>> janos
> > >>>>>>>>>>
> > >>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > >>>>>>>>>>
> > >>>>>>>>>>
> > >>>>>>>>>>
> > >>>>>>>>>>  5) @InjectPage the page and call the getter
> > >>>>>>>>>>
> > >>>>>>>>>>> Kristian Marinkovic wrote:
> > >>>>>>>>>>>
> > >>>>>>>>>>>
> > >>>>>>>>>>>  hi janos,
> > >>>>>>>>>>>
> > >>>>>>>>>>>> there are several possibilities:
> > >>>>>>>>>>>>
> > >>>>>>>>>>>> 1) declare a component parameter and pass in the
> > >>>>>>>>>>>> variable
> > >>>>>>>>>>>>
> > >>>>>>>>>>>> 2) put it in a ASO and inject the ASO in all your
> > >>>>>>>>>>>> components
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>
> > >>>>>>>>>>> (using
> > >>>>>>>>>>>
> > >>>>>>>> @ApplicationState)
> > >>>>>>>>
> > >>>>>>>>>>>> the drawback is that any other page or component will
> > >>>>>>>>>>>> be
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>
> > >>>>>>>>>>> able to
> > >>>>>>>>>>>
> > >>>>> access
> > >>>>>
> > >>>>>>>>>  the ASO
> > >>>>>>>>>
> > >>>>>>>>>>>> 3) put it into the Environment and read it whereever
> > >>>>>>>>>>>> you
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>
> > >>>>>>>>>>> need it
> > >>>>>>>>>>>
> > >>>>> in
> > >>>>>
> > >>>>>>>> your
> > >>>>>>>>
> > >>>>>>>>>  nested components.
> > >>>>>>>>>
> > >>>>>>>>>>>> be careful when you put your object in your
> > >>>>>>>>>>>> environment. if
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>
> > >>>>>>>>>>> you
> > >>>>>>>>>>>
> > >>>>> put it
> > >>>>>
> > >>>>>>>>>>>>  in
> > >>>>>>>>>>>>
> > >>>>>>>>>>>  during the action
> > >>>>>>>>>>>
> > >>>>>>>>>>>> request it will not be able in the render request
> > >>>>>>>>>>>> (because
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>
> > >>>>>>>>>>> of
> > >>>>>>>>>>>
> > >>>>> the
> > >>>>>
> > >>>>>
> > >>>>>> page
> > >>>>>>
> > >>>>>>>> redirect).
> > >>>>>>>>
> > >>>>>>>>>>>> page:
> > >>>>>>>>>>>>
> > >>>>>>>>>>>> @Inject Environment env;
> > >>>>>>>>>>>>
> > >>>>>>>>>>>> @Persist("flash") whateverclass w;
> > >>>>>>>>>>>>
> > >>>>>>>>>>>> onActivate(w) {  this.w= w }
> > >>>>>>>>>>>>
> > >>>>>>>>>>>> setupRender() { env.push(whateverclass.class,w);}
> > >>>>>>>>>>>>
> > >>>>>>>>>>>> components:
> > >>>>>>>>>>>>
> > >>>>>>>>>>>> @Environmental Whateverclass var;
> > >>>>>>>>>>>>
> > >>>>>>>>>>>> 4) define a service that can take this variable (and
> > >>>>>>>>>>>> saves
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>
> > >>>>>>>>>>> it
> > >>>>>>>>>>>
> > >>>>>>>>>>>>  appropriatly
> > >>>>>>>>>>>>
> > >>>>>>>>>>>  so it is not
> > >>>>>>>>>>>
> > >>>>>>>>>>>> lost on a redirect:)) and inject your service in the
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>
> > >>>>>>>>>>> components
> > >>>>>>>>>>>
> > >>>>> where
> > >>>>>
> > >>>>>>>> needed
> > >>>>>>>>
> > >>>>>>>>>>>> to retrieve the value.
> > >>>>>>>>>>>>
> > >>>>>>>>>>>> maybe there are some more possibilities :)
> > >>>>>>>>>>>>
> > >>>>>>>>>>>> g,
> > >>>>>>>>>>>> kris
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>
> > >>>>>>>>>>>> "János Jarecsni" <ja...@gmail.com>
> > >>>>>>>>>>>> 29.04.2008 08:15
> > >>>>>>>>>>>> Bitte antworten an
> > >>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>
> > >>>>>>>>>>>> An
> > >>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
> > >>>>>>>>>>>> Kopie
> > >>>>>>>>>>>>
> > >>>>>>>>>>>> Thema
> > >>>>>>>>>>>> page activation + components
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>
> > >>>>>>>>>>>> Hi there,
> > >>>>>>>>>>>>
> > >>>>>>>>>>>> I have an activatable page, in its onActivate(String
> > >>>>>>>>>>>> param)
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>
> > >>>>>>>>>>> method
> > >>>>>>>>>>>
> > >>>>>> I
> > >>>>>>
> > >>>>>>>>>>>>  save
> > >>>>>>>>>>>>
> > >>>>>>>>>>>  the param to a normal instance variable of the page
> > >>>>>>>>>>>
> > >>>>>>>>>>>> class
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>
> > >>>>>>>>>>> (no
> > >>>>>>>>>>>
> > >>>>> persistence!).
> > >>>>>
> > >>>>>>>>>>>> How can any component embedded within this page access
> > >>>>>>>>>>>> this
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>
> > >>>>>>>>>>> variable?
> > >>>>>>>>>>>
> > >>>>>>>> the page class:
> > >>>>>>>>
> > >>>>>>>>>>>> //...
> > >>>>>>>>>>>> private String param;
> > >>>>>>>>>>>>
> > >>>>>>>>>>>> public void onActivate(String param) {
> > >>>>>>>>>>>>   this.param = param;
> > >>>>>>>>>>>> }
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>
> > >>>>>>>>>>>> public String getParam() {...}
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>
> > >>>>>>>>>>>> Thx in advance!
> > >>>>>>>>>>>> Janos
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>  --
> > >>>>>>>>>>>>
> > >>>>>>>>>>> http://thegodcode.net
> > >>>>>>>>>>>
> > >>>>>>>>>>>
> > >>>>>>>>>>>
> > >>>>>>>>>>>
> > ------------------------------------------------------------------
> > >>>>>>>>>>>
> > >>>>>> ---
> > >>>>>>
> > >>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > >>>>>
> > >>>>>>>>>>> For additional commands, e-mail: users-
> > >>>>>>>>>>>
> > >>>>>>>>>>>
> > >>>>>>>>>> help@tapestry.apache.org
> > >>>>>>>>>>
> > >>>>>>>>>>>  --
> > >>>>>>>>>>>
> > >>>>>>>>> http://thegodcode.net
> > >>>>>>>>>
> > >>>>>>>>>
> > >>>>>>>>>
> > >>>>>>>>>
> > ---------------------------------------------------------------------
> > >>>>>>>>>
> > >>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > >>>>>>
> > >>>>>>>>> For additional commands, e-mail:
> > >>>>>>>>> users-help@tapestry.apache.org
> > >>>>>>>>>
> > >>>>>>>>>
> > >>>>>>>>>
> > >>>>>>>>>  --
> > >>>>>>>>>
> > >>>>>>> http://thegodcode.net
> > >>>>>>>
> > >>>>>>>
> > >>>>>>>
> > >>>>>>> ------------------------------------------------------------------
> > >>>>>>>
> > >>>>>>>
> > >>>>>> ---
> > >>>>>>
> > >>>>> 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
> > >>>>
> > >>>>
> > >>>
> > >> ---------------------------------------------------------------------
> > >>
> > >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > >> For additional commands, e-mail: users-help@tapestry.apache.org
> > >>
> > >>
> > >>
> >
> > --
> > http://thegodcode.net
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>



-- 
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.

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


Re: page activation + components

Posted by Chris Lewis <ch...@bellsouth.net>.
Ok, now I understand :-). I believe the tapestry way of doing this is to
use events, so your NewsQuote would be responsible for listing your news
pieces and handling the selection. When one is made, NewsQuote will fire
a component indicating the selection, and any components or pages
listening for that event can catch it and do whatever with it. I'll put
together some example code a bit later, I have run out for a bit.

sincerely,
chris

János Jarecsni wrote:
> Hi Chris,
>
> no! that's the essential part. the same page redisplayed. with the "News"
> component changing state and showing the requested news.
>
> cheers,
> janos
>
> 2008/4/30 Chris Lewis <ch...@bellsouth.net>:
>
>   
>> Much clearer :-). When you say "when it comes to my 'News' component" do
>> you mean news page? That is, clicking a 'more' link from NewsQuote leads
>> to a News page?
>>
>> János Jarecsni wrote:
>>     
>>> Hi Chris,
>>>
>>> I try to explain :)
>>> Say, you have a "NewsQuote" component, which shows a few lines from the
>>>       
>> 5
>>     
>>> latest news. At the and of each quotations, there a "More" link. Now,
>>>       
>> when
>>     
>>> the user clicks on this link (an action link, for that matter), the
>>> NewsQuote component will set a request scope info saying that the news
>>>       
>> with
>>     
>>> ID=4527 is requested. And when it comes to the "News" component (it is
>>>       
>> able
>>     
>>> to show the text of a given news in full), it simply looks at this piece
>>>       
>> of
>>     
>>> info, and loads the news with id 4527 (or gets it from an app level
>>>       
>> cache
>>     
>>> :)) and renders it.
>>>
>>> Hope it tells something about what I am up to :)
>>>
>>> thx
>>> Janos
>>>
>>> 2008/4/30 Chris Lewis <ch...@bellsouth.net>:
>>>
>>>
>>>       
>>>> Honestly it's difficult for me to imagine a situation where I'd do that
>>>> because it seems to violate a degree of encapsulation that tapestry
>>>> imposes as a "freeing law" of the framework. The epicenter of that
>>>>         
>> being
>>     
>>>> that one should not think in terms of low-level idioms such as request
>>>> parameters, and instead replace those with a higher level of
>>>>         
>> application
>>     
>>>> logic that eclipses them entirely (when possible). That's not to say
>>>> that your perspective is flawed, but from the small bit of
>>>>         
>> understanding
>>     
>>>> I've taken from your posts I can't see why one would do what you want.
>>>> The thing that I've been saying is missing here is, what are you trying
>>>> to do? I don't mean technically, I mean what is the end result for the
>>>> user? Understanding this is critical, but even if I don't your problem
>>>> can still be solved by using a session to serve as an arbitrary holder.
>>>> If you've settled on this architecture, why not write such a generic
>>>> service and move on?
>>>>
>>>> János Jarecsni wrote:
>>>>
>>>>         
>>>>> Hi,
>>>>>
>>>>> I looked everywhere for usage of request scope variables, but found
>>>>>
>>>>>           
>>>> nothing
>>>>
>>>>         
>>>>> (maybe I'm impatient a bit :)...
>>>>> Is it really that unrealistic to have two components in a page, one
>>>>>           
>> (A)
>>     
>>>>> having an action link eventhandler where it would set some attribute
>>>>>           
>> for
>>     
>>>> the
>>>>
>>>>         
>>>>> request only (not the session!) and then component B could render
>>>>>           
>> itself
>>     
>>>>> according to the attribute set by component A?
>>>>>
>>>>> I think it should be a piece of cake :)
>>>>>
>>>>> thx
>>>>> Janos
>>>>>
>>>>> 2008/4/30 Filip S. Adamsen <fs...@fsadev.com>:
>>>>>
>>>>>
>>>>>
>>>>>           
>>>>>> Nope, you're exactly right.
>>>>>>
>>>>>> -Filip
>>>>>>
>>>>>> Blower, Andy skrev:
>>>>>>
>>>>>>  This is not what I understood 'perthread' scope to be. I thought
>>>>>>             
>> that
>>     
>>>> it
>>>>
>>>>         
>>>>>>> meant that each thread using a service gets its own instance of the
>>>>>>>
>>>>>>>               
>>>> service
>>>>
>>>>         
>>>>>>> to use, even though that instance may not be the same as any
>>>>>>>               
>> previous
>>     
>>>>>>> instance it used. In other words, nothing to do with user sessions,
>>>>>>>
>>>>>>>               
>>>> it's
>>>>
>>>>         
>>>>>>> just for services that are not thread safe and cannot be singletons.
>>>>>>>
>>>>>>> Have I got the wrong end of the stick here?
>>>>>>>
>>>>>>>  -----Original Message-----
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> From: Andy Huhn [mailto:amhuhn@hrtc.net]
>>>>>>>> Sent: 29 April 2008 17:34
>>>>>>>> To: Tapestry users
>>>>>>>> Subject: Re: page activation + components
>>>>>>>>
>>>>>>>>
>>>>>>>> Hello,
>>>>>>>>
>>>>>>>> You can define the scope of each service...you can set that
>>>>>>>>
>>>>>>>>                 
>>>> particular
>>>>
>>>>         
>>>>>>>> service to be tied to only one session.
>>>>>>>>
>>>>>>>> See http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html,
>>>>>>>> and
>>>>>>>> search for "perthread".
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> Andy
>>>>>>>>
>>>>>>>> On Tue, 29 Apr 2008 18:02:52 +0200, "János Jarecsni"
>>>>>>>> <ja...@gmail.com> wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> Hi there,
>>>>>>>>>
>>>>>>>>> the service approach (as I expected) is session-agnostic (and is
>>>>>>>>> page-independent so concurrent users would interfere badly),
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> therefore is
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> not ok.
>>>>>>>>>
>>>>>>>>> I will now try the Environment approach... if that is
>>>>>>>>>                   
>> session-aware
>>     
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> :)
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> thx again
>>>>>>>>> janos
>>>>>>>>>
>>>>>>>>> 2008/4/29 János Jarecsni <ja...@gmail.com>:
>>>>>>>>>
>>>>>>>>>  Hi Chris,
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> even so you could help :) I want this kind of generic way of
>>>>>>>>>> passing
>>>>>>>>>> around information (component to component communication :)) so
>>>>>>>>>> I'll
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> look
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> for the solutions Kristian and you outlined.
>>>>>>>>>>
>>>>>>>>>> thanks!
>>>>>>>>>>
>>>>>>>>>> cheers,
>>>>>>>>>> janos
>>>>>>>>>>
>>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>>>>>>>>>>
>>>>>>>>>>  Janos,
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>> Without code or a description of your actual goal, I'm finding
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> your
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> situation too hypothetical to really digest. The one thing I can
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> point
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> out is what you said about wanting a component to set a property
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> in
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> the
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> page. If you want to do that, then you have to know the class of
>>>>>>>>>>
>>>>>>>>>> the
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> page and so injecting a page would make sense. Of course that
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> means
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> tightly coupling a component to a page, which to me doesn't make
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> sense.
>>>>>>>>>>
>>>>>>>>>> If you simply need a generic way of passing data between pages
>>>>>>>>>>                     
>> and
>>     
>>>>>>>>>>                     
>>>>>>>>>>> components, consider using a service that provides an untyped
>>>>>>>>>>> list
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> or
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> putting something in the environment as Kristian suggested. I'm
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> sorry
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> I
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> can't be more helpful but as I said I'm not clear on what you're
>>>>>>>>>>
>>>>>>>>>> really
>>>>>>>>>>
>>>>>>>>>> trying to do.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>> good luck
>>>>>>>>>>> chris
>>>>>>>>>>>
>>>>>>>>>>> János Jarecsni wrote:
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>> Hi Chris,
>>>>>>>>>>>>
>>>>>>>>>>>> I thought of pages as "contexts" for the components embedded
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> within
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>> them.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>>> So, in one event handler of a component I would like to set
>>>>>>>>>>>> some
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> property or
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>> another (in the page object), and the other components in the
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> page,
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>> which
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>>> are also able to access this property may change their
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> appearance
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>> (say, the
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>>> .TML would test the property). Maybe I'm on a wrong track,
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> please
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>> let
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> me
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>>> know :)
>>>>>>>>>>>>
>>>>>>>>>>>> thx
>>>>>>>>>>>> Cheers,
>>>>>>>>>>>> janos
>>>>>>>>>>>>
>>>>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>  Janos,
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>> I'm having a hard time understanding a case that a component
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>> should
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>> know
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>>> in which page it is embedded, so my suggestion probably wasn't
>>>>>>>>>>>>
>>>>>>>>>>>> a
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>> good
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> one. Activation contexts aren't meant for components but for
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>>> pages
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>> -
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> you
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>>> should be using component parameters to configure them, and if
>>>>>>>>>>>>
>>>>>>>>>>>> it's
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>> a
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> more sophisticated component, probably a service.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>>>> chris
>>>>>>>>>>>>>
>>>>>>>>>>>>> János Jarecsni wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>  and how a component can get to know the page in which it is
>>>>>>>>>>>>>
>>>>>>>>>>>>> included? I
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>> mean, I can't @InjectPage, as the component will be included
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>> in
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>> many
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> kinds
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>>>>  of pages.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>> @Kristian: thx for the many ways :) I'll try these, hope
>>>>>>>>>>>>>> that
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>> the
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>> @Environmental stuff is scalable (I'm trying to bypass session
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>>>> creation
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>> as
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>>  much as possible)
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>> Is there a doc on the various annotations available?
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> @Michael:
>>>>>>>>>>>>>> Could you include a tiny bit of example? THX!
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Thx to you all
>>>>>>>>>>>>>> cheers
>>>>>>>>>>>>>> janos
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  5) @InjectPage the page and call the getter
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>> Kristian Marinkovic wrote:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>  hi janos,
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>>>> there are several possibilities:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> 1) declare a component parameter and pass in the
>>>>>>>>>>>>>>>> variable
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> 2) put it in a ASO and inject the ASO in all your
>>>>>>>>>>>>>>>> components
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>                                 
>>>>>>>>>>>>>>> (using
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>> @ApplicationState)
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>>>>> the drawback is that any other page or component will
>>>>>>>>>>>>>>>> be
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>                                 
>>>>>>>>>>>>>>> able to
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>> access
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>>>>  the ASO
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>>>> 3) put it into the Environment and read it whereever
>>>>>>>>>>>>>>>> you
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>                                 
>>>>>>>>>>>>>>> need it
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>> in
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>>> your
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>>  nested components.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>>>> be careful when you put your object in your
>>>>>>>>>>>>>>>> environment. if
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>                                 
>>>>>>>>>>>>>>> you
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>> put it
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>>>>>>>  in
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>                                 
>>>>>>>>>>>>>>>  during the action
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>>>> request it will not be able in the render request
>>>>>>>>>>>>>>>> (because
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>                                 
>>>>>>>>>>>>>>> of
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>> the
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> page
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>>> redirect).
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>>>>> page:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> @Inject Environment env;
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> @Persist("flash") whateverclass w;
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> onActivate(w) {  this.w= w }
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> setupRender() { env.push(whateverclass.class,w);}
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> components:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> @Environmental Whateverclass var;
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> 4) define a service that can take this variable (and
>>>>>>>>>>>>>>>> saves
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>                                 
>>>>>>>>>>>>>>> it
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>>>>  appropriatly
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>                                 
>>>>>>>>>>>>>>>  so it is not
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>>>> lost on a redirect:)) and inject your service in the
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>                                 
>>>>>>>>>>>>>>> components
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>> where
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>>> needed
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>>>>> to retrieve the value.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> maybe there are some more possibilities :)
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> g,
>>>>>>>>>>>>>>>> kris
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> "János Jarecsni" <ja...@gmail.com>
>>>>>>>>>>>>>>>> 29.04.2008 08:15
>>>>>>>>>>>>>>>> Bitte antworten an
>>>>>>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> An
>>>>>>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
>>>>>>>>>>>>>>>> Kopie
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Thema
>>>>>>>>>>>>>>>> page activation + components
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Hi there,
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> I have an activatable page, in its onActivate(String
>>>>>>>>>>>>>>>> param)
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>                                 
>>>>>>>>>>>>>>> method
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>> I
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>>>>>>>  save
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>                                 
>>>>>>>>>>>>>>>  the param to a normal instance variable of the page
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>>>> class
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>                                 
>>>>>>>>>>>>>>> (no
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>> persistence!).
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>>>>>>> How can any component embedded within this page access
>>>>>>>>>>>>>>>> this
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>                                 
>>>>>>>>>>>>>>> variable?
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>> the page class:
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>>>>> //...
>>>>>>>>>>>>>>>> private String param;
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> public void onActivate(String param) {
>>>>>>>>>>>>>>>>   this.param = param;
>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> public String getParam() {...}
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Thx in advance!
>>>>>>>>>>>>>>>> Janos
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>  --
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>                                 
>>>>>>>>>>>>>>> http://thegodcode.net
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>> ------------------------------------------------------------------
>>>>
>>>>         
>>>>>>>>>> ---
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>>>>>>> For additional commands, e-mail: users-
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>>> help@tapestry.apache.org
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>>>  --
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>                               
>>>>>>>>>>>>> http://thegodcode.net
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>> ---------------------------------------------------------------------
>>>>
>>>>         
>>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>>>> For additional commands, e-mail:
>>>>>>>>>>>>> users-help@tapestry.apache.org
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>  --
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>> http://thegodcode.net
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>> ------------------------------------------------------------------
>>     
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> ---
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> 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
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>> ---------------------------------------------------------------------
>>>>>>
>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>             
>>>> --
>>>> http://thegodcode.net
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>>
>>>>
>>>>         
>> --
>> http://thegodcode.net
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>     

-- 
http://thegodcode.net


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


Re: page activation + components

Posted by János Jarecsni <ja...@gmail.com>.
Hi Chris,

no! that's the essential part. the same page redisplayed. with the "News"
component changing state and showing the requested news.

cheers,
janos

2008/4/30 Chris Lewis <ch...@bellsouth.net>:

> Much clearer :-). When you say "when it comes to my 'News' component" do
> you mean news page? That is, clicking a 'more' link from NewsQuote leads
> to a News page?
>
> János Jarecsni wrote:
> > Hi Chris,
> >
> > I try to explain :)
> > Say, you have a "NewsQuote" component, which shows a few lines from the
> 5
> > latest news. At the and of each quotations, there a "More" link. Now,
> when
> > the user clicks on this link (an action link, for that matter), the
> > NewsQuote component will set a request scope info saying that the news
> with
> > ID=4527 is requested. And when it comes to the "News" component (it is
> able
> > to show the text of a given news in full), it simply looks at this piece
> of
> > info, and loads the news with id 4527 (or gets it from an app level
> cache
> > :)) and renders it.
> >
> > Hope it tells something about what I am up to :)
> >
> > thx
> > Janos
> >
> > 2008/4/30 Chris Lewis <ch...@bellsouth.net>:
> >
> >
> >> Honestly it's difficult for me to imagine a situation where I'd do that
> >> because it seems to violate a degree of encapsulation that tapestry
> >> imposes as a "freeing law" of the framework. The epicenter of that
> being
> >> that one should not think in terms of low-level idioms such as request
> >> parameters, and instead replace those with a higher level of
> application
> >> logic that eclipses them entirely (when possible). That's not to say
> >> that your perspective is flawed, but from the small bit of
> understanding
> >> I've taken from your posts I can't see why one would do what you want.
> >> The thing that I've been saying is missing here is, what are you trying
> >> to do? I don't mean technically, I mean what is the end result for the
> >> user? Understanding this is critical, but even if I don't your problem
> >> can still be solved by using a session to serve as an arbitrary holder.
> >> If you've settled on this architecture, why not write such a generic
> >> service and move on?
> >>
> >> János Jarecsni wrote:
> >>
> >>> Hi,
> >>>
> >>> I looked everywhere for usage of request scope variables, but found
> >>>
> >> nothing
> >>
> >>> (maybe I'm impatient a bit :)...
> >>> Is it really that unrealistic to have two components in a page, one
> (A)
> >>> having an action link eventhandler where it would set some attribute
> for
> >>>
> >> the
> >>
> >>> request only (not the session!) and then component B could render
> itself
> >>> according to the attribute set by component A?
> >>>
> >>> I think it should be a piece of cake :)
> >>>
> >>> thx
> >>> Janos
> >>>
> >>> 2008/4/30 Filip S. Adamsen <fs...@fsadev.com>:
> >>>
> >>>
> >>>
> >>>> Nope, you're exactly right.
> >>>>
> >>>> -Filip
> >>>>
> >>>> Blower, Andy skrev:
> >>>>
> >>>>  This is not what I understood 'perthread' scope to be. I thought
> that
> >>>>
> >> it
> >>
> >>>>> meant that each thread using a service gets its own instance of the
> >>>>>
> >> service
> >>
> >>>>> to use, even though that instance may not be the same as any
> previous
> >>>>> instance it used. In other words, nothing to do with user sessions,
> >>>>>
> >> it's
> >>
> >>>>> just for services that are not thread safe and cannot be singletons.
> >>>>>
> >>>>> Have I got the wrong end of the stick here?
> >>>>>
> >>>>>  -----Original Message-----
> >>>>>
> >>>>>
> >>>>>> From: Andy Huhn [mailto:amhuhn@hrtc.net]
> >>>>>> Sent: 29 April 2008 17:34
> >>>>>> To: Tapestry users
> >>>>>> Subject: Re: page activation + components
> >>>>>>
> >>>>>>
> >>>>>> Hello,
> >>>>>>
> >>>>>> You can define the scope of each service...you can set that
> >>>>>>
> >> particular
> >>
> >>>>>> service to be tied to only one session.
> >>>>>>
> >>>>>> See http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html,
> >>>>>> and
> >>>>>> search for "perthread".
> >>>>>>
> >>>>>> Thanks,
> >>>>>> Andy
> >>>>>>
> >>>>>> On Tue, 29 Apr 2008 18:02:52 +0200, "János Jarecsni"
> >>>>>> <ja...@gmail.com> wrote:
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>> Hi there,
> >>>>>>>
> >>>>>>> the service approach (as I expected) is session-agnostic (and is
> >>>>>>> page-independent so concurrent users would interfere badly),
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>> therefore is
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>> not ok.
> >>>>>>>
> >>>>>>> I will now try the Environment approach... if that is
> session-aware
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>> :)
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>> thx again
> >>>>>>> janos
> >>>>>>>
> >>>>>>> 2008/4/29 János Jarecsni <ja...@gmail.com>:
> >>>>>>>
> >>>>>>>  Hi Chris,
> >>>>>>>
> >>>>>>>
> >>>>>>>> even so you could help :) I want this kind of generic way of
> >>>>>>>> passing
> >>>>>>>> around information (component to component communication :)) so
> >>>>>>>> I'll
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>> look
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>> for the solutions Kristian and you outlined.
> >>>>>>>>
> >>>>>>>> thanks!
> >>>>>>>>
> >>>>>>>> cheers,
> >>>>>>>> janos
> >>>>>>>>
> >>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> >>>>>>>>
> >>>>>>>>  Janos,
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>> Without code or a description of your actual goal, I'm finding
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>> your
> >>>>>>>>
> >>>>>>>>
> >>>>>>> situation too hypothetical to really digest. The one thing I can
> >>>>>>>
> >>>>>>>
> >>>>>>>> point
> >>>>>>>>
> >>>>>>>>
> >>>>>>> out is what you said about wanting a component to set a property
> >>>>>>>
> >>>>>>>
> >>>>>>>> in
> >>>>>>>>
> >>>>>>>>
> >>>>>>> the
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>> page. If you want to do that, then you have to know the class of
> >>>>>>>>
> >>>>>>>> the
> >>>>>>>>
> >>>>>>>>
> >>>>>>> page and so injecting a page would make sense. Of course that
> >>>>>>>
> >>>>>>>
> >>>>>>>> means
> >>>>>>>>
> >>>>>>>>
> >>>>>>> tightly coupling a component to a page, which to me doesn't make
> >>>>>>>
> >>>>>>>
> >>>>>>>> sense.
> >>>>>>>>
> >>>>>>>> If you simply need a generic way of passing data between pages
> and
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>> components, consider using a service that provides an untyped
> >>>>>>>>> list
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>> or
> >>>>>>>>
> >>>>>>>>
> >>>>>>> putting something in the environment as Kristian suggested. I'm
> >>>>>>>
> >>>>>>>
> >>>>>>>> sorry
> >>>>>>>>
> >>>>>>>>
> >>>>>>> I
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>> can't be more helpful but as I said I'm not clear on what you're
> >>>>>>>>
> >>>>>>>> really
> >>>>>>>>
> >>>>>>>> trying to do.
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>> good luck
> >>>>>>>>> chris
> >>>>>>>>>
> >>>>>>>>> János Jarecsni wrote:
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>> Hi Chris,
> >>>>>>>>>>
> >>>>>>>>>> I thought of pages as "contexts" for the components embedded
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>> within
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>> them.
> >>>>>>>
> >>>>>>>
> >>>>>>>>>> So, in one event handler of a component I would like to set
> >>>>>>>>>> some
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>> property or
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>> another (in the page object), and the other components in the
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>> page,
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>> which
> >>>>>>>
> >>>>>>>
> >>>>>>>>>> are also able to access this property may change their
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>> appearance
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>> (say, the
> >>>>>>>
> >>>>>>>
> >>>>>>>>>> .TML would test the property). Maybe I'm on a wrong track,
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>> please
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>> let
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>> me
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>> know :)
> >>>>>>>>>>
> >>>>>>>>>> thx
> >>>>>>>>>> Cheers,
> >>>>>>>>>> janos
> >>>>>>>>>>
> >>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>  Janos,
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>> I'm having a hard time understanding a case that a component
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>> should
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>> know
> >>>>>>>
> >>>>>>>
> >>>>>>>>>> in which page it is embedded, so my suggestion probably wasn't
> >>>>>>>>>>
> >>>>>>>>>> a
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>> good
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>> one. Activation contexts aren't meant for components but for
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>> pages
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>> -
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>> you
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>> should be using component parameters to configure them, and if
> >>>>>>>>>>
> >>>>>>>>>> it's
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>> a
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>> more sophisticated component, probably a service.
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>>> chris
> >>>>>>>>>>>
> >>>>>>>>>>> János Jarecsni wrote:
> >>>>>>>>>>>
> >>>>>>>>>>>  and how a component can get to know the page in which it is
> >>>>>>>>>>>
> >>>>>>>>>>> included? I
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>> mean, I can't @InjectPage, as the component will be included
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>> in
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>> many
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>> kinds
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>>>  of pages.
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>> @Kristian: thx for the many ways :) I'll try these, hope
> >>>>>>>>>>>> that
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>> the
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>> @Environmental stuff is scalable (I'm trying to bypass session
> >>>>>>>
> >>>>>>>
> >>>>>>>>>>> creation
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>> as
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>>  much as possible)
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>> Is there a doc on the various annotations available?
> >>>>>>>>>>>>
> >>>>>>>>>>>> @Michael:
> >>>>>>>>>>>> Could you include a tiny bit of example? THX!
> >>>>>>>>>>>>
> >>>>>>>>>>>> Thx to you all
> >>>>>>>>>>>> cheers
> >>>>>>>>>>>> janos
> >>>>>>>>>>>>
> >>>>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>  5) @InjectPage the page and call the getter
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>> Kristian Marinkovic wrote:
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>  hi janos,
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>> there are several possibilities:
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> 1) declare a component parameter and pass in the
> >>>>>>>>>>>>>> variable
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> 2) put it in a ASO and inject the ASO in all your
> >>>>>>>>>>>>>> components
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>> (using
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>> @ApplicationState)
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>>>>> the drawback is that any other page or component will
> >>>>>>>>>>>>>> be
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>> able to
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>> access
> >>>>>>>
> >>>>>>>
> >>>>>>>>>>>  the ASO
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>>>> 3) put it into the Environment and read it whereever
> >>>>>>>>>>>>>> you
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>> need it
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>> in
> >>>>>>>
> >>>>>>>
> >>>>>>>>>> your
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>>  nested components.
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>>>> be careful when you put your object in your
> >>>>>>>>>>>>>> environment. if
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>> you
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>> put it
> >>>>>>>
> >>>>>>>
> >>>>>>>>>>>>>>  in
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>  during the action
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>> request it will not be able in the render request
> >>>>>>>>>>>>>> (because
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>> of
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>> the
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>> page
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>> redirect).
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>>>>> page:
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> @Inject Environment env;
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> @Persist("flash") whateverclass w;
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> onActivate(w) {  this.w= w }
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> setupRender() { env.push(whateverclass.class,w);}
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> components:
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> @Environmental Whateverclass var;
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> 4) define a service that can take this variable (and
> >>>>>>>>>>>>>> saves
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>> it
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>>  appropriatly
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>  so it is not
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>> lost on a redirect:)) and inject your service in the
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>> components
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>> where
> >>>>>>>
> >>>>>>>
> >>>>>>>>>> needed
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>>>>> to retrieve the value.
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> maybe there are some more possibilities :)
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> g,
> >>>>>>>>>>>>>> kris
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> "János Jarecsni" <ja...@gmail.com>
> >>>>>>>>>>>>>> 29.04.2008 08:15
> >>>>>>>>>>>>>> Bitte antworten an
> >>>>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> An
> >>>>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
> >>>>>>>>>>>>>> Kopie
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> Thema
> >>>>>>>>>>>>>> page activation + components
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> Hi there,
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> I have an activatable page, in its onActivate(String
> >>>>>>>>>>>>>> param)
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>> method
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>> I
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>>>>>>  save
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>  the param to a normal instance variable of the page
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>> class
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>> (no
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>> persistence!).
> >>>>>>>
> >>>>>>>
> >>>>>>>>>>>>>> How can any component embedded within this page access
> >>>>>>>>>>>>>> this
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>> variable?
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>> the page class:
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>>>>> //...
> >>>>>>>>>>>>>> private String param;
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> public void onActivate(String param) {
> >>>>>>>>>>>>>>   this.param = param;
> >>>>>>>>>>>>>> }
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> public String getParam() {...}
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> Thx in advance!
> >>>>>>>>>>>>>> Janos
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>  --
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>> http://thegodcode.net
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >> ------------------------------------------------------------------
> >>
> >>>>>>>> ---
> >>>>>>>>
> >>>>>>>>
> >>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >>>>>>>
> >>>>>>>
> >>>>>>>>>>>>> For additional commands, e-mail: users-
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>> help@tapestry.apache.org
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>>  --
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>> http://thegodcode.net
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >> ---------------------------------------------------------------------
> >>
> >>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>>> For additional commands, e-mail:
> >>>>>>>>>>> users-help@tapestry.apache.org
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>  --
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>> http://thegodcode.net
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> ------------------------------------------------------------------
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>> ---
> >>>>>>>>
> >>>>>>>>
> >>>>>>> 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
> >>>>>>
> >>>>>>
> >>>>>>
> >>>> ---------------------------------------------------------------------
> >>>>
> >>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >>>> For additional commands, e-mail: users-help@tapestry.apache.org
> >>>>
> >>>>
> >>>>
> >>>>
> >> --
> >> http://thegodcode.net
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
> >>
>
> --
> http://thegodcode.net
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: page activation + components

Posted by Chris Lewis <ch...@bellsouth.net>.
Much clearer :-). When you say "when it comes to my 'News' component" do
you mean news page? That is, clicking a 'more' link from NewsQuote leads
to a News page?

János Jarecsni wrote:
> Hi Chris,
>
> I try to explain :)
> Say, you have a "NewsQuote" component, which shows a few lines from the 5
> latest news. At the and of each quotations, there a "More" link. Now, when
> the user clicks on this link (an action link, for that matter), the
> NewsQuote component will set a request scope info saying that the news with
> ID=4527 is requested. And when it comes to the "News" component (it is able
> to show the text of a given news in full), it simply looks at this piece of
> info, and loads the news with id 4527 (or gets it from an app level cache
> :)) and renders it.
>
> Hope it tells something about what I am up to :)
>
> thx
> Janos
>
> 2008/4/30 Chris Lewis <ch...@bellsouth.net>:
>
>   
>> Honestly it's difficult for me to imagine a situation where I'd do that
>> because it seems to violate a degree of encapsulation that tapestry
>> imposes as a "freeing law" of the framework. The epicenter of that being
>> that one should not think in terms of low-level idioms such as request
>> parameters, and instead replace those with a higher level of application
>> logic that eclipses them entirely (when possible). That's not to say
>> that your perspective is flawed, but from the small bit of understanding
>> I've taken from your posts I can't see why one would do what you want.
>> The thing that I've been saying is missing here is, what are you trying
>> to do? I don't mean technically, I mean what is the end result for the
>> user? Understanding this is critical, but even if I don't your problem
>> can still be solved by using a session to serve as an arbitrary holder.
>> If you've settled on this architecture, why not write such a generic
>> service and move on?
>>
>> János Jarecsni wrote:
>>     
>>> Hi,
>>>
>>> I looked everywhere for usage of request scope variables, but found
>>>       
>> nothing
>>     
>>> (maybe I'm impatient a bit :)...
>>> Is it really that unrealistic to have two components in a page, one (A)
>>> having an action link eventhandler where it would set some attribute for
>>>       
>> the
>>     
>>> request only (not the session!) and then component B could render itself
>>> according to the attribute set by component A?
>>>
>>> I think it should be a piece of cake :)
>>>
>>> thx
>>> Janos
>>>
>>> 2008/4/30 Filip S. Adamsen <fs...@fsadev.com>:
>>>
>>>
>>>       
>>>> Nope, you're exactly right.
>>>>
>>>> -Filip
>>>>
>>>> Blower, Andy skrev:
>>>>
>>>>  This is not what I understood 'perthread' scope to be. I thought that
>>>>         
>> it
>>     
>>>>> meant that each thread using a service gets its own instance of the
>>>>>           
>> service
>>     
>>>>> to use, even though that instance may not be the same as any previous
>>>>> instance it used. In other words, nothing to do with user sessions,
>>>>>           
>> it's
>>     
>>>>> just for services that are not thread safe and cannot be singletons.
>>>>>
>>>>> Have I got the wrong end of the stick here?
>>>>>
>>>>>  -----Original Message-----
>>>>>
>>>>>           
>>>>>> From: Andy Huhn [mailto:amhuhn@hrtc.net]
>>>>>> Sent: 29 April 2008 17:34
>>>>>> To: Tapestry users
>>>>>> Subject: Re: page activation + components
>>>>>>
>>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> You can define the scope of each service...you can set that
>>>>>>             
>> particular
>>     
>>>>>> service to be tied to only one session.
>>>>>>
>>>>>> See http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html,
>>>>>> and
>>>>>> search for "perthread".
>>>>>>
>>>>>> Thanks,
>>>>>> Andy
>>>>>>
>>>>>> On Tue, 29 Apr 2008 18:02:52 +0200, "János Jarecsni"
>>>>>> <ja...@gmail.com> wrote:
>>>>>>
>>>>>>
>>>>>>             
>>>>>>> Hi there,
>>>>>>>
>>>>>>> the service approach (as I expected) is session-agnostic (and is
>>>>>>> page-independent so concurrent users would interfere badly),
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>> therefore is
>>>>>>
>>>>>>
>>>>>>             
>>>>>>> not ok.
>>>>>>>
>>>>>>> I will now try the Environment approach... if that is session-aware
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>> :)
>>>>>>
>>>>>>
>>>>>>             
>>>>>>> thx again
>>>>>>> janos
>>>>>>>
>>>>>>> 2008/4/29 János Jarecsni <ja...@gmail.com>:
>>>>>>>
>>>>>>>  Hi Chris,
>>>>>>>
>>>>>>>               
>>>>>>>> even so you could help :) I want this kind of generic way of
>>>>>>>> passing
>>>>>>>> around information (component to component communication :)) so
>>>>>>>> I'll
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>> look
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> for the solutions Kristian and you outlined.
>>>>>>>>
>>>>>>>> thanks!
>>>>>>>>
>>>>>>>> cheers,
>>>>>>>> janos
>>>>>>>>
>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>>>>>>>>
>>>>>>>>  Janos,
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> Without code or a description of your actual goal, I'm finding
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> your
>>>>>>>>
>>>>>>>>                 
>>>>>>> situation too hypothetical to really digest. The one thing I can
>>>>>>>
>>>>>>>               
>>>>>>>> point
>>>>>>>>
>>>>>>>>                 
>>>>>>> out is what you said about wanting a component to set a property
>>>>>>>
>>>>>>>               
>>>>>>>> in
>>>>>>>>
>>>>>>>>                 
>>>>>>> the
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> page. If you want to do that, then you have to know the class of
>>>>>>>>
>>>>>>>> the
>>>>>>>>
>>>>>>>>                 
>>>>>>> page and so injecting a page would make sense. Of course that
>>>>>>>
>>>>>>>               
>>>>>>>> means
>>>>>>>>
>>>>>>>>                 
>>>>>>> tightly coupling a component to a page, which to me doesn't make
>>>>>>>
>>>>>>>               
>>>>>>>> sense.
>>>>>>>>
>>>>>>>> If you simply need a generic way of passing data between pages and
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> components, consider using a service that provides an untyped
>>>>>>>>> list
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> or
>>>>>>>>
>>>>>>>>                 
>>>>>>> putting something in the environment as Kristian suggested. I'm
>>>>>>>
>>>>>>>               
>>>>>>>> sorry
>>>>>>>>
>>>>>>>>                 
>>>>>>> I
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> can't be more helpful but as I said I'm not clear on what you're
>>>>>>>>
>>>>>>>> really
>>>>>>>>
>>>>>>>> trying to do.
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> good luck
>>>>>>>>> chris
>>>>>>>>>
>>>>>>>>> János Jarecsni wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> Hi Chris,
>>>>>>>>>>
>>>>>>>>>> I thought of pages as "contexts" for the components embedded
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> within
>>>>>>>>>
>>>>>>>>>                   
>>>>>>> them.
>>>>>>>
>>>>>>>               
>>>>>>>>>> So, in one event handler of a component I would like to set
>>>>>>>>>> some
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> property or
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>>>> another (in the page object), and the other components in the
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> page,
>>>>>>>>>
>>>>>>>>>                   
>>>>>>> which
>>>>>>>
>>>>>>>               
>>>>>>>>>> are also able to access this property may change their
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> appearance
>>>>>>>>>
>>>>>>>>>                   
>>>>>>> (say, the
>>>>>>>
>>>>>>>               
>>>>>>>>>> .TML would test the property). Maybe I'm on a wrong track,
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> please
>>>>>>>>>
>>>>>>>>>                   
>>>>>>> let
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> me
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>> know :)
>>>>>>>>>>
>>>>>>>>>> thx
>>>>>>>>>> Cheers,
>>>>>>>>>> janos
>>>>>>>>>>
>>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>  Janos,
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>> I'm having a hard time understanding a case that a component
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> should
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>> know
>>>>>>>
>>>>>>>               
>>>>>>>>>> in which page it is embedded, so my suggestion probably wasn't
>>>>>>>>>>
>>>>>>>>>> a
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>> good
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> one. Activation contexts aren't meant for components but for
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>> pages
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>> -
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> you
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>> should be using component parameters to configure them, and if
>>>>>>>>>>
>>>>>>>>>> it's
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>> a
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> more sophisticated component, probably a service.
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>> chris
>>>>>>>>>>>
>>>>>>>>>>> János Jarecsni wrote:
>>>>>>>>>>>
>>>>>>>>>>>  and how a component can get to know the page in which it is
>>>>>>>>>>>
>>>>>>>>>>> included? I
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> mean, I can't @InjectPage, as the component will be included
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>> in
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>> many
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> kinds
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>>  of pages.
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>> @Kristian: thx for the many ways :) I'll try these, hope
>>>>>>>>>>>> that
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> the
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>> @Environmental stuff is scalable (I'm trying to bypass session
>>>>>>>
>>>>>>>               
>>>>>>>>>>> creation
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> as
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>>  much as possible)
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>> Is there a doc on the various annotations available?
>>>>>>>>>>>>
>>>>>>>>>>>> @Michael:
>>>>>>>>>>>> Could you include a tiny bit of example? THX!
>>>>>>>>>>>>
>>>>>>>>>>>> Thx to you all
>>>>>>>>>>>> cheers
>>>>>>>>>>>> janos
>>>>>>>>>>>>
>>>>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>  5) @InjectPage the page and call the getter
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>> Kristian Marinkovic wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>  hi janos,
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>> there are several possibilities:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> 1) declare a component parameter and pass in the
>>>>>>>>>>>>>> variable
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> 2) put it in a ASO and inject the ASO in all your
>>>>>>>>>>>>>> components
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>> (using
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>> @ApplicationState)
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>>>>> the drawback is that any other page or component will
>>>>>>>>>>>>>> be
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>> able to
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>> access
>>>>>>>
>>>>>>>               
>>>>>>>>>>>  the ASO
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>>>> 3) put it into the Environment and read it whereever
>>>>>>>>>>>>>> you
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>> need it
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>> in
>>>>>>>
>>>>>>>               
>>>>>>>>>> your
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>>  nested components.
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>>>>>> be careful when you put your object in your
>>>>>>>>>>>>>> environment. if
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>> you
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>> put it
>>>>>>>
>>>>>>>               
>>>>>>>>>>>>>>  in
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>  during the action
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>> request it will not be able in the render request
>>>>>>>>>>>>>> (because
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>> of
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>> the
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> page
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>> redirect).
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>>>>> page:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> @Inject Environment env;
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> @Persist("flash") whateverclass w;
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> onActivate(w) {  this.w= w }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> setupRender() { env.push(whateverclass.class,w);}
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> components:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> @Environmental Whateverclass var;
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> 4) define a service that can take this variable (and
>>>>>>>>>>>>>> saves
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>> it
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>>  appropriatly
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>  so it is not
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>> lost on a redirect:)) and inject your service in the
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>> components
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>> where
>>>>>>>
>>>>>>>               
>>>>>>>>>> needed
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>>>>> to retrieve the value.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> maybe there are some more possibilities :)
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> g,
>>>>>>>>>>>>>> kris
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> "János Jarecsni" <ja...@gmail.com>
>>>>>>>>>>>>>> 29.04.2008 08:15
>>>>>>>>>>>>>> Bitte antworten an
>>>>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> An
>>>>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
>>>>>>>>>>>>>> Kopie
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Thema
>>>>>>>>>>>>>> page activation + components
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Hi there,
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> I have an activatable page, in its onActivate(String
>>>>>>>>>>>>>> param)
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>> method
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>> I
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>>>>>  save
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>>  the param to a normal instance variable of the page
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>>>> class
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>> (no
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>> persistence!).
>>>>>>>
>>>>>>>               
>>>>>>>>>>>>>> How can any component embedded within this page access
>>>>>>>>>>>>>> this
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>> variable?
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>> the page class:
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>>>>>>> //...
>>>>>>>>>>>>>> private String param;
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> public void onActivate(String param) {
>>>>>>>>>>>>>>   this.param = param;
>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> public String getParam() {...}
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Thx in advance!
>>>>>>>>>>>>>> Janos
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  --
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>                             
>>>>>>>>>>>>> http://thegodcode.net
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>> ------------------------------------------------------------------
>>     
>>>>>>>> ---
>>>>>>>>
>>>>>>>>                 
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>
>>>>>>>               
>>>>>>>>>>>>> For additional commands, e-mail: users-
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>>> help@tapestry.apache.org
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>>>>  --
>>>>>>>>>>>>>
>>>>>>>>>>>>>                           
>>>>>>>>>>> http://thegodcode.net
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                       
>> ---------------------------------------------------------------------
>>     
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>>
>>>>>>>>                 
>>>>>>>>>>> For additional commands, e-mail:
>>>>>>>>>>> users-help@tapestry.apache.org
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>  --
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>> http://thegodcode.net
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> ------------------------------------------------------------------
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> ---
>>>>>>>>
>>>>>>>>                 
>>>>>>> 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
>>>>>>
>>>>>>
>>>>>>             
>>>> ---------------------------------------------------------------------
>>>>
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>>
>>>>
>>>>         
>> --
>> http://thegodcode.net
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>     

-- 
http://thegodcode.net


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


Re: page activation + components

Posted by János Jarecsni <ja...@gmail.com>.
Hi Chris,

I try to explain :)
Say, you have a "NewsQuote" component, which shows a few lines from the 5
latest news. At the and of each quotations, there a "More" link. Now, when
the user clicks on this link (an action link, for that matter), the
NewsQuote component will set a request scope info saying that the news with
ID=4527 is requested. And when it comes to the "News" component (it is able
to show the text of a given news in full), it simply looks at this piece of
info, and loads the news with id 4527 (or gets it from an app level cache
:)) and renders it.

Hope it tells something about what I am up to :)

thx
Janos

2008/4/30 Chris Lewis <ch...@bellsouth.net>:

> Honestly it's difficult for me to imagine a situation where I'd do that
> because it seems to violate a degree of encapsulation that tapestry
> imposes as a "freeing law" of the framework. The epicenter of that being
> that one should not think in terms of low-level idioms such as request
> parameters, and instead replace those with a higher level of application
> logic that eclipses them entirely (when possible). That's not to say
> that your perspective is flawed, but from the small bit of understanding
> I've taken from your posts I can't see why one would do what you want.
> The thing that I've been saying is missing here is, what are you trying
> to do? I don't mean technically, I mean what is the end result for the
> user? Understanding this is critical, but even if I don't your problem
> can still be solved by using a session to serve as an arbitrary holder.
> If you've settled on this architecture, why not write such a generic
> service and move on?
>
> János Jarecsni wrote:
> > Hi,
> >
> > I looked everywhere for usage of request scope variables, but found
> nothing
> > (maybe I'm impatient a bit :)...
> > Is it really that unrealistic to have two components in a page, one (A)
> > having an action link eventhandler where it would set some attribute for
> the
> > request only (not the session!) and then component B could render itself
> > according to the attribute set by component A?
> >
> > I think it should be a piece of cake :)
> >
> > thx
> > Janos
> >
> > 2008/4/30 Filip S. Adamsen <fs...@fsadev.com>:
> >
> >
> >> Nope, you're exactly right.
> >>
> >> -Filip
> >>
> >> Blower, Andy skrev:
> >>
> >>  This is not what I understood 'perthread' scope to be. I thought that
> it
> >>
> >>> meant that each thread using a service gets its own instance of the
> service
> >>> to use, even though that instance may not be the same as any previous
> >>> instance it used. In other words, nothing to do with user sessions,
> it's
> >>> just for services that are not thread safe and cannot be singletons.
> >>>
> >>> Have I got the wrong end of the stick here?
> >>>
> >>>  -----Original Message-----
> >>>
> >>>> From: Andy Huhn [mailto:amhuhn@hrtc.net]
> >>>> Sent: 29 April 2008 17:34
> >>>> To: Tapestry users
> >>>> Subject: Re: page activation + components
> >>>>
> >>>>
> >>>> Hello,
> >>>>
> >>>> You can define the scope of each service...you can set that
> particular
> >>>> service to be tied to only one session.
> >>>>
> >>>> See http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html,
> >>>> and
> >>>> search for "perthread".
> >>>>
> >>>> Thanks,
> >>>> Andy
> >>>>
> >>>> On Tue, 29 Apr 2008 18:02:52 +0200, "János Jarecsni"
> >>>> <ja...@gmail.com> wrote:
> >>>>
> >>>>
> >>>>> Hi there,
> >>>>>
> >>>>> the service approach (as I expected) is session-agnostic (and is
> >>>>> page-independent so concurrent users would interfere badly),
> >>>>>
> >>>>>
> >>>> therefore is
> >>>>
> >>>>
> >>>>> not ok.
> >>>>>
> >>>>> I will now try the Environment approach... if that is session-aware
> >>>>>
> >>>>>
> >>>> :)
> >>>>
> >>>>
> >>>>> thx again
> >>>>> janos
> >>>>>
> >>>>> 2008/4/29 János Jarecsni <ja...@gmail.com>:
> >>>>>
> >>>>>  Hi Chris,
> >>>>>
> >>>>>> even so you could help :) I want this kind of generic way of
> >>>>>> passing
> >>>>>> around information (component to component communication :)) so
> >>>>>> I'll
> >>>>>>
> >>>>>>
> >>>>> look
> >>>>>
> >>>>>
> >>>>>> for the solutions Kristian and you outlined.
> >>>>>>
> >>>>>> thanks!
> >>>>>>
> >>>>>> cheers,
> >>>>>> janos
> >>>>>>
> >>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> >>>>>>
> >>>>>>  Janos,
> >>>>>>
> >>>>>>> Without code or a description of your actual goal, I'm finding
> >>>>>>>
> >>>>>>>
> >>>>>> your
> >>>>>>
> >>>>> situation too hypothetical to really digest. The one thing I can
> >>>>>
> >>>>>> point
> >>>>>>
> >>>>> out is what you said about wanting a component to set a property
> >>>>>
> >>>>>> in
> >>>>>>
> >>>>> the
> >>>>>
> >>>>>
> >>>>>> page. If you want to do that, then you have to know the class of
> >>>>>>
> >>>>>> the
> >>>>>>
> >>>>> page and so injecting a page would make sense. Of course that
> >>>>>
> >>>>>> means
> >>>>>>
> >>>>> tightly coupling a component to a page, which to me doesn't make
> >>>>>
> >>>>>> sense.
> >>>>>>
> >>>>>> If you simply need a generic way of passing data between pages and
> >>>>>>
> >>>>>>> components, consider using a service that provides an untyped
> >>>>>>> list
> >>>>>>>
> >>>>>>>
> >>>>>> or
> >>>>>>
> >>>>> putting something in the environment as Kristian suggested. I'm
> >>>>>
> >>>>>> sorry
> >>>>>>
> >>>>> I
> >>>>>
> >>>>>
> >>>>>> can't be more helpful but as I said I'm not clear on what you're
> >>>>>>
> >>>>>> really
> >>>>>>
> >>>>>> trying to do.
> >>>>>>
> >>>>>>> good luck
> >>>>>>> chris
> >>>>>>>
> >>>>>>> János Jarecsni wrote:
> >>>>>>>
> >>>>>>>
> >>>>>>>> Hi Chris,
> >>>>>>>>
> >>>>>>>> I thought of pages as "contexts" for the components embedded
> >>>>>>>>
> >>>>>>>>
> >>>>>>> within
> >>>>>>>
> >>>>> them.
> >>>>>
> >>>>>>>> So, in one event handler of a component I would like to set
> >>>>>>>> some
> >>>>>>>>
> >>>>>>>>
> >>>>>>> property or
> >>>>>>>
> >>>>>>>
> >>>>>>>> another (in the page object), and the other components in the
> >>>>>>>>
> >>>>>>>>
> >>>>>>> page,
> >>>>>>>
> >>>>> which
> >>>>>
> >>>>>>>> are also able to access this property may change their
> >>>>>>>>
> >>>>>>>>
> >>>>>>> appearance
> >>>>>>>
> >>>>> (say, the
> >>>>>
> >>>>>>>> .TML would test the property). Maybe I'm on a wrong track,
> >>>>>>>>
> >>>>>>>>
> >>>>>>> please
> >>>>>>>
> >>>>> let
> >>>>>
> >>>>>
> >>>>>> me
> >>>>>>
> >>>>>>>> know :)
> >>>>>>>>
> >>>>>>>> thx
> >>>>>>>> Cheers,
> >>>>>>>> janos
> >>>>>>>>
> >>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>  Janos,
> >>>>>>>>
> >>>>>>>>> I'm having a hard time understanding a case that a component
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>> should
> >>>>>>>>
> >>>>> know
> >>>>>
> >>>>>>>> in which page it is embedded, so my suggestion probably wasn't
> >>>>>>>>
> >>>>>>>> a
> >>>>>>>>
> >>>>> good
> >>>>>
> >>>>>
> >>>>>> one. Activation contexts aren't meant for components but for
> >>>>>>
> >>>>>>>> pages
> >>>>>>>>
> >>>>> -
> >>>>>
> >>>>>
> >>>>>> you
> >>>>>>
> >>>>>>>> should be using component parameters to configure them, and if
> >>>>>>>>
> >>>>>>>> it's
> >>>>>>>>
> >>>>> a
> >>>>>
> >>>>>
> >>>>>> more sophisticated component, probably a service.
> >>>>>>
> >>>>>>>>> chris
> >>>>>>>>>
> >>>>>>>>> János Jarecsni wrote:
> >>>>>>>>>
> >>>>>>>>>  and how a component can get to know the page in which it is
> >>>>>>>>>
> >>>>>>>>> included? I
> >>>>>>>>>
> >>>>>>>> mean, I can't @InjectPage, as the component will be included
> >>>>>>>>
> >>>>>>>>> in
> >>>>>>>>>
> >>>>> many
> >>>>>
> >>>>>
> >>>>>> kinds
> >>>>>>
> >>>>>>>>>  of pages.
> >>>>>>>>>
> >>>>>>>>>> @Kristian: thx for the many ways :) I'll try these, hope
> >>>>>>>>>> that
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>> the
> >>>>>>>>>
> >>>>> @Environmental stuff is scalable (I'm trying to bypass session
> >>>>>
> >>>>>>>>> creation
> >>>>>>>>>
> >>>>>>>> as
> >>>>>>>>
> >>>>>>>>>  much as possible)
> >>>>>>>>>
> >>>>>>>>>> Is there a doc on the various annotations available?
> >>>>>>>>>>
> >>>>>>>>>> @Michael:
> >>>>>>>>>> Could you include a tiny bit of example? THX!
> >>>>>>>>>>
> >>>>>>>>>> Thx to you all
> >>>>>>>>>> cheers
> >>>>>>>>>> janos
> >>>>>>>>>>
> >>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>  5) @InjectPage the page and call the getter
> >>>>>>>>>>
> >>>>>>>>>>> Kristian Marinkovic wrote:
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>  hi janos,
> >>>>>>>>>>>
> >>>>>>>>>>>> there are several possibilities:
> >>>>>>>>>>>>
> >>>>>>>>>>>> 1) declare a component parameter and pass in the
> >>>>>>>>>>>> variable
> >>>>>>>>>>>>
> >>>>>>>>>>>> 2) put it in a ASO and inject the ASO in all your
> >>>>>>>>>>>> components
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>> (using
> >>>>>>>>>>>
> >>>>>>>> @ApplicationState)
> >>>>>>>>
> >>>>>>>>>>>> the drawback is that any other page or component will
> >>>>>>>>>>>> be
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>> able to
> >>>>>>>>>>>
> >>>>> access
> >>>>>
> >>>>>>>>>  the ASO
> >>>>>>>>>
> >>>>>>>>>>>> 3) put it into the Environment and read it whereever
> >>>>>>>>>>>> you
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>> need it
> >>>>>>>>>>>
> >>>>> in
> >>>>>
> >>>>>>>> your
> >>>>>>>>
> >>>>>>>>>  nested components.
> >>>>>>>>>
> >>>>>>>>>>>> be careful when you put your object in your
> >>>>>>>>>>>> environment. if
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>> you
> >>>>>>>>>>>
> >>>>> put it
> >>>>>
> >>>>>>>>>>>>  in
> >>>>>>>>>>>>
> >>>>>>>>>>>  during the action
> >>>>>>>>>>>
> >>>>>>>>>>>> request it will not be able in the render request
> >>>>>>>>>>>> (because
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>> of
> >>>>>>>>>>>
> >>>>> the
> >>>>>
> >>>>>
> >>>>>> page
> >>>>>>
> >>>>>>>> redirect).
> >>>>>>>>
> >>>>>>>>>>>> page:
> >>>>>>>>>>>>
> >>>>>>>>>>>> @Inject Environment env;
> >>>>>>>>>>>>
> >>>>>>>>>>>> @Persist("flash") whateverclass w;
> >>>>>>>>>>>>
> >>>>>>>>>>>> onActivate(w) {  this.w= w }
> >>>>>>>>>>>>
> >>>>>>>>>>>> setupRender() { env.push(whateverclass.class,w);}
> >>>>>>>>>>>>
> >>>>>>>>>>>> components:
> >>>>>>>>>>>>
> >>>>>>>>>>>> @Environmental Whateverclass var;
> >>>>>>>>>>>>
> >>>>>>>>>>>> 4) define a service that can take this variable (and
> >>>>>>>>>>>> saves
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>> it
> >>>>>>>>>>>
> >>>>>>>>>>>>  appropriatly
> >>>>>>>>>>>>
> >>>>>>>>>>>  so it is not
> >>>>>>>>>>>
> >>>>>>>>>>>> lost on a redirect:)) and inject your service in the
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>> components
> >>>>>>>>>>>
> >>>>> where
> >>>>>
> >>>>>>>> needed
> >>>>>>>>
> >>>>>>>>>>>> to retrieve the value.
> >>>>>>>>>>>>
> >>>>>>>>>>>> maybe there are some more possibilities :)
> >>>>>>>>>>>>
> >>>>>>>>>>>> g,
> >>>>>>>>>>>> kris
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>> "János Jarecsni" <ja...@gmail.com>
> >>>>>>>>>>>> 29.04.2008 08:15
> >>>>>>>>>>>> Bitte antworten an
> >>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>> An
> >>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
> >>>>>>>>>>>> Kopie
> >>>>>>>>>>>>
> >>>>>>>>>>>> Thema
> >>>>>>>>>>>> page activation + components
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>> Hi there,
> >>>>>>>>>>>>
> >>>>>>>>>>>> I have an activatable page, in its onActivate(String
> >>>>>>>>>>>> param)
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>> method
> >>>>>>>>>>>
> >>>>>> I
> >>>>>>
> >>>>>>>>>>>>  save
> >>>>>>>>>>>>
> >>>>>>>>>>>  the param to a normal instance variable of the page
> >>>>>>>>>>>
> >>>>>>>>>>>> class
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>> (no
> >>>>>>>>>>>
> >>>>> persistence!).
> >>>>>
> >>>>>>>>>>>> How can any component embedded within this page access
> >>>>>>>>>>>> this
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>> variable?
> >>>>>>>>>>>
> >>>>>>>> the page class:
> >>>>>>>>
> >>>>>>>>>>>> //...
> >>>>>>>>>>>> private String param;
> >>>>>>>>>>>>
> >>>>>>>>>>>> public void onActivate(String param) {
> >>>>>>>>>>>>   this.param = param;
> >>>>>>>>>>>> }
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>> public String getParam() {...}
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>> Thx in advance!
> >>>>>>>>>>>> Janos
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>  --
> >>>>>>>>>>>>
> >>>>>>>>>>> http://thegodcode.net
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> ------------------------------------------------------------------
> >>>>>>>>>>>
> >>>>>> ---
> >>>>>>
> >>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >>>>>
> >>>>>>>>>>> For additional commands, e-mail: users-
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>> help@tapestry.apache.org
> >>>>>>>>>>
> >>>>>>>>>>>  --
> >>>>>>>>>>>
> >>>>>>>>> http://thegodcode.net
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> ---------------------------------------------------------------------
> >>>>>>>>>
> >>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >>>>>>
> >>>>>>>>> For additional commands, e-mail:
> >>>>>>>>> users-help@tapestry.apache.org
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>  --
> >>>>>>>>>
> >>>>>>> http://thegodcode.net
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>> ------------------------------------------------------------------
> >>>>>>>
> >>>>>>>
> >>>>>> ---
> >>>>>>
> >>>>> 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
> >>>>
> >>>>
> >>>
> >> ---------------------------------------------------------------------
> >>
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
> >>
>
> --
> http://thegodcode.net
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: page activation + components

Posted by Chris Lewis <ch...@bellsouth.net>.
Honestly it's difficult for me to imagine a situation where I'd do that
because it seems to violate a degree of encapsulation that tapestry
imposes as a "freeing law" of the framework. The epicenter of that being
that one should not think in terms of low-level idioms such as request
parameters, and instead replace those with a higher level of application
logic that eclipses them entirely (when possible). That's not to say
that your perspective is flawed, but from the small bit of understanding
I've taken from your posts I can't see why one would do what you want.
The thing that I've been saying is missing here is, what are you trying
to do? I don't mean technically, I mean what is the end result for the
user? Understanding this is critical, but even if I don't your problem
can still be solved by using a session to serve as an arbitrary holder.
If you've settled on this architecture, why not write such a generic
service and move on?

János Jarecsni wrote:
> Hi,
>
> I looked everywhere for usage of request scope variables, but found nothing
> (maybe I'm impatient a bit :)...
> Is it really that unrealistic to have two components in a page, one (A)
> having an action link eventhandler where it would set some attribute for the
> request only (not the session!) and then component B could render itself
> according to the attribute set by component A?
>
> I think it should be a piece of cake :)
>
> thx
> Janos
>
> 2008/4/30 Filip S. Adamsen <fs...@fsadev.com>:
>
>   
>> Nope, you're exactly right.
>>
>> -Filip
>>
>> Blower, Andy skrev:
>>
>>  This is not what I understood 'perthread' scope to be. I thought that it
>>     
>>> meant that each thread using a service gets its own instance of the service
>>> to use, even though that instance may not be the same as any previous
>>> instance it used. In other words, nothing to do with user sessions, it's
>>> just for services that are not thread safe and cannot be singletons.
>>>
>>> Have I got the wrong end of the stick here?
>>>
>>>  -----Original Message-----
>>>       
>>>> From: Andy Huhn [mailto:amhuhn@hrtc.net]
>>>> Sent: 29 April 2008 17:34
>>>> To: Tapestry users
>>>> Subject: Re: page activation + components
>>>>
>>>>
>>>> Hello,
>>>>
>>>> You can define the scope of each service...you can set that particular
>>>> service to be tied to only one session.
>>>>
>>>> See http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html,
>>>> and
>>>> search for "perthread".
>>>>
>>>> Thanks,
>>>> Andy
>>>>
>>>> On Tue, 29 Apr 2008 18:02:52 +0200, "János Jarecsni"
>>>> <ja...@gmail.com> wrote:
>>>>
>>>>         
>>>>> Hi there,
>>>>>
>>>>> the service approach (as I expected) is session-agnostic (and is
>>>>> page-independent so concurrent users would interfere badly),
>>>>>
>>>>>           
>>>> therefore is
>>>>
>>>>         
>>>>> not ok.
>>>>>
>>>>> I will now try the Environment approach... if that is session-aware
>>>>>
>>>>>           
>>>> :)
>>>>
>>>>         
>>>>> thx again
>>>>> janos
>>>>>
>>>>> 2008/4/29 János Jarecsni <ja...@gmail.com>:
>>>>>
>>>>>  Hi Chris,
>>>>>           
>>>>>> even so you could help :) I want this kind of generic way of
>>>>>> passing
>>>>>> around information (component to component communication :)) so
>>>>>> I'll
>>>>>>
>>>>>>             
>>>>> look
>>>>>
>>>>>           
>>>>>> for the solutions Kristian and you outlined.
>>>>>>
>>>>>> thanks!
>>>>>>
>>>>>> cheers,
>>>>>> janos
>>>>>>
>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>>>>>>
>>>>>>  Janos,
>>>>>>             
>>>>>>> Without code or a description of your actual goal, I'm finding
>>>>>>>
>>>>>>>               
>>>>>> your
>>>>>>             
>>>>> situation too hypothetical to really digest. The one thing I can
>>>>>           
>>>>>> point
>>>>>>             
>>>>> out is what you said about wanting a component to set a property
>>>>>           
>>>>>> in
>>>>>>             
>>>>> the
>>>>>
>>>>>           
>>>>>> page. If you want to do that, then you have to know the class of
>>>>>>             
>>>>>> the
>>>>>>             
>>>>> page and so injecting a page would make sense. Of course that
>>>>>           
>>>>>> means
>>>>>>             
>>>>> tightly coupling a component to a page, which to me doesn't make
>>>>>           
>>>>>> sense.
>>>>>>             
>>>>>> If you simply need a generic way of passing data between pages and
>>>>>>             
>>>>>>> components, consider using a service that provides an untyped
>>>>>>> list
>>>>>>>
>>>>>>>               
>>>>>> or
>>>>>>             
>>>>> putting something in the environment as Kristian suggested. I'm
>>>>>           
>>>>>> sorry
>>>>>>             
>>>>> I
>>>>>
>>>>>           
>>>>>> can't be more helpful but as I said I'm not clear on what you're
>>>>>>             
>>>>>> really
>>>>>>             
>>>>>> trying to do.
>>>>>>             
>>>>>>> good luck
>>>>>>> chris
>>>>>>>
>>>>>>> János Jarecsni wrote:
>>>>>>>
>>>>>>>               
>>>>>>>> Hi Chris,
>>>>>>>>
>>>>>>>> I thought of pages as "contexts" for the components embedded
>>>>>>>>
>>>>>>>>                 
>>>>>>> within
>>>>>>>               
>>>>> them.
>>>>>           
>>>>>>>> So, in one event handler of a component I would like to set
>>>>>>>> some
>>>>>>>>
>>>>>>>>                 
>>>>>>> property or
>>>>>>>
>>>>>>>               
>>>>>>>> another (in the page object), and the other components in the
>>>>>>>>
>>>>>>>>                 
>>>>>>> page,
>>>>>>>               
>>>>> which
>>>>>           
>>>>>>>> are also able to access this property may change their
>>>>>>>>
>>>>>>>>                 
>>>>>>> appearance
>>>>>>>               
>>>>> (say, the
>>>>>           
>>>>>>>> .TML would test the property). Maybe I'm on a wrong track,
>>>>>>>>
>>>>>>>>                 
>>>>>>> please
>>>>>>>               
>>>>> let
>>>>>
>>>>>           
>>>>>> me
>>>>>>             
>>>>>>>> know :)
>>>>>>>>
>>>>>>>> thx
>>>>>>>> Cheers,
>>>>>>>> janos
>>>>>>>>
>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>>>>>>>>
>>>>>>>>
>>>>>>>>  Janos,
>>>>>>>>                 
>>>>>>>>> I'm having a hard time understanding a case that a component
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> should
>>>>>>>>                 
>>>>> know
>>>>>           
>>>>>>>> in which page it is embedded, so my suggestion probably wasn't
>>>>>>>>                 
>>>>>>>> a
>>>>>>>>                 
>>>>> good
>>>>>
>>>>>           
>>>>>> one. Activation contexts aren't meant for components but for
>>>>>>             
>>>>>>>> pages
>>>>>>>>                 
>>>>> -
>>>>>
>>>>>           
>>>>>> you
>>>>>>             
>>>>>>>> should be using component parameters to configure them, and if
>>>>>>>>                 
>>>>>>>> it's
>>>>>>>>                 
>>>>> a
>>>>>
>>>>>           
>>>>>> more sophisticated component, probably a service.
>>>>>>             
>>>>>>>>> chris
>>>>>>>>>
>>>>>>>>> János Jarecsni wrote:
>>>>>>>>>
>>>>>>>>>  and how a component can get to know the page in which it is
>>>>>>>>>                   
>>>>>>>>> included? I
>>>>>>>>>                   
>>>>>>>> mean, I can't @InjectPage, as the component will be included
>>>>>>>>                 
>>>>>>>>> in
>>>>>>>>>                   
>>>>> many
>>>>>
>>>>>           
>>>>>> kinds
>>>>>>             
>>>>>>>>>  of pages.
>>>>>>>>>                   
>>>>>>>>>> @Kristian: thx for the many ways :) I'll try these, hope
>>>>>>>>>> that
>>>>>>>>>>
>>>>>>>>>>                     
>>>>>>>>> the
>>>>>>>>>                   
>>>>> @Environmental stuff is scalable (I'm trying to bypass session
>>>>>           
>>>>>>>>> creation
>>>>>>>>>                   
>>>>>>>> as
>>>>>>>>                 
>>>>>>>>>  much as possible)
>>>>>>>>>                   
>>>>>>>>>> Is there a doc on the various annotations available?
>>>>>>>>>>
>>>>>>>>>> @Michael:
>>>>>>>>>> Could you include a tiny bit of example? THX!
>>>>>>>>>>
>>>>>>>>>> Thx to you all
>>>>>>>>>> cheers
>>>>>>>>>> janos
>>>>>>>>>>
>>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>  5) @InjectPage the page and call the getter
>>>>>>>>>>                     
>>>>>>>>>>> Kristian Marinkovic wrote:
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>  hi janos,
>>>>>>>>>>>                       
>>>>>>>>>>>> there are several possibilities:
>>>>>>>>>>>>
>>>>>>>>>>>> 1) declare a component parameter and pass in the
>>>>>>>>>>>> variable
>>>>>>>>>>>>
>>>>>>>>>>>> 2) put it in a ASO and inject the ASO in all your
>>>>>>>>>>>> components
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> (using
>>>>>>>>>>>                       
>>>>>>>> @ApplicationState)
>>>>>>>>                 
>>>>>>>>>>>> the drawback is that any other page or component will
>>>>>>>>>>>> be
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> able to
>>>>>>>>>>>                       
>>>>> access
>>>>>           
>>>>>>>>>  the ASO
>>>>>>>>>                   
>>>>>>>>>>>> 3) put it into the Environment and read it whereever
>>>>>>>>>>>> you
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> need it
>>>>>>>>>>>                       
>>>>> in
>>>>>           
>>>>>>>> your
>>>>>>>>                 
>>>>>>>>>  nested components.
>>>>>>>>>                   
>>>>>>>>>>>> be careful when you put your object in your
>>>>>>>>>>>> environment. if
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> you
>>>>>>>>>>>                       
>>>>> put it
>>>>>           
>>>>>>>>>>>>  in
>>>>>>>>>>>>                         
>>>>>>>>>>>  during the action
>>>>>>>>>>>                       
>>>>>>>>>>>> request it will not be able in the render request
>>>>>>>>>>>> (because
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> of
>>>>>>>>>>>                       
>>>>> the
>>>>>
>>>>>           
>>>>>> page
>>>>>>             
>>>>>>>> redirect).
>>>>>>>>                 
>>>>>>>>>>>> page:
>>>>>>>>>>>>
>>>>>>>>>>>> @Inject Environment env;
>>>>>>>>>>>>
>>>>>>>>>>>> @Persist("flash") whateverclass w;
>>>>>>>>>>>>
>>>>>>>>>>>> onActivate(w) {  this.w= w }
>>>>>>>>>>>>
>>>>>>>>>>>> setupRender() { env.push(whateverclass.class,w);}
>>>>>>>>>>>>
>>>>>>>>>>>> components:
>>>>>>>>>>>>
>>>>>>>>>>>> @Environmental Whateverclass var;
>>>>>>>>>>>>
>>>>>>>>>>>> 4) define a service that can take this variable (and
>>>>>>>>>>>> saves
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> it
>>>>>>>>>>>                       
>>>>>>>>>>>>  appropriatly
>>>>>>>>>>>>                         
>>>>>>>>>>>  so it is not
>>>>>>>>>>>                       
>>>>>>>>>>>> lost on a redirect:)) and inject your service in the
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> components
>>>>>>>>>>>                       
>>>>> where
>>>>>           
>>>>>>>> needed
>>>>>>>>                 
>>>>>>>>>>>> to retrieve the value.
>>>>>>>>>>>>
>>>>>>>>>>>> maybe there are some more possibilities :)
>>>>>>>>>>>>
>>>>>>>>>>>> g,
>>>>>>>>>>>> kris
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> "János Jarecsni" <ja...@gmail.com>
>>>>>>>>>>>> 29.04.2008 08:15
>>>>>>>>>>>> Bitte antworten an
>>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> An
>>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
>>>>>>>>>>>> Kopie
>>>>>>>>>>>>
>>>>>>>>>>>> Thema
>>>>>>>>>>>> page activation + components
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Hi there,
>>>>>>>>>>>>
>>>>>>>>>>>> I have an activatable page, in its onActivate(String
>>>>>>>>>>>> param)
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> method
>>>>>>>>>>>                       
>>>>>> I
>>>>>>             
>>>>>>>>>>>>  save
>>>>>>>>>>>>                         
>>>>>>>>>>>  the param to a normal instance variable of the page
>>>>>>>>>>>                       
>>>>>>>>>>>> class
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> (no
>>>>>>>>>>>                       
>>>>> persistence!).
>>>>>           
>>>>>>>>>>>> How can any component embedded within this page access
>>>>>>>>>>>> this
>>>>>>>>>>>>
>>>>>>>>>>>>                         
>>>>>>>>>>> variable?
>>>>>>>>>>>                       
>>>>>>>> the page class:
>>>>>>>>                 
>>>>>>>>>>>> //...
>>>>>>>>>>>> private String param;
>>>>>>>>>>>>
>>>>>>>>>>>> public void onActivate(String param) {
>>>>>>>>>>>>   this.param = param;
>>>>>>>>>>>> }
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> public String getParam() {...}
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Thx in advance!
>>>>>>>>>>>> Janos
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>  --
>>>>>>>>>>>>                         
>>>>>>>>>>> http://thegodcode.net
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> ------------------------------------------------------------------
>>>>>>>>>>>                       
>>>>>> ---
>>>>>>             
>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>           
>>>>>>>>>>> For additional commands, e-mail: users-
>>>>>>>>>>>
>>>>>>>>>>>                       
>>>>>>>>>> help@tapestry.apache.org
>>>>>>>>>>                     
>>>>>>>>>>>  --
>>>>>>>>>>>                       
>>>>>>>>> http://thegodcode.net
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>                   
>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>             
>>>>>>>>> For additional commands, e-mail:
>>>>>>>>> users-help@tapestry.apache.org
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>  --
>>>>>>>>>                   
>>>>>>> http://thegodcode.net
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> ------------------------------------------------------------------
>>>>>>>
>>>>>>>               
>>>>>> ---
>>>>>>             
>>>>> 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
>>>>
>>>>         
>>>       
>> ---------------------------------------------------------------------
>>
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>     

-- 
http://thegodcode.net


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


Re: page activation + components

Posted by János Jarecsni <ja...@gmail.com>.
Hi
and thx for the info! why would you discourage from doing so? (I will read
the page you sent now).
cheers
janos

2008/4/30 Filip S. Adamsen <fs...@fsadev.com>:

> That's pretty hard to do without some kind of persistence because of the
> redirect that happens between the component action and the page render.
>
> There's of course tapestry.suppress-redirect-from-action-requests, but I
> would strongly recommend AGAINST using that.
>
> http://tapestry.apache.org/tapestry5/tapestry-core/guide/conf.html
>
> -Filip
>
> János Jarecsni skrev:
>
>  Hi,
> >
> > I looked everywhere for usage of request scope variables, but found
> > nothing
> > (maybe I'm impatient a bit :)...
> > Is it really that unrealistic to have two components in a page, one (A)
> > having an action link eventhandler where it would set some attribute for
> > the
> > request only (not the session!) and then component B could render itself
> > according to the attribute set by component A?
> >
> > I think it should be a piece of cake :)
> >
> > thx
> > Janos
> >
> > 2008/4/30 Filip S. Adamsen <fs...@fsadev.com>:
> >
> >  Nope, you're exactly right.
> > >
> > > -Filip
> > >
> > > Blower, Andy skrev:
> > >
> > >  This is not what I understood 'perthread' scope to be. I thought that
> > > it
> > >
> > > > meant that each thread using a service gets its own instance of the
> > > > service
> > > > to use, even though that instance may not be the same as any
> > > > previous
> > > > instance it used. In other words, nothing to do with user sessions,
> > > > it's
> > > > just for services that are not thread safe and cannot be singletons.
> > > >
> > > > Have I got the wrong end of the stick here?
> > > >
> > > >  -----Original Message-----
> > > >
> > > > > From: Andy Huhn [mailto:amhuhn@hrtc.net]
> > > > > Sent: 29 April 2008 17:34
> > > > > To: Tapestry users
> > > > > Subject: Re: page activation + components
> > > > >
> > > > >
> > > > > Hello,
> > > > >
> > > > > You can define the scope of each service...you can set that
> > > > > particular
> > > > > service to be tied to only one session.
> > > > >
> > > > > See http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html
> > > > > ,
> > > > > and
> > > > > search for "perthread".
> > > > >
> > > > > Thanks,
> > > > > Andy
> > > > >
> > > > > On Tue, 29 Apr 2008 18:02:52 +0200, "János Jarecsni"
> > > > > <ja...@gmail.com> wrote:
> > > > >
> > > > >  Hi there,
> > > > > >
> > > > > > the service approach (as I expected) is session-agnostic (and is
> > > > > > page-independent so concurrent users would interfere badly),
> > > > > >
> > > > > >  therefore is
> > > > >
> > > > >  not ok.
> > > > > >
> > > > > > I will now try the Environment approach... if that is
> > > > > > session-aware
> > > > > >
> > > > > >  :)
> > > > >
> > > > >  thx again
> > > > > > janos
> > > > > >
> > > > > > 2008/4/29 János Jarecsni <ja...@gmail.com>:
> > > > > >
> > > > > >  Hi Chris,
> > > > > >
> > > > > > > even so you could help :) I want this kind of generic way of
> > > > > > > passing
> > > > > > > around information (component to component communication :))
> > > > > > > so
> > > > > > > I'll
> > > > > > >
> > > > > > >  look
> > > > > >
> > > > > >  for the solutions Kristian and you outlined.
> > > > > > >
> > > > > > > thanks!
> > > > > > >
> > > > > > > cheers,
> > > > > > > janos
> > > > > > >
> > > > > > > 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > > > > >
> > > > > > >  Janos,
> > > > > > >
> > > > > > > > Without code or a description of your actual goal, I'm
> > > > > > > > finding
> > > > > > > >
> > > > > > > >  your
> > > > > > >
> > > > > > situation too hypothetical to really digest. The one thing I can
> > > > > >
> > > > > > > point
> > > > > > >
> > > > > > out is what you said about wanting a component to set a property
> > > > > >
> > > > > > > in
> > > > > > >
> > > > > > the
> > > > > >
> > > > > >  page. If you want to do that, then you have to know the class
> > > > > > > of
> > > > > > > the
> > > > > > >
> > > > > > page and so injecting a page would make sense. Of course that
> > > > > >
> > > > > > > means
> > > > > > >
> > > > > > tightly coupling a component to a page, which to me doesn't make
> > > > > >
> > > > > > > sense.
> > > > > > > If you simply need a generic way of passing data between pages
> > > > > > > and
> > > > > > >
> > > > > > > > components, consider using a service that provides an
> > > > > > > > untyped
> > > > > > > > list
> > > > > > > >
> > > > > > > >  or
> > > > > > >
> > > > > > putting something in the environment as Kristian suggested. I'm
> > > > > >
> > > > > > > sorry
> > > > > > >
> > > > > > I
> > > > > >
> > > > > >  can't be more helpful but as I said I'm not clear on what
> > > > > > > you're
> > > > > > > really
> > > > > > > trying to do.
> > > > > > >
> > > > > > > > good luck
> > > > > > > > chris
> > > > > > > >
> > > > > > > > János Jarecsni wrote:
> > > > > > > >
> > > > > > > >  Hi Chris,
> > > > > > > > >
> > > > > > > > > I thought of pages as "contexts" for the components
> > > > > > > > > embedded
> > > > > > > > >
> > > > > > > > >  within
> > > > > > > >
> > > > > > > them.
> > > > > >
> > > > > > > So, in one event handler of a component I would like to set
> > > > > > > > > some
> > > > > > > > >
> > > > > > > > >  property or
> > > > > > > >
> > > > > > > >  another (in the page object), and the other components in
> > > > > > > > > the
> > > > > > > > >
> > > > > > > > >  page,
> > > > > > > >
> > > > > > > which
> > > > > >
> > > > > > > are also able to access this property may change their
> > > > > > > > >
> > > > > > > > >  appearance
> > > > > > > >
> > > > > > > (say, the
> > > > > >
> > > > > > > .TML would test the property). Maybe I'm on a wrong track,
> > > > > > > > >
> > > > > > > > >  please
> > > > > > > >
> > > > > > > let
> > > > > >
> > > > > >  me
> > > > > > >
> > > > > > > > know :)
> > > > > > > > >
> > > > > > > > > thx
> > > > > > > > > Cheers,
> > > > > > > > > janos
> > > > > > > > >
> > > > > > > > > 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >  Janos,
> > > > > > > > >
> > > > > > > > > > I'm having a hard time understanding a case that a
> > > > > > > > > > component
> > > > > > > > > >
> > > > > > > > > >  should
> > > > > > > > >
> > > > > > > > know
> > > > > >
> > > > > > > in which page it is embedded, so my suggestion probably wasn't
> > > > > > > > > a
> > > > > > > > >
> > > > > > > > good
> > > > > >
> > > > > >  one. Activation contexts aren't meant for components but for
> > > > > > >
> > > > > > > > pages
> > > > > > > > >
> > > > > > > > -
> > > > > >
> > > > > >  you
> > > > > > >
> > > > > > > > should be using component parameters to configure them, and
> > > > > > > > > if
> > > > > > > > > it's
> > > > > > > > >
> > > > > > > > a
> > > > > >
> > > > > >  more sophisticated component, probably a service.
> > > > > > >
> > > > > > > > chris
> > > > > > > > > >
> > > > > > > > > > János Jarecsni wrote:
> > > > > > > > > >
> > > > > > > > > >  and how a component can get to know the page in which
> > > > > > > > > > it is
> > > > > > > > > > included? I
> > > > > > > > > >
> > > > > > > > > mean, I can't @InjectPage, as the component will be
> > > > > > > > > included
> > > > > > > > >
> > > > > > > > > > in
> > > > > > > > > >
> > > > > > > > > many
> > > > > >
> > > > > >  kinds
> > > > > > >
> > > > > > > >  of pages.
> > > > > > > > > >
> > > > > > > > > > > @Kristian: thx for the many ways :) I'll try these,
> > > > > > > > > > > hope
> > > > > > > > > > > that
> > > > > > > > > > >
> > > > > > > > > > >  the
> > > > > > > > > >
> > > > > > > > > @Environmental stuff is scalable (I'm trying to bypass
> > > > > > session
> > > > > >
> > > > > > > creation
> > > > > > > > > >
> > > > > > > > > as
> > > > > > > > >
> > > > > > > > > >  much as possible)
> > > > > > > > > >
> > > > > > > > > > > Is there a doc on the various annotations available?
> > > > > > > > > > >
> > > > > > > > > > > @Michael:
> > > > > > > > > > > Could you include a tiny bit of example? THX!
> > > > > > > > > > >
> > > > > > > > > > > Thx to you all
> > > > > > > > > > > cheers
> > > > > > > > > > > janos
> > > > > > > > > > >
> > > > > > > > > > > 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >  5) @InjectPage the page and call the getter
> > > > > > > > > > >
> > > > > > > > > > > > Kristian Marinkovic wrote:
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >  hi janos,
> > > > > > > > > > > >
> > > > > > > > > > > > > there are several possibilities:
> > > > > > > > > > > > >
> > > > > > > > > > > > > 1) declare a component parameter and pass in the
> > > > > > > > > > > > > variable
> > > > > > > > > > > > >
> > > > > > > > > > > > > 2) put it in a ASO and inject the ASO in all your
> > > > > > > > > > > > > components
> > > > > > > > > > > > >
> > > > > > > > > > > > >  (using
> > > > > > > > > > > >
> > > > > > > > > > > @ApplicationState)
> > > > > > > > >
> > > > > > > > > > the drawback is that any other page or component will
> > > > > > > > > > > > > be
> > > > > > > > > > > > >
> > > > > > > > > > > > >  able to
> > > > > > > > > > > >
> > > > > > > > > > > access
> > > > > >
> > > > > > >  the ASO
> > > > > > > > > >
> > > > > > > > > > > 3) put it into the Environment and read it whereever
> > > > > > > > > > > > > you
> > > > > > > > > > > > >
> > > > > > > > > > > > >  need it
> > > > > > > > > > > >
> > > > > > > > > > > in
> > > > > >
> > > > > > > your
> > > > > > > > >
> > > > > > > > > >  nested components.
> > > > > > > > > >
> > > > > > > > > > > be careful when you put your object in your
> > > > > > > > > > > > > environment. if
> > > > > > > > > > > > >
> > > > > > > > > > > > >  you
> > > > > > > > > > > >
> > > > > > > > > > > put it
> > > > > >
> > > > > > >  in
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >  during the action
> > > > > > > > > > > >
> > > > > > > > > > > > > request it will not be able in the render request
> > > > > > > > > > > > > (because
> > > > > > > > > > > > >
> > > > > > > > > > > > >  of
> > > > > > > > > > > >
> > > > > > > > > > > the
> > > > > >
> > > > > >  page
> > > > > > >
> > > > > > > > redirect).
> > > > > > > > >
> > > > > > > > > > page:
> > > > > > > > > > > > >
> > > > > > > > > > > > > @Inject Environment env;
> > > > > > > > > > > > >
> > > > > > > > > > > > > @Persist("flash") whateverclass w;
> > > > > > > > > > > > >
> > > > > > > > > > > > > onActivate(w) {  this.w= w }
> > > > > > > > > > > > >
> > > > > > > > > > > > > setupRender() { env.push(whateverclass.class,w);}
> > > > > > > > > > > > >
> > > > > > > > > > > > > components:
> > > > > > > > > > > > >
> > > > > > > > > > > > > @Environmental Whateverclass var;
> > > > > > > > > > > > >
> > > > > > > > > > > > > 4) define a service that can take this variable
> > > > > > > > > > > > > (and
> > > > > > > > > > > > > saves
> > > > > > > > > > > > >
> > > > > > > > > > > > >  it
> > > > > > > > > > > >
> > > > > > > > > > > > >  appropriatly
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >  so it is not
> > > > > > > > > > > >
> > > > > > > > > > > > > lost on a redirect:)) and inject your service in
> > > > > > > > > > > > > the
> > > > > > > > > > > > >
> > > > > > > > > > > > >  components
> > > > > > > > > > > >
> > > > > > > > > > > where
> > > > > >
> > > > > > > needed
> > > > > > > > >
> > > > > > > > > > to retrieve the value.
> > > > > > > > > > > > >
> > > > > > > > > > > > > maybe there are some more possibilities :)
> > > > > > > > > > > > >
> > > > > > > > > > > > > g,
> > > > > > > > > > > > > kris
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > "János Jarecsni" <ja...@gmail.com>
> > > > > > > > > > > > > 29.04.2008 08:15
> > > > > > > > > > > > > Bitte antworten an
> > > > > > > > > > > > > "Tapestry users" <us...@tapestry.apache.org>
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > An
> > > > > > > > > > > > > "Tapestry users" <us...@tapestry.apache.org>
> > > > > > > > > > > > > Kopie
> > > > > > > > > > > > >
> > > > > > > > > > > > > Thema
> > > > > > > > > > > > > page activation + components
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > Hi there,
> > > > > > > > > > > > >
> > > > > > > > > > > > > I have an activatable page, in its
> > > > > > > > > > > > > onActivate(String
> > > > > > > > > > > > > param)
> > > > > > > > > > > > >
> > > > > > > > > > > > >  method
> > > > > > > > > > > >
> > > > > > > > > > > I
> > > > > > >
> > > > > > > >  save
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >  the param to a normal instance variable of the page
> > > > > > > > > > > >
> > > > > > > > > > > > > class
> > > > > > > > > > > > >
> > > > > > > > > > > > >  (no
> > > > > > > > > > > >
> > > > > > > > > > > persistence!).
> > > > > >
> > > > > > > How can any component embedded within this page access
> > > > > > > > > > > > > this
> > > > > > > > > > > > >
> > > > > > > > > > > > >  variable?
> > > > > > > > > > > >
> > > > > > > > > > > the page class:
> > > > > > > > >
> > > > > > > > > > //...
> > > > > > > > > > > > > private String param;
> > > > > > > > > > > > >
> > > > > > > > > > > > > public void onActivate(String param) {
> > > > > > > > > > > > >  this.param = param;
> > > > > > > > > > > > > }
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > public String getParam() {...}
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > Thx in advance!
> > > > > > > > > > > > > Janos
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >  --
> > > > > > > > > > > > >
> > > > > > > > > > > > http://thegodcode.net
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > ------------------------------------------------------------------
> > > > > > > > > > > >
> > > > > > > > > > > ---
> > > > > > >
> > > > > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > > >
> > > > > > > For additional commands, e-mail: users-
> > > > > > > > > > > >
> > > > > > > > > > > >  help@tapestry.apache.org
> > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >  --
> > > > > > > > > > > >
> > > > > > > > > > > http://thegodcode.net
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > ---------------------------------------------------------------------
> > > > > > > > > >
> > > > > > > > > To unsubscribe, e-mail:
> > > > > > > users-unsubscribe@tapestry.apache.org
> > > > > > >
> > > > > > > > For additional commands, e-mail:
> > > > > > > > > > users-help@tapestry.apache.org
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >  --
> > > > > > > > > >
> > > > > > > > > http://thegodcode.net
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > ------------------------------------------------------------------
> > > > > > > >
> > > > > > > >  ---
> > > > > > >
> > > > > > 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
> > > > >
> > > > >
> > > > ---------------------------------------------------------------------
> > >
> > > 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: page activation + components

Posted by "Filip S. Adamsen" <fs...@fsadev.com>.
Nope, that's an often used pattern in web applications, that is, it's a 
broader version of the Post/Redirect/Get pattern. It's normally only 
used for forms, but since you can do stuff in components actions that 
corresponds to what you would do on a form submit, it makes perfect 
sense. And it makes it a lot easier for Tapestry to handle, as far as I 
know.

http://en.wikipedia.org/wiki/Post/Redirect/Get

-Filip

János Jarecsni skrev:
> This did the trick! Superb, it works just like I want it :)
> Actually, having 2 network roundtrips for a single requests sounds a little
> bad doesn't it?
> 
> cheers
> janos
> 
> 2008/4/30 Filip S. Adamsen <fs...@fsadev.com>:
> 
>> That's pretty hard to do without some kind of persistence because of the
>> redirect that happens between the component action and the page render.
>>
>> There's of course tapestry.suppress-redirect-from-action-requests, but I
>> would strongly recommend AGAINST using that.
>>
>> http://tapestry.apache.org/tapestry5/tapestry-core/guide/conf.html
>>
>> -Filip
>>
>> János Jarecsni skrev:
>>
>>  Hi,
>>> I looked everywhere for usage of request scope variables, but found
>>> nothing
>>> (maybe I'm impatient a bit :)...
>>> Is it really that unrealistic to have two components in a page, one (A)
>>> having an action link eventhandler where it would set some attribute for
>>> the
>>> request only (not the session!) and then component B could render itself
>>> according to the attribute set by component A?
>>>
>>> I think it should be a piece of cake :)
>>>
>>> thx
>>> Janos
>>>
>>> 2008/4/30 Filip S. Adamsen <fs...@fsadev.com>:
>>>
>>>  Nope, you're exactly right.
>>>> -Filip
>>>>
>>>> Blower, Andy skrev:
>>>>
>>>>  This is not what I understood 'perthread' scope to be. I thought that
>>>> it
>>>>
>>>>> meant that each thread using a service gets its own instance of the
>>>>> service
>>>>> to use, even though that instance may not be the same as any
>>>>> previous
>>>>> instance it used. In other words, nothing to do with user sessions,
>>>>> it's
>>>>> just for services that are not thread safe and cannot be singletons.
>>>>>
>>>>> Have I got the wrong end of the stick here?
>>>>>
>>>>>  -----Original Message-----
>>>>>
>>>>>> From: Andy Huhn [mailto:amhuhn@hrtc.net]
>>>>>> Sent: 29 April 2008 17:34
>>>>>> To: Tapestry users
>>>>>> Subject: Re: page activation + components
>>>>>>
>>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> You can define the scope of each service...you can set that
>>>>>> particular
>>>>>> service to be tied to only one session.
>>>>>>
>>>>>> See http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html
>>>>>> ,
>>>>>> and
>>>>>> search for "perthread".
>>>>>>
>>>>>> Thanks,
>>>>>> Andy
>>>>>>
>>>>>> On Tue, 29 Apr 2008 18:02:52 +0200, "János Jarecsni"
>>>>>> <ja...@gmail.com> wrote:
>>>>>>
>>>>>>  Hi there,
>>>>>>> the service approach (as I expected) is session-agnostic (and is
>>>>>>> page-independent so concurrent users would interfere badly),
>>>>>>>
>>>>>>>  therefore is
>>>>>>  not ok.
>>>>>>> I will now try the Environment approach... if that is
>>>>>>> session-aware
>>>>>>>
>>>>>>>  :)
>>>>>>  thx again
>>>>>>> janos
>>>>>>>
>>>>>>> 2008/4/29 János Jarecsni <ja...@gmail.com>:
>>>>>>>
>>>>>>>  Hi Chris,
>>>>>>>
>>>>>>>> even so you could help :) I want this kind of generic way of
>>>>>>>> passing
>>>>>>>> around information (component to component communication :))
>>>>>>>> so
>>>>>>>> I'll
>>>>>>>>
>>>>>>>>  look
>>>>>>>  for the solutions Kristian and you outlined.
>>>>>>>> thanks!
>>>>>>>>
>>>>>>>> cheers,
>>>>>>>> janos
>>>>>>>>
>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>>>>>>>>
>>>>>>>>  Janos,
>>>>>>>>
>>>>>>>>> Without code or a description of your actual goal, I'm
>>>>>>>>> finding
>>>>>>>>>
>>>>>>>>>  your
>>>>>>> situation too hypothetical to really digest. The one thing I can
>>>>>>>
>>>>>>>> point
>>>>>>>>
>>>>>>> out is what you said about wanting a component to set a property
>>>>>>>
>>>>>>>> in
>>>>>>>>
>>>>>>> the
>>>>>>>
>>>>>>>  page. If you want to do that, then you have to know the class
>>>>>>>> of
>>>>>>>> the
>>>>>>>>
>>>>>>> page and so injecting a page would make sense. Of course that
>>>>>>>
>>>>>>>> means
>>>>>>>>
>>>>>>> tightly coupling a component to a page, which to me doesn't make
>>>>>>>
>>>>>>>> sense.
>>>>>>>> If you simply need a generic way of passing data between pages
>>>>>>>> and
>>>>>>>>
>>>>>>>>> components, consider using a service that provides an
>>>>>>>>> untyped
>>>>>>>>> list
>>>>>>>>>
>>>>>>>>>  or
>>>>>>> putting something in the environment as Kristian suggested. I'm
>>>>>>>
>>>>>>>> sorry
>>>>>>>>
>>>>>>> I
>>>>>>>
>>>>>>>  can't be more helpful but as I said I'm not clear on what
>>>>>>>> you're
>>>>>>>> really
>>>>>>>> trying to do.
>>>>>>>>
>>>>>>>>> good luck
>>>>>>>>> chris
>>>>>>>>>
>>>>>>>>> János Jarecsni wrote:
>>>>>>>>>
>>>>>>>>>  Hi Chris,
>>>>>>>>>> I thought of pages as "contexts" for the components
>>>>>>>>>> embedded
>>>>>>>>>>
>>>>>>>>>>  within
>>>>>>>> them.
>>>>>>>> So, in one event handler of a component I would like to set
>>>>>>>>>> some
>>>>>>>>>>
>>>>>>>>>>  property or
>>>>>>>>>  another (in the page object), and the other components in
>>>>>>>>>> the
>>>>>>>>>>
>>>>>>>>>>  page,
>>>>>>>> which
>>>>>>>> are also able to access this property may change their
>>>>>>>>>>  appearance
>>>>>>>> (say, the
>>>>>>>> .TML would test the property). Maybe I'm on a wrong track,
>>>>>>>>>>  please
>>>>>>>> let
>>>>>>>  me
>>>>>>>>> know :)
>>>>>>>>>> thx
>>>>>>>>>> Cheers,
>>>>>>>>>> janos
>>>>>>>>>>
>>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>  Janos,
>>>>>>>>>>
>>>>>>>>>>> I'm having a hard time understanding a case that a
>>>>>>>>>>> component
>>>>>>>>>>>
>>>>>>>>>>>  should
>>>>>>>>> know
>>>>>>>> in which page it is embedded, so my suggestion probably wasn't
>>>>>>>>>> a
>>>>>>>>>>
>>>>>>>>> good
>>>>>>>  one. Activation contexts aren't meant for components but for
>>>>>>>>> pages
>>>>>>>>> -
>>>>>>>  you
>>>>>>>>> should be using component parameters to configure them, and
>>>>>>>>>> if
>>>>>>>>>> it's
>>>>>>>>>>
>>>>>>>>> a
>>>>>>>  more sophisticated component, probably a service.
>>>>>>>>> chris
>>>>>>>>>>> János Jarecsni wrote:
>>>>>>>>>>>
>>>>>>>>>>>  and how a component can get to know the page in which
>>>>>>>>>>> it is
>>>>>>>>>>> included? I
>>>>>>>>>>>
>>>>>>>>>> mean, I can't @InjectPage, as the component will be
>>>>>>>>>> included
>>>>>>>>>>
>>>>>>>>>>> in
>>>>>>>>>>>
>>>>>>>>>> many
>>>>>>>  kinds
>>>>>>>>>  of pages.
>>>>>>>>>>>> @Kristian: thx for the many ways :) I'll try these,
>>>>>>>>>>>> hope
>>>>>>>>>>>> that
>>>>>>>>>>>>
>>>>>>>>>>>>  the
>>>>>>>>>> @Environmental stuff is scalable (I'm trying to bypass
>>>>>>> session
>>>>>>>
>>>>>>>> creation
>>>>>>>>>> as
>>>>>>>>>>
>>>>>>>>>>>  much as possible)
>>>>>>>>>>>
>>>>>>>>>>>> Is there a doc on the various annotations available?
>>>>>>>>>>>>
>>>>>>>>>>>> @Michael:
>>>>>>>>>>>> Could you include a tiny bit of example? THX!
>>>>>>>>>>>>
>>>>>>>>>>>> Thx to you all
>>>>>>>>>>>> cheers
>>>>>>>>>>>> janos
>>>>>>>>>>>>
>>>>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>  5) @InjectPage the page and call the getter
>>>>>>>>>>>>
>>>>>>>>>>>>> Kristian Marinkovic wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>  hi janos,
>>>>>>>>>>>>>
>>>>>>>>>>>>>> there are several possibilities:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> 1) declare a component parameter and pass in the
>>>>>>>>>>>>>> variable
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> 2) put it in a ASO and inject the ASO in all your
>>>>>>>>>>>>>> components
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  (using
>>>>>>>>>>>> @ApplicationState)
>>>>>>>>>>> the drawback is that any other page or component will
>>>>>>>>>>>>>> be
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  able to
>>>>>>>>>>>> access
>>>>>>>>  the ASO
>>>>>>>>>>>> 3) put it into the Environment and read it whereever
>>>>>>>>>>>>>> you
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  need it
>>>>>>>>>>>> in
>>>>>>>> your
>>>>>>>>>>>  nested components.
>>>>>>>>>>>
>>>>>>>>>>>> be careful when you put your object in your
>>>>>>>>>>>>>> environment. if
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  you
>>>>>>>>>>>> put it
>>>>>>>>  in
>>>>>>>>>>>>>  during the action
>>>>>>>>>>>>>
>>>>>>>>>>>>>> request it will not be able in the render request
>>>>>>>>>>>>>> (because
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  of
>>>>>>>>>>>> the
>>>>>>>  page
>>>>>>>>> redirect).
>>>>>>>>>>> page:
>>>>>>>>>>>>>> @Inject Environment env;
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> @Persist("flash") whateverclass w;
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> onActivate(w) {  this.w= w }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> setupRender() { env.push(whateverclass.class,w);}
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> components:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> @Environmental Whateverclass var;
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> 4) define a service that can take this variable
>>>>>>>>>>>>>> (and
>>>>>>>>>>>>>> saves
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  it
>>>>>>>>>>>>>>  appropriatly
>>>>>>>>>>>>>>
>>>>>>>>>>>>>  so it is not
>>>>>>>>>>>>>
>>>>>>>>>>>>>> lost on a redirect:)) and inject your service in
>>>>>>>>>>>>>> the
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  components
>>>>>>>>>>>> where
>>>>>>>> needed
>>>>>>>>>>> to retrieve the value.
>>>>>>>>>>>>>> maybe there are some more possibilities :)
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> g,
>>>>>>>>>>>>>> kris
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> "János Jarecsni" <ja...@gmail.com>
>>>>>>>>>>>>>> 29.04.2008 08:15
>>>>>>>>>>>>>> Bitte antworten an
>>>>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> An
>>>>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
>>>>>>>>>>>>>> Kopie
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Thema
>>>>>>>>>>>>>> page activation + components
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Hi there,
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> I have an activatable page, in its
>>>>>>>>>>>>>> onActivate(String
>>>>>>>>>>>>>> param)
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  method
>>>>>>>>>>>> I
>>>>>>>>>  save
>>>>>>>>>>>>>  the param to a normal instance variable of the page
>>>>>>>>>>>>>
>>>>>>>>>>>>>> class
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  (no
>>>>>>>>>>>> persistence!).
>>>>>>>> How can any component embedded within this page access
>>>>>>>>>>>>>> this
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  variable?
>>>>>>>>>>>> the page class:
>>>>>>>>>>> //...
>>>>>>>>>>>>>> private String param;
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> public void onActivate(String param) {
>>>>>>>>>>>>>>  this.param = param;
>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> public String getParam() {...}
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Thx in advance!
>>>>>>>>>>>>>> Janos
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  --
>>>>>>>>>>>>>>
>>>>>>>>>>>>> http://thegodcode.net
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> ------------------------------------------------------------------
>>>>>>>>>>>>>
>>>>>>>>>>>> ---
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>
>>>>>>>> For additional commands, e-mail: users-
>>>>>>>>>>>>>  help@tapestry.apache.org
>>>>>>>>>>>>>  --
>>>>>>>>>>>>>
>>>>>>>>>>>> http://thegodcode.net
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>>>
>>>>>>>>>> To unsubscribe, e-mail:
>>>>>>>> users-unsubscribe@tapestry.apache.org
>>>>>>>>
>>>>>>>>> For additional commands, e-mail:
>>>>>>>>>>> users-help@tapestry.apache.org
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>  --
>>>>>>>>>>>
>>>>>>>>>> http://thegodcode.net
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> ------------------------------------------------------------------
>>>>>>>>>
>>>>>>>>>  ---
>>>>>>> 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
>>>>>>
>>>>>>
>>>>> ---------------------------------------------------------------------
>>>> 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
>>
>>

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


Re: page activation + components

Posted by János Jarecsni <ja...@gmail.com>.
This did the trick! Superb, it works just like I want it :)
Actually, having 2 network roundtrips for a single requests sounds a little
bad doesn't it?

cheers
janos

2008/4/30 Filip S. Adamsen <fs...@fsadev.com>:

> That's pretty hard to do without some kind of persistence because of the
> redirect that happens between the component action and the page render.
>
> There's of course tapestry.suppress-redirect-from-action-requests, but I
> would strongly recommend AGAINST using that.
>
> http://tapestry.apache.org/tapestry5/tapestry-core/guide/conf.html
>
> -Filip
>
> János Jarecsni skrev:
>
>  Hi,
> >
> > I looked everywhere for usage of request scope variables, but found
> > nothing
> > (maybe I'm impatient a bit :)...
> > Is it really that unrealistic to have two components in a page, one (A)
> > having an action link eventhandler where it would set some attribute for
> > the
> > request only (not the session!) and then component B could render itself
> > according to the attribute set by component A?
> >
> > I think it should be a piece of cake :)
> >
> > thx
> > Janos
> >
> > 2008/4/30 Filip S. Adamsen <fs...@fsadev.com>:
> >
> >  Nope, you're exactly right.
> > >
> > > -Filip
> > >
> > > Blower, Andy skrev:
> > >
> > >  This is not what I understood 'perthread' scope to be. I thought that
> > > it
> > >
> > > > meant that each thread using a service gets its own instance of the
> > > > service
> > > > to use, even though that instance may not be the same as any
> > > > previous
> > > > instance it used. In other words, nothing to do with user sessions,
> > > > it's
> > > > just for services that are not thread safe and cannot be singletons.
> > > >
> > > > Have I got the wrong end of the stick here?
> > > >
> > > >  -----Original Message-----
> > > >
> > > > > From: Andy Huhn [mailto:amhuhn@hrtc.net]
> > > > > Sent: 29 April 2008 17:34
> > > > > To: Tapestry users
> > > > > Subject: Re: page activation + components
> > > > >
> > > > >
> > > > > Hello,
> > > > >
> > > > > You can define the scope of each service...you can set that
> > > > > particular
> > > > > service to be tied to only one session.
> > > > >
> > > > > See http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html
> > > > > ,
> > > > > and
> > > > > search for "perthread".
> > > > >
> > > > > Thanks,
> > > > > Andy
> > > > >
> > > > > On Tue, 29 Apr 2008 18:02:52 +0200, "János Jarecsni"
> > > > > <ja...@gmail.com> wrote:
> > > > >
> > > > >  Hi there,
> > > > > >
> > > > > > the service approach (as I expected) is session-agnostic (and is
> > > > > > page-independent so concurrent users would interfere badly),
> > > > > >
> > > > > >  therefore is
> > > > >
> > > > >  not ok.
> > > > > >
> > > > > > I will now try the Environment approach... if that is
> > > > > > session-aware
> > > > > >
> > > > > >  :)
> > > > >
> > > > >  thx again
> > > > > > janos
> > > > > >
> > > > > > 2008/4/29 János Jarecsni <ja...@gmail.com>:
> > > > > >
> > > > > >  Hi Chris,
> > > > > >
> > > > > > > even so you could help :) I want this kind of generic way of
> > > > > > > passing
> > > > > > > around information (component to component communication :))
> > > > > > > so
> > > > > > > I'll
> > > > > > >
> > > > > > >  look
> > > > > >
> > > > > >  for the solutions Kristian and you outlined.
> > > > > > >
> > > > > > > thanks!
> > > > > > >
> > > > > > > cheers,
> > > > > > > janos
> > > > > > >
> > > > > > > 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > > > > >
> > > > > > >  Janos,
> > > > > > >
> > > > > > > > Without code or a description of your actual goal, I'm
> > > > > > > > finding
> > > > > > > >
> > > > > > > >  your
> > > > > > >
> > > > > > situation too hypothetical to really digest. The one thing I can
> > > > > >
> > > > > > > point
> > > > > > >
> > > > > > out is what you said about wanting a component to set a property
> > > > > >
> > > > > > > in
> > > > > > >
> > > > > > the
> > > > > >
> > > > > >  page. If you want to do that, then you have to know the class
> > > > > > > of
> > > > > > > the
> > > > > > >
> > > > > > page and so injecting a page would make sense. Of course that
> > > > > >
> > > > > > > means
> > > > > > >
> > > > > > tightly coupling a component to a page, which to me doesn't make
> > > > > >
> > > > > > > sense.
> > > > > > > If you simply need a generic way of passing data between pages
> > > > > > > and
> > > > > > >
> > > > > > > > components, consider using a service that provides an
> > > > > > > > untyped
> > > > > > > > list
> > > > > > > >
> > > > > > > >  or
> > > > > > >
> > > > > > putting something in the environment as Kristian suggested. I'm
> > > > > >
> > > > > > > sorry
> > > > > > >
> > > > > > I
> > > > > >
> > > > > >  can't be more helpful but as I said I'm not clear on what
> > > > > > > you're
> > > > > > > really
> > > > > > > trying to do.
> > > > > > >
> > > > > > > > good luck
> > > > > > > > chris
> > > > > > > >
> > > > > > > > János Jarecsni wrote:
> > > > > > > >
> > > > > > > >  Hi Chris,
> > > > > > > > >
> > > > > > > > > I thought of pages as "contexts" for the components
> > > > > > > > > embedded
> > > > > > > > >
> > > > > > > > >  within
> > > > > > > >
> > > > > > > them.
> > > > > >
> > > > > > > So, in one event handler of a component I would like to set
> > > > > > > > > some
> > > > > > > > >
> > > > > > > > >  property or
> > > > > > > >
> > > > > > > >  another (in the page object), and the other components in
> > > > > > > > > the
> > > > > > > > >
> > > > > > > > >  page,
> > > > > > > >
> > > > > > > which
> > > > > >
> > > > > > > are also able to access this property may change their
> > > > > > > > >
> > > > > > > > >  appearance
> > > > > > > >
> > > > > > > (say, the
> > > > > >
> > > > > > > .TML would test the property). Maybe I'm on a wrong track,
> > > > > > > > >
> > > > > > > > >  please
> > > > > > > >
> > > > > > > let
> > > > > >
> > > > > >  me
> > > > > > >
> > > > > > > > know :)
> > > > > > > > >
> > > > > > > > > thx
> > > > > > > > > Cheers,
> > > > > > > > > janos
> > > > > > > > >
> > > > > > > > > 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >  Janos,
> > > > > > > > >
> > > > > > > > > > I'm having a hard time understanding a case that a
> > > > > > > > > > component
> > > > > > > > > >
> > > > > > > > > >  should
> > > > > > > > >
> > > > > > > > know
> > > > > >
> > > > > > > in which page it is embedded, so my suggestion probably wasn't
> > > > > > > > > a
> > > > > > > > >
> > > > > > > > good
> > > > > >
> > > > > >  one. Activation contexts aren't meant for components but for
> > > > > > >
> > > > > > > > pages
> > > > > > > > >
> > > > > > > > -
> > > > > >
> > > > > >  you
> > > > > > >
> > > > > > > > should be using component parameters to configure them, and
> > > > > > > > > if
> > > > > > > > > it's
> > > > > > > > >
> > > > > > > > a
> > > > > >
> > > > > >  more sophisticated component, probably a service.
> > > > > > >
> > > > > > > > chris
> > > > > > > > > >
> > > > > > > > > > János Jarecsni wrote:
> > > > > > > > > >
> > > > > > > > > >  and how a component can get to know the page in which
> > > > > > > > > > it is
> > > > > > > > > > included? I
> > > > > > > > > >
> > > > > > > > > mean, I can't @InjectPage, as the component will be
> > > > > > > > > included
> > > > > > > > >
> > > > > > > > > > in
> > > > > > > > > >
> > > > > > > > > many
> > > > > >
> > > > > >  kinds
> > > > > > >
> > > > > > > >  of pages.
> > > > > > > > > >
> > > > > > > > > > > @Kristian: thx for the many ways :) I'll try these,
> > > > > > > > > > > hope
> > > > > > > > > > > that
> > > > > > > > > > >
> > > > > > > > > > >  the
> > > > > > > > > >
> > > > > > > > > @Environmental stuff is scalable (I'm trying to bypass
> > > > > > session
> > > > > >
> > > > > > > creation
> > > > > > > > > >
> > > > > > > > > as
> > > > > > > > >
> > > > > > > > > >  much as possible)
> > > > > > > > > >
> > > > > > > > > > > Is there a doc on the various annotations available?
> > > > > > > > > > >
> > > > > > > > > > > @Michael:
> > > > > > > > > > > Could you include a tiny bit of example? THX!
> > > > > > > > > > >
> > > > > > > > > > > Thx to you all
> > > > > > > > > > > cheers
> > > > > > > > > > > janos
> > > > > > > > > > >
> > > > > > > > > > > 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >  5) @InjectPage the page and call the getter
> > > > > > > > > > >
> > > > > > > > > > > > Kristian Marinkovic wrote:
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >  hi janos,
> > > > > > > > > > > >
> > > > > > > > > > > > > there are several possibilities:
> > > > > > > > > > > > >
> > > > > > > > > > > > > 1) declare a component parameter and pass in the
> > > > > > > > > > > > > variable
> > > > > > > > > > > > >
> > > > > > > > > > > > > 2) put it in a ASO and inject the ASO in all your
> > > > > > > > > > > > > components
> > > > > > > > > > > > >
> > > > > > > > > > > > >  (using
> > > > > > > > > > > >
> > > > > > > > > > > @ApplicationState)
> > > > > > > > >
> > > > > > > > > > the drawback is that any other page or component will
> > > > > > > > > > > > > be
> > > > > > > > > > > > >
> > > > > > > > > > > > >  able to
> > > > > > > > > > > >
> > > > > > > > > > > access
> > > > > >
> > > > > > >  the ASO
> > > > > > > > > >
> > > > > > > > > > > 3) put it into the Environment and read it whereever
> > > > > > > > > > > > > you
> > > > > > > > > > > > >
> > > > > > > > > > > > >  need it
> > > > > > > > > > > >
> > > > > > > > > > > in
> > > > > >
> > > > > > > your
> > > > > > > > >
> > > > > > > > > >  nested components.
> > > > > > > > > >
> > > > > > > > > > > be careful when you put your object in your
> > > > > > > > > > > > > environment. if
> > > > > > > > > > > > >
> > > > > > > > > > > > >  you
> > > > > > > > > > > >
> > > > > > > > > > > put it
> > > > > >
> > > > > > >  in
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >  during the action
> > > > > > > > > > > >
> > > > > > > > > > > > > request it will not be able in the render request
> > > > > > > > > > > > > (because
> > > > > > > > > > > > >
> > > > > > > > > > > > >  of
> > > > > > > > > > > >
> > > > > > > > > > > the
> > > > > >
> > > > > >  page
> > > > > > >
> > > > > > > > redirect).
> > > > > > > > >
> > > > > > > > > > page:
> > > > > > > > > > > > >
> > > > > > > > > > > > > @Inject Environment env;
> > > > > > > > > > > > >
> > > > > > > > > > > > > @Persist("flash") whateverclass w;
> > > > > > > > > > > > >
> > > > > > > > > > > > > onActivate(w) {  this.w= w }
> > > > > > > > > > > > >
> > > > > > > > > > > > > setupRender() { env.push(whateverclass.class,w);}
> > > > > > > > > > > > >
> > > > > > > > > > > > > components:
> > > > > > > > > > > > >
> > > > > > > > > > > > > @Environmental Whateverclass var;
> > > > > > > > > > > > >
> > > > > > > > > > > > > 4) define a service that can take this variable
> > > > > > > > > > > > > (and
> > > > > > > > > > > > > saves
> > > > > > > > > > > > >
> > > > > > > > > > > > >  it
> > > > > > > > > > > >
> > > > > > > > > > > > >  appropriatly
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >  so it is not
> > > > > > > > > > > >
> > > > > > > > > > > > > lost on a redirect:)) and inject your service in
> > > > > > > > > > > > > the
> > > > > > > > > > > > >
> > > > > > > > > > > > >  components
> > > > > > > > > > > >
> > > > > > > > > > > where
> > > > > >
> > > > > > > needed
> > > > > > > > >
> > > > > > > > > > to retrieve the value.
> > > > > > > > > > > > >
> > > > > > > > > > > > > maybe there are some more possibilities :)
> > > > > > > > > > > > >
> > > > > > > > > > > > > g,
> > > > > > > > > > > > > kris
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > "János Jarecsni" <ja...@gmail.com>
> > > > > > > > > > > > > 29.04.2008 08:15
> > > > > > > > > > > > > Bitte antworten an
> > > > > > > > > > > > > "Tapestry users" <us...@tapestry.apache.org>
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > An
> > > > > > > > > > > > > "Tapestry users" <us...@tapestry.apache.org>
> > > > > > > > > > > > > Kopie
> > > > > > > > > > > > >
> > > > > > > > > > > > > Thema
> > > > > > > > > > > > > page activation + components
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > Hi there,
> > > > > > > > > > > > >
> > > > > > > > > > > > > I have an activatable page, in its
> > > > > > > > > > > > > onActivate(String
> > > > > > > > > > > > > param)
> > > > > > > > > > > > >
> > > > > > > > > > > > >  method
> > > > > > > > > > > >
> > > > > > > > > > > I
> > > > > > >
> > > > > > > >  save
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >  the param to a normal instance variable of the page
> > > > > > > > > > > >
> > > > > > > > > > > > > class
> > > > > > > > > > > > >
> > > > > > > > > > > > >  (no
> > > > > > > > > > > >
> > > > > > > > > > > persistence!).
> > > > > >
> > > > > > > How can any component embedded within this page access
> > > > > > > > > > > > > this
> > > > > > > > > > > > >
> > > > > > > > > > > > >  variable?
> > > > > > > > > > > >
> > > > > > > > > > > the page class:
> > > > > > > > >
> > > > > > > > > > //...
> > > > > > > > > > > > > private String param;
> > > > > > > > > > > > >
> > > > > > > > > > > > > public void onActivate(String param) {
> > > > > > > > > > > > >  this.param = param;
> > > > > > > > > > > > > }
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > public String getParam() {...}
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > Thx in advance!
> > > > > > > > > > > > > Janos
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >  --
> > > > > > > > > > > > >
> > > > > > > > > > > > http://thegodcode.net
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > ------------------------------------------------------------------
> > > > > > > > > > > >
> > > > > > > > > > > ---
> > > > > > >
> > > > > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > > >
> > > > > > > For additional commands, e-mail: users-
> > > > > > > > > > > >
> > > > > > > > > > > >  help@tapestry.apache.org
> > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >  --
> > > > > > > > > > > >
> > > > > > > > > > > http://thegodcode.net
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > ---------------------------------------------------------------------
> > > > > > > > > >
> > > > > > > > > To unsubscribe, e-mail:
> > > > > > > users-unsubscribe@tapestry.apache.org
> > > > > > >
> > > > > > > > For additional commands, e-mail:
> > > > > > > > > > users-help@tapestry.apache.org
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >  --
> > > > > > > > > >
> > > > > > > > > http://thegodcode.net
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > ------------------------------------------------------------------
> > > > > > > >
> > > > > > > >  ---
> > > > > > >
> > > > > > 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
> > > > >
> > > > >
> > > > ---------------------------------------------------------------------
> > >
> > > 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: page activation + components

Posted by "Filip S. Adamsen" <fs...@fsadev.com>.
That's pretty hard to do without some kind of persistence because of the 
redirect that happens between the component action and the page render.

There's of course tapestry.suppress-redirect-from-action-requests, but I 
would strongly recommend AGAINST using that.

http://tapestry.apache.org/tapestry5/tapestry-core/guide/conf.html

-Filip

János Jarecsni skrev:
> Hi,
> 
> I looked everywhere for usage of request scope variables, but found nothing
> (maybe I'm impatient a bit :)...
> Is it really that unrealistic to have two components in a page, one (A)
> having an action link eventhandler where it would set some attribute for the
> request only (not the session!) and then component B could render itself
> according to the attribute set by component A?
> 
> I think it should be a piece of cake :)
> 
> thx
> Janos
> 
> 2008/4/30 Filip S. Adamsen <fs...@fsadev.com>:
> 
>> Nope, you're exactly right.
>>
>> -Filip
>>
>> Blower, Andy skrev:
>>
>>  This is not what I understood 'perthread' scope to be. I thought that it
>>> meant that each thread using a service gets its own instance of the service
>>> to use, even though that instance may not be the same as any previous
>>> instance it used. In other words, nothing to do with user sessions, it's
>>> just for services that are not thread safe and cannot be singletons.
>>>
>>> Have I got the wrong end of the stick here?
>>>
>>>  -----Original Message-----
>>>> From: Andy Huhn [mailto:amhuhn@hrtc.net]
>>>> Sent: 29 April 2008 17:34
>>>> To: Tapestry users
>>>> Subject: Re: page activation + components
>>>>
>>>>
>>>> Hello,
>>>>
>>>> You can define the scope of each service...you can set that particular
>>>> service to be tied to only one session.
>>>>
>>>> See http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html,
>>>> and
>>>> search for "perthread".
>>>>
>>>> Thanks,
>>>> Andy
>>>>
>>>> On Tue, 29 Apr 2008 18:02:52 +0200, "János Jarecsni"
>>>> <ja...@gmail.com> wrote:
>>>>
>>>>> Hi there,
>>>>>
>>>>> the service approach (as I expected) is session-agnostic (and is
>>>>> page-independent so concurrent users would interfere badly),
>>>>>
>>>> therefore is
>>>>
>>>>> not ok.
>>>>>
>>>>> I will now try the Environment approach... if that is session-aware
>>>>>
>>>> :)
>>>>
>>>>> thx again
>>>>> janos
>>>>>
>>>>> 2008/4/29 János Jarecsni <ja...@gmail.com>:
>>>>>
>>>>>  Hi Chris,
>>>>>> even so you could help :) I want this kind of generic way of
>>>>>> passing
>>>>>> around information (component to component communication :)) so
>>>>>> I'll
>>>>>>
>>>>> look
>>>>>
>>>>>> for the solutions Kristian and you outlined.
>>>>>>
>>>>>> thanks!
>>>>>>
>>>>>> cheers,
>>>>>> janos
>>>>>>
>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>>>>>>
>>>>>>  Janos,
>>>>>>> Without code or a description of your actual goal, I'm finding
>>>>>>>
>>>>>> your
>>>>> situation too hypothetical to really digest. The one thing I can
>>>>>> point
>>>>> out is what you said about wanting a component to set a property
>>>>>> in
>>>>> the
>>>>>
>>>>>> page. If you want to do that, then you have to know the class of
>>>>>> the
>>>>> page and so injecting a page would make sense. Of course that
>>>>>> means
>>>>> tightly coupling a component to a page, which to me doesn't make
>>>>>> sense.
>>>>>> If you simply need a generic way of passing data between pages and
>>>>>>> components, consider using a service that provides an untyped
>>>>>>> list
>>>>>>>
>>>>>> or
>>>>> putting something in the environment as Kristian suggested. I'm
>>>>>> sorry
>>>>> I
>>>>>
>>>>>> can't be more helpful but as I said I'm not clear on what you're
>>>>>> really
>>>>>> trying to do.
>>>>>>> good luck
>>>>>>> chris
>>>>>>>
>>>>>>> János Jarecsni wrote:
>>>>>>>
>>>>>>>> Hi Chris,
>>>>>>>>
>>>>>>>> I thought of pages as "contexts" for the components embedded
>>>>>>>>
>>>>>>> within
>>>>> them.
>>>>>>>> So, in one event handler of a component I would like to set
>>>>>>>> some
>>>>>>>>
>>>>>>> property or
>>>>>>>
>>>>>>>> another (in the page object), and the other components in the
>>>>>>>>
>>>>>>> page,
>>>>> which
>>>>>>>> are also able to access this property may change their
>>>>>>>>
>>>>>>> appearance
>>>>> (say, the
>>>>>>>> .TML would test the property). Maybe I'm on a wrong track,
>>>>>>>>
>>>>>>> please
>>>>> let
>>>>>
>>>>>> me
>>>>>>>> know :)
>>>>>>>>
>>>>>>>> thx
>>>>>>>> Cheers,
>>>>>>>> janos
>>>>>>>>
>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>>>>>>>>
>>>>>>>>
>>>>>>>>  Janos,
>>>>>>>>> I'm having a hard time understanding a case that a component
>>>>>>>>>
>>>>>>>> should
>>>>> know
>>>>>>>> in which page it is embedded, so my suggestion probably wasn't
>>>>>>>> a
>>>>> good
>>>>>
>>>>>> one. Activation contexts aren't meant for components but for
>>>>>>>> pages
>>>>> -
>>>>>
>>>>>> you
>>>>>>>> should be using component parameters to configure them, and if
>>>>>>>> it's
>>>>> a
>>>>>
>>>>>> more sophisticated component, probably a service.
>>>>>>>>> chris
>>>>>>>>>
>>>>>>>>> János Jarecsni wrote:
>>>>>>>>>
>>>>>>>>>  and how a component can get to know the page in which it is
>>>>>>>>> included? I
>>>>>>>> mean, I can't @InjectPage, as the component will be included
>>>>>>>>> in
>>>>> many
>>>>>
>>>>>> kinds
>>>>>>>>>  of pages.
>>>>>>>>>> @Kristian: thx for the many ways :) I'll try these, hope
>>>>>>>>>> that
>>>>>>>>>>
>>>>>>>>> the
>>>>> @Environmental stuff is scalable (I'm trying to bypass session
>>>>>>>>> creation
>>>>>>>> as
>>>>>>>>>  much as possible)
>>>>>>>>>> Is there a doc on the various annotations available?
>>>>>>>>>>
>>>>>>>>>> @Michael:
>>>>>>>>>> Could you include a tiny bit of example? THX!
>>>>>>>>>>
>>>>>>>>>> Thx to you all
>>>>>>>>>> cheers
>>>>>>>>>> janos
>>>>>>>>>>
>>>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>  5) @InjectPage the page and call the getter
>>>>>>>>>>> Kristian Marinkovic wrote:
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>  hi janos,
>>>>>>>>>>>> there are several possibilities:
>>>>>>>>>>>>
>>>>>>>>>>>> 1) declare a component parameter and pass in the
>>>>>>>>>>>> variable
>>>>>>>>>>>>
>>>>>>>>>>>> 2) put it in a ASO and inject the ASO in all your
>>>>>>>>>>>> components
>>>>>>>>>>>>
>>>>>>>>>>> (using
>>>>>>>> @ApplicationState)
>>>>>>>>>>>> the drawback is that any other page or component will
>>>>>>>>>>>> be
>>>>>>>>>>>>
>>>>>>>>>>> able to
>>>>> access
>>>>>>>>>  the ASO
>>>>>>>>>>>> 3) put it into the Environment and read it whereever
>>>>>>>>>>>> you
>>>>>>>>>>>>
>>>>>>>>>>> need it
>>>>> in
>>>>>>>> your
>>>>>>>>>  nested components.
>>>>>>>>>>>> be careful when you put your object in your
>>>>>>>>>>>> environment. if
>>>>>>>>>>>>
>>>>>>>>>>> you
>>>>> put it
>>>>>>>>>>>>  in
>>>>>>>>>>>
>>>>>>>>>>>  during the action
>>>>>>>>>>>> request it will not be able in the render request
>>>>>>>>>>>> (because
>>>>>>>>>>>>
>>>>>>>>>>> of
>>>>> the
>>>>>
>>>>>> page
>>>>>>>> redirect).
>>>>>>>>>>>> page:
>>>>>>>>>>>>
>>>>>>>>>>>> @Inject Environment env;
>>>>>>>>>>>>
>>>>>>>>>>>> @Persist("flash") whateverclass w;
>>>>>>>>>>>>
>>>>>>>>>>>> onActivate(w) {  this.w= w }
>>>>>>>>>>>>
>>>>>>>>>>>> setupRender() { env.push(whateverclass.class,w);}
>>>>>>>>>>>>
>>>>>>>>>>>> components:
>>>>>>>>>>>>
>>>>>>>>>>>> @Environmental Whateverclass var;
>>>>>>>>>>>>
>>>>>>>>>>>> 4) define a service that can take this variable (and
>>>>>>>>>>>> saves
>>>>>>>>>>>>
>>>>>>>>>>> it
>>>>>>>>>>>>  appropriatly
>>>>>>>>>>>
>>>>>>>>>>>  so it is not
>>>>>>>>>>>> lost on a redirect:)) and inject your service in the
>>>>>>>>>>>>
>>>>>>>>>>> components
>>>>> where
>>>>>>>> needed
>>>>>>>>>>>> to retrieve the value.
>>>>>>>>>>>>
>>>>>>>>>>>> maybe there are some more possibilities :)
>>>>>>>>>>>>
>>>>>>>>>>>> g,
>>>>>>>>>>>> kris
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> "János Jarecsni" <ja...@gmail.com>
>>>>>>>>>>>> 29.04.2008 08:15
>>>>>>>>>>>> Bitte antworten an
>>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> An
>>>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
>>>>>>>>>>>> Kopie
>>>>>>>>>>>>
>>>>>>>>>>>> Thema
>>>>>>>>>>>> page activation + components
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Hi there,
>>>>>>>>>>>>
>>>>>>>>>>>> I have an activatable page, in its onActivate(String
>>>>>>>>>>>> param)
>>>>>>>>>>>>
>>>>>>>>>>> method
>>>>>> I
>>>>>>>>>>>>  save
>>>>>>>>>>>
>>>>>>>>>>>  the param to a normal instance variable of the page
>>>>>>>>>>>> class
>>>>>>>>>>>>
>>>>>>>>>>> (no
>>>>> persistence!).
>>>>>>>>>>>> How can any component embedded within this page access
>>>>>>>>>>>> this
>>>>>>>>>>>>
>>>>>>>>>>> variable?
>>>>>>>> the page class:
>>>>>>>>>>>> //...
>>>>>>>>>>>> private String param;
>>>>>>>>>>>>
>>>>>>>>>>>> public void onActivate(String param) {
>>>>>>>>>>>>   this.param = param;
>>>>>>>>>>>> }
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> public String getParam() {...}
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Thx in advance!
>>>>>>>>>>>> Janos
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>  --
>>>>>>>>>>> http://thegodcode.net
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> ------------------------------------------------------------------
>>>>>> ---
>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>>>>> For additional commands, e-mail: users-
>>>>>>>>>>>
>>>>>>>>>> help@tapestry.apache.org
>>>>>>>>>>>
>>>>>>>>>>>  --
>>>>>>>>> http://thegodcode.net
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>>> For additional commands, e-mail:
>>>>>>>>> users-help@tapestry.apache.org
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>  --
>>>>>>> http://thegodcode.net
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> ------------------------------------------------------------------
>>>>>>>
>>>>>> ---
>>>>> 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
>>>>
>>>
>> ---------------------------------------------------------------------
>>
>> 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: page activation + components

Posted by János Jarecsni <ja...@gmail.com>.
Hi,

I looked everywhere for usage of request scope variables, but found nothing
(maybe I'm impatient a bit :)...
Is it really that unrealistic to have two components in a page, one (A)
having an action link eventhandler where it would set some attribute for the
request only (not the session!) and then component B could render itself
according to the attribute set by component A?

I think it should be a piece of cake :)

thx
Janos

2008/4/30 Filip S. Adamsen <fs...@fsadev.com>:

> Nope, you're exactly right.
>
> -Filip
>
> Blower, Andy skrev:
>
>  This is not what I understood 'perthread' scope to be. I thought that it
> > meant that each thread using a service gets its own instance of the service
> > to use, even though that instance may not be the same as any previous
> > instance it used. In other words, nothing to do with user sessions, it's
> > just for services that are not thread safe and cannot be singletons.
> >
> > Have I got the wrong end of the stick here?
> >
> >  -----Original Message-----
> > > From: Andy Huhn [mailto:amhuhn@hrtc.net]
> > > Sent: 29 April 2008 17:34
> > > To: Tapestry users
> > > Subject: Re: page activation + components
> > >
> > >
> > > Hello,
> > >
> > > You can define the scope of each service...you can set that particular
> > > service to be tied to only one session.
> > >
> > > See http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html,
> > > and
> > > search for "perthread".
> > >
> > > Thanks,
> > > Andy
> > >
> > > On Tue, 29 Apr 2008 18:02:52 +0200, "János Jarecsni"
> > > <ja...@gmail.com> wrote:
> > >
> > > > Hi there,
> > > >
> > > > the service approach (as I expected) is session-agnostic (and is
> > > > page-independent so concurrent users would interfere badly),
> > > >
> > > therefore is
> > >
> > > > not ok.
> > > >
> > > > I will now try the Environment approach... if that is session-aware
> > > >
> > > :)
> > >
> > > > thx again
> > > > janos
> > > >
> > > > 2008/4/29 János Jarecsni <ja...@gmail.com>:
> > > >
> > > >  Hi Chris,
> > > > >
> > > > > even so you could help :) I want this kind of generic way of
> > > > > passing
> > > > > around information (component to component communication :)) so
> > > > > I'll
> > > > >
> > > > look
> > > >
> > > > > for the solutions Kristian and you outlined.
> > > > >
> > > > > thanks!
> > > > >
> > > > > cheers,
> > > > > janos
> > > > >
> > > > > 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > > >
> > > > >  Janos,
> > > > > >
> > > > > > Without code or a description of your actual goal, I'm finding
> > > > > >
> > > > > your
> > >
> > > > situation too hypothetical to really digest. The one thing I can
> > > > > >
> > > > > point
> > >
> > > > out is what you said about wanting a component to set a property
> > > > > >
> > > > > in
> > >
> > > > the
> > > >
> > > > > page. If you want to do that, then you have to know the class of
> > > > > >
> > > > > the
> > >
> > > > page and so injecting a page would make sense. Of course that
> > > > > >
> > > > > means
> > >
> > > > tightly coupling a component to a page, which to me doesn't make
> > > > > >
> > > > > sense.
> > > >
> > > > > If you simply need a generic way of passing data between pages and
> > > > > > components, consider using a service that provides an untyped
> > > > > > list
> > > > > >
> > > > > or
> > >
> > > > putting something in the environment as Kristian suggested. I'm
> > > > > >
> > > > > sorry
> > >
> > > > I
> > > >
> > > > > can't be more helpful but as I said I'm not clear on what you're
> > > > > >
> > > > > really
> > > >
> > > > > trying to do.
> > > > > >
> > > > > > good luck
> > > > > > chris
> > > > > >
> > > > > > János Jarecsni wrote:
> > > > > >
> > > > > > > Hi Chris,
> > > > > > >
> > > > > > > I thought of pages as "contexts" for the components embedded
> > > > > > >
> > > > > > within
> > >
> > > > them.
> > > > > >
> > > > > > > So, in one event handler of a component I would like to set
> > > > > > > some
> > > > > > >
> > > > > > property or
> > > > > >
> > > > > > > another (in the page object), and the other components in the
> > > > > > >
> > > > > > page,
> > >
> > > > which
> > > > > >
> > > > > > > are also able to access this property may change their
> > > > > > >
> > > > > > appearance
> > >
> > > > (say, the
> > > > > >
> > > > > > > .TML would test the property). Maybe I'm on a wrong track,
> > > > > > >
> > > > > > please
> > >
> > > > let
> > > >
> > > > > me
> > > > > >
> > > > > > > know :)
> > > > > > >
> > > > > > > thx
> > > > > > > Cheers,
> > > > > > > janos
> > > > > > >
> > > > > > > 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > > > > >
> > > > > > >
> > > > > > >  Janos,
> > > > > > > >
> > > > > > > > I'm having a hard time understanding a case that a component
> > > > > > > >
> > > > > > > should
> > >
> > > > know
> > > > > >
> > > > > > > in which page it is embedded, so my suggestion probably wasn't
> > > > > > > >
> > > > > > > a
> > >
> > > > good
> > > >
> > > > > one. Activation contexts aren't meant for components but for
> > > > > > > >
> > > > > > > pages
> > >
> > > > -
> > > >
> > > > > you
> > > > > >
> > > > > > > should be using component parameters to configure them, and if
> > > > > > > >
> > > > > > > it's
> > >
> > > > a
> > > >
> > > > > more sophisticated component, probably a service.
> > > > > > > >
> > > > > > > > chris
> > > > > > > >
> > > > > > > > János Jarecsni wrote:
> > > > > > > >
> > > > > > > >  and how a component can get to know the page in which it is
> > > > > > > > >
> > > > > > > > included? I
> > > > > >
> > > > > > > mean, I can't @InjectPage, as the component will be included
> > > > > > > > >
> > > > > > > > in
> > >
> > > > many
> > > >
> > > > > kinds
> > > > > > > >
> > > > > > > >  of pages.
> > > > > > > > >
> > > > > > > > > @Kristian: thx for the many ways :) I'll try these, hope
> > > > > > > > > that
> > > > > > > > >
> > > > > > > > the
> > >
> > > > @Environmental stuff is scalable (I'm trying to bypass session
> > > > > > > > >
> > > > > > > > creation
> > > > > >
> > > > > > > as
> > > > > > > >
> > > > > > > >  much as possible)
> > > > > > > > >
> > > > > > > > > Is there a doc on the various annotations available?
> > > > > > > > >
> > > > > > > > > @Michael:
> > > > > > > > > Could you include a tiny bit of example? THX!
> > > > > > > > >
> > > > > > > > > Thx to you all
> > > > > > > > > cheers
> > > > > > > > > janos
> > > > > > > > >
> > > > > > > > > 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >  5) @InjectPage the page and call the getter
> > > > > > > > > >
> > > > > > > > > > Kristian Marinkovic wrote:
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >  hi janos,
> > > > > > > > > > >
> > > > > > > > > > > there are several possibilities:
> > > > > > > > > > >
> > > > > > > > > > > 1) declare a component parameter and pass in the
> > > > > > > > > > > variable
> > > > > > > > > > >
> > > > > > > > > > > 2) put it in a ASO and inject the ASO in all your
> > > > > > > > > > > components
> > > > > > > > > > >
> > > > > > > > > > (using
> > > > > >
> > > > > > > @ApplicationState)
> > > > > > > > > > > the drawback is that any other page or component will
> > > > > > > > > > > be
> > > > > > > > > > >
> > > > > > > > > > able to
> > >
> > > > access
> > > > > > > >
> > > > > > > >  the ASO
> > > > > > > > > > >
> > > > > > > > > > > 3) put it into the Environment and read it whereever
> > > > > > > > > > > you
> > > > > > > > > > >
> > > > > > > > > > need it
> > >
> > > > in
> > > > > >
> > > > > > > your
> > > > > > > >
> > > > > > > >  nested components.
> > > > > > > > > > > be careful when you put your object in your
> > > > > > > > > > > environment. if
> > > > > > > > > > >
> > > > > > > > > > you
> > >
> > > > put it
> > > > > >
> > > > > > >
> > > > > > > > > > >  in
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >  during the action
> > > > > > > > > > > request it will not be able in the render request
> > > > > > > > > > > (because
> > > > > > > > > > >
> > > > > > > > > > of
> > >
> > > > the
> > > >
> > > > > page
> > > > > >
> > > > > > > redirect).
> > > > > > > > > > >
> > > > > > > > > > > page:
> > > > > > > > > > >
> > > > > > > > > > > @Inject Environment env;
> > > > > > > > > > >
> > > > > > > > > > > @Persist("flash") whateverclass w;
> > > > > > > > > > >
> > > > > > > > > > > onActivate(w) {  this.w= w }
> > > > > > > > > > >
> > > > > > > > > > > setupRender() { env.push(whateverclass.class,w);}
> > > > > > > > > > >
> > > > > > > > > > > components:
> > > > > > > > > > >
> > > > > > > > > > > @Environmental Whateverclass var;
> > > > > > > > > > >
> > > > > > > > > > > 4) define a service that can take this variable (and
> > > > > > > > > > > saves
> > > > > > > > > > >
> > > > > > > > > > it
> > >
> > > >
> > > > > > > > > > >  appropriatly
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >  so it is not
> > > > > > > > > > > lost on a redirect:)) and inject your service in the
> > > > > > > > > > >
> > > > > > > > > > components
> > >
> > > > where
> > > > > >
> > > > > > > needed
> > > > > > > > > > > to retrieve the value.
> > > > > > > > > > >
> > > > > > > > > > > maybe there are some more possibilities :)
> > > > > > > > > > >
> > > > > > > > > > > g,
> > > > > > > > > > > kris
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > "János Jarecsni" <ja...@gmail.com>
> > > > > > > > > > > 29.04.2008 08:15
> > > > > > > > > > > Bitte antworten an
> > > > > > > > > > > "Tapestry users" <us...@tapestry.apache.org>
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > An
> > > > > > > > > > > "Tapestry users" <us...@tapestry.apache.org>
> > > > > > > > > > > Kopie
> > > > > > > > > > >
> > > > > > > > > > > Thema
> > > > > > > > > > > page activation + components
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Hi there,
> > > > > > > > > > >
> > > > > > > > > > > I have an activatable page, in its onActivate(String
> > > > > > > > > > > param)
> > > > > > > > > > >
> > > > > > > > > > method
> > > >
> > > > > I
> > > > > >
> > > > > > >
> > > > > > > > > > >  save
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >  the param to a normal instance variable of the page
> > > > > > > > > > > class
> > > > > > > > > > >
> > > > > > > > > > (no
> > >
> > > > persistence!).
> > > > > > > > > > > How can any component embedded within this page access
> > > > > > > > > > > this
> > > > > > > > > > >
> > > > > > > > > > variable?
> > > > > >
> > > > > > > the page class:
> > > > > > > > > > >
> > > > > > > > > > > //...
> > > > > > > > > > > private String param;
> > > > > > > > > > >
> > > > > > > > > > > public void onActivate(String param) {
> > > > > > > > > > >   this.param = param;
> > > > > > > > > > > }
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > public String getParam() {...}
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Thx in advance!
> > > > > > > > > > > Janos
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >  --
> > > > > > > > > > http://thegodcode.net
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > ------------------------------------------------------------------
> > > > > >
> > > > > ---
> > >
> > > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > > > > > > > For additional commands, e-mail: users-
> > > > > > > > > >
> > > > > > > > > help@tapestry.apache.org
> > >
> > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >  --
> > > > > > > > http://thegodcode.net
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > ---------------------------------------------------------------------
> > > >
> > > > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > > > > > For additional commands, e-mail:
> > > > > > > > users-help@tapestry.apache.org
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >  --
> > > > > > http://thegodcode.net
> > > > > >
> > > > > >
> > > > > >
> > > > > > ------------------------------------------------------------------
> > > > > >
> > > > > ---
> > >
> > > > 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
> > >
> >
> >
> ---------------------------------------------------------------------
>
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: page activation + components

Posted by "Filip S. Adamsen" <fs...@fsadev.com>.
Nope, you're exactly right.

-Filip

Blower, Andy skrev:
> This is not what I understood 'perthread' scope to be. I thought that it meant that each thread using a service gets its own instance of the service to use, even though that instance may not be the same as any previous instance it used. In other words, nothing to do with user sessions, it's just for services that are not thread safe and cannot be singletons.
> 
> Have I got the wrong end of the stick here?
> 
>> -----Original Message-----
>> From: Andy Huhn [mailto:amhuhn@hrtc.net]
>> Sent: 29 April 2008 17:34
>> To: Tapestry users
>> Subject: Re: page activation + components
>>
>>
>> Hello,
>>
>> You can define the scope of each service...you can set that particular
>> service to be tied to only one session.
>>
>> See http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html, and
>> search for "perthread".
>>
>> Thanks,
>> Andy
>>
>> On Tue, 29 Apr 2008 18:02:52 +0200, "János Jarecsni"
>> <ja...@gmail.com> wrote:
>>> Hi there,
>>>
>>> the service approach (as I expected) is session-agnostic (and is
>>> page-independent so concurrent users would interfere badly),
>> therefore is
>>> not ok.
>>>
>>> I will now try the Environment approach... if that is session-aware
>> :)
>>> thx again
>>> janos
>>>
>>> 2008/4/29 János Jarecsni <ja...@gmail.com>:
>>>
>>>> Hi Chris,
>>>>
>>>> even so you could help :) I want this kind of generic way of passing
>>>> around information (component to component communication :)) so I'll
>>> look
>>>> for the solutions Kristian and you outlined.
>>>>
>>>> thanks!
>>>>
>>>> cheers,
>>>> janos
>>>>
>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>>>>
>>>>> Janos,
>>>>>
>>>>> Without code or a description of your actual goal, I'm finding
>> your
>>>>> situation too hypothetical to really digest. The one thing I can
>> point
>>>>> out is what you said about wanting a component to set a property
>> in
>>> the
>>>>> page. If you want to do that, then you have to know the class of
>> the
>>>>> page and so injecting a page would make sense. Of course that
>> means
>>>>> tightly coupling a component to a page, which to me doesn't make
>>> sense.
>>>>> If you simply need a generic way of passing data between pages and
>>>>> components, consider using a service that provides an untyped list
>> or
>>>>> putting something in the environment as Kristian suggested. I'm
>> sorry
>>> I
>>>>> can't be more helpful but as I said I'm not clear on what you're
>>> really
>>>>> trying to do.
>>>>>
>>>>> good luck
>>>>> chris
>>>>>
>>>>> János Jarecsni wrote:
>>>>>> Hi Chris,
>>>>>>
>>>>>> I thought of pages as "contexts" for the components embedded
>> within
>>>>> them.
>>>>>> So, in one event handler of a component I would like to set some
>>>>> property or
>>>>>> another (in the page object), and the other components in the
>> page,
>>>>> which
>>>>>> are also able to access this property may change their
>> appearance
>>>>> (say, the
>>>>>> .TML would test the property). Maybe I'm on a wrong track,
>> please
>>> let
>>>>> me
>>>>>> know :)
>>>>>>
>>>>>> thx
>>>>>> Cheers,
>>>>>> janos
>>>>>>
>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>>>>>>
>>>>>>
>>>>>>> Janos,
>>>>>>>
>>>>>>> I'm having a hard time understanding a case that a component
>> should
>>>>> know
>>>>>>> in which page it is embedded, so my suggestion probably wasn't
>> a
>>> good
>>>>>>> one. Activation contexts aren't meant for components but for
>> pages
>>> -
>>>>> you
>>>>>>> should be using component parameters to configure them, and if
>> it's
>>> a
>>>>>>> more sophisticated component, probably a service.
>>>>>>>
>>>>>>> chris
>>>>>>>
>>>>>>> János Jarecsni wrote:
>>>>>>>
>>>>>>>> and how a component can get to know the page in which it is
>>>>> included? I
>>>>>>>> mean, I can't @InjectPage, as the component will be included
>> in
>>> many
>>>>>>> kinds
>>>>>>>
>>>>>>>> of pages.
>>>>>>>>
>>>>>>>> @Kristian: thx for the many ways :) I'll try these, hope that
>> the
>>>>>>>> @Environmental stuff is scalable (I'm trying to bypass session
>>>>> creation
>>>>>>> as
>>>>>>>
>>>>>>>> much as possible)
>>>>>>>>
>>>>>>>> Is there a doc on the various annotations available?
>>>>>>>>
>>>>>>>> @Michael:
>>>>>>>> Could you include a tiny bit of example? THX!
>>>>>>>>
>>>>>>>> Thx to you all
>>>>>>>> cheers
>>>>>>>> janos
>>>>>>>>
>>>>>>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> 5) @InjectPage the page and call the getter
>>>>>>>>>
>>>>>>>>> Kristian Marinkovic wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> hi janos,
>>>>>>>>>>
>>>>>>>>>> there are several possibilities:
>>>>>>>>>>
>>>>>>>>>> 1) declare a component parameter and pass in the variable
>>>>>>>>>>
>>>>>>>>>> 2) put it in a ASO and inject the ASO in all your components
>>>>> (using
>>>>>>>>>> @ApplicationState)
>>>>>>>>>> the drawback is that any other page or component will be
>> able to
>>>>>>> access
>>>>>>>
>>>>>>>>>> the ASO
>>>>>>>>>>
>>>>>>>>>> 3) put it into the Environment and read it whereever you
>> need it
>>>>> in
>>>>>>> your
>>>>>>>
>>>>>>>>>> nested components.
>>>>>>>>>> be careful when you put your object in your environment. if
>> you
>>>>> put it
>>>>>>>>>>
>>>>>>>>> in
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> during the action
>>>>>>>>>> request it will not be able in the render request (because
>> of
>>> the
>>>>> page
>>>>>>>>>> redirect).
>>>>>>>>>>
>>>>>>>>>> page:
>>>>>>>>>>
>>>>>>>>>> @Inject Environment env;
>>>>>>>>>>
>>>>>>>>>> @Persist("flash") whateverclass w;
>>>>>>>>>>
>>>>>>>>>> onActivate(w) {  this.w= w }
>>>>>>>>>>
>>>>>>>>>> setupRender() { env.push(whateverclass.class,w);}
>>>>>>>>>>
>>>>>>>>>> components:
>>>>>>>>>>
>>>>>>>>>> @Environmental Whateverclass var;
>>>>>>>>>>
>>>>>>>>>> 4) define a service that can take this variable (and saves
>> it
>>>>>>>>>>
>>>>>>>>> appropriatly
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> so it is not
>>>>>>>>>> lost on a redirect:)) and inject your service in the
>> components
>>>>> where
>>>>>>>>>> needed
>>>>>>>>>> to retrieve the value.
>>>>>>>>>>
>>>>>>>>>> maybe there are some more possibilities :)
>>>>>>>>>>
>>>>>>>>>> g,
>>>>>>>>>> kris
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> "János Jarecsni" <ja...@gmail.com>
>>>>>>>>>> 29.04.2008 08:15
>>>>>>>>>> Bitte antworten an
>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> An
>>>>>>>>>> "Tapestry users" <us...@tapestry.apache.org>
>>>>>>>>>> Kopie
>>>>>>>>>>
>>>>>>>>>> Thema
>>>>>>>>>> page activation + components
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Hi there,
>>>>>>>>>>
>>>>>>>>>> I have an activatable page, in its onActivate(String param)
>>> method
>>>>> I
>>>>>>>>>>
>>>>>>>>> save
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> the param to a normal instance variable of the page class
>> (no
>>>>>>>>>> persistence!).
>>>>>>>>>> How can any component embedded within this page access this
>>>>> variable?
>>>>>>>>>> the page class:
>>>>>>>>>>
>>>>>>>>>> //...
>>>>>>>>>> private String param;
>>>>>>>>>>
>>>>>>>>>> public void onActivate(String param) {
>>>>>>>>>>    this.param = param;
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> public String getParam() {...}
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Thx in advance!
>>>>>>>>>> Janos
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> http://thegodcode.net
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>> ------------------------------------------------------------------
>> ---
>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>>>> For additional commands, e-mail: users-
>> help@tapestry.apache.org
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>> --
>>>>>>> http://thegodcode.net
>>>>>>>
>>>>>>>
>>>>>>>
>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>>
>>>>>>>
>>>>>>>
>>>>> --
>>>>> http://thegodcode.net
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------
>> ---
>>>>> 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
> 

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


Re: page activation + components

Posted by János Jarecsni <ja...@gmail.com>.
Maybe the request approach does not work, as T5 has two requests
action+render following each other? And the request attributes are reset
between them?

Janos

2008/4/30 János Jarecsni <ja...@gmail.com>:

> No, I think then I misunderstood you :)
> The essential thing, is I'd like to have something similar to request
> scoped variables... something that would be available to all components and
> the page itself in the same request. Intention is to avoid creating a
> session as far as possible.
>
> thx!
> cheers
> janos
>
> 2008/4/30 Blower, Andy <An...@proquest.co.uk>:
>
> This is not what I understood 'perthread' scope to be. I thought that it
> > meant that each thread using a service gets its own instance of the service
> > to use, even though that instance may not be the same as any previous
> > instance it used. In other words, nothing to do with user sessions, it's
> > just for services that are not thread safe and cannot be singletons.
> >
> > Have I got the wrong end of the stick here?
> >
> > > -----Original Message-----
> > > From: Andy Huhn [mailto:amhuhn@hrtc.net]
> > > Sent: 29 April 2008 17:34
> > > To: Tapestry users
> > > Subject: Re: page activation + components
> > >
> > >
> > > Hello,
> > >
> > > You can define the scope of each service...you can set that particular
> > > service to be tied to only one session.
> > >
> > > See http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html,
> > and
> > > search for "perthread".
> > >
> > > Thanks,
> > > Andy
> > >
> > > On Tue, 29 Apr 2008 18:02:52 +0200, "János Jarecsni"
> > > <ja...@gmail.com> wrote:
> > > > Hi there,
> > > >
> > > > the service approach (as I expected) is session-agnostic (and is
> > > > page-independent so concurrent users would interfere badly),
> > > therefore is
> > > > not ok.
> > > >
> > > > I will now try the Environment approach... if that is session-aware
> > > :)
> > > >
> > > > thx again
> > > > janos
> > > >
> > > > 2008/4/29 János Jarecsni <ja...@gmail.com>:
> > > >
> > > >> Hi Chris,
> > > >>
> > > >> even so you could help :) I want this kind of generic way of
> > passing
> > > >> around information (component to component communication :)) so
> > I'll
> > > > look
> > > >> for the solutions Kristian and you outlined.
> > > >>
> > > >> thanks!
> > > >>
> > > >> cheers,
> > > >> janos
> > > >>
> > > >> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > >>
> > > >> > Janos,
> > > >> >
> > > >> > Without code or a description of your actual goal, I'm finding
> > > your
> > > >> > situation too hypothetical to really digest. The one thing I can
> > > point
> > > >> > out is what you said about wanting a component to set a property
> > > in
> > > > the
> > > >> > page. If you want to do that, then you have to know the class of
> > > the
> > > >> > page and so injecting a page would make sense. Of course that
> > > means
> > > >> > tightly coupling a component to a page, which to me doesn't make
> > > > sense.
> > > >> > If you simply need a generic way of passing data between pages
> > and
> > > >> > components, consider using a service that provides an untyped
> > list
> > > or
> > > >> > putting something in the environment as Kristian suggested. I'm
> > > sorry
> > > > I
> > > >> > can't be more helpful but as I said I'm not clear on what you're
> > > > really
> > > >> > trying to do.
> > > >> >
> > > >> > good luck
> > > >> > chris
> > > >> >
> > > >> > János Jarecsni wrote:
> > > >> > > Hi Chris,
> > > >> > >
> > > >> > > I thought of pages as "contexts" for the components embedded
> > > within
> > > >> > them.
> > > >> > > So, in one event handler of a component I would like to set
> > some
> > > >> > property or
> > > >> > > another (in the page object), and the other components in the
> > > page,
> > > >> > which
> > > >> > > are also able to access this property may change their
> > > appearance
> > > >> > (say, the
> > > >> > > .TML would test the property). Maybe I'm on a wrong track,
> > > please
> > > > let
> > > >> > me
> > > >> > > know :)
> > > >> > >
> > > >> > > thx
> > > >> > > Cheers,
> > > >> > > janos
> > > >> > >
> > > >> > > 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > >> > >
> > > >> > >
> > > >> > >> Janos,
> > > >> > >>
> > > >> > >> I'm having a hard time understanding a case that a component
> > > should
> > > >> > know
> > > >> > >> in which page it is embedded, so my suggestion probably wasn't
> > > a
> > > > good
> > > >> > >> one. Activation contexts aren't meant for components but for
> > > pages
> > > > -
> > > >> > you
> > > >> > >> should be using component parameters to configure them, and if
> > > it's
> > > > a
> > > >> > >> more sophisticated component, probably a service.
> > > >> > >>
> > > >> > >> chris
> > > >> > >>
> > > >> > >> János Jarecsni wrote:
> > > >> > >>
> > > >> > >>> and how a component can get to know the page in which it is
> > > >> > included? I
> > > >> > >>> mean, I can't @InjectPage, as the component will be included
> > > in
> > > > many
> > > >> > >>>
> > > >> > >> kinds
> > > >> > >>
> > > >> > >>> of pages.
> > > >> > >>>
> > > >> > >>> @Kristian: thx for the many ways :) I'll try these, hope that
> > > the
> > > >> > >>> @Environmental stuff is scalable (I'm trying to bypass
> > session
> > > >> > creation
> > > >> > >>>
> > > >> > >> as
> > > >> > >>
> > > >> > >>> much as possible)
> > > >> > >>>
> > > >> > >>> Is there a doc on the various annotations available?
> > > >> > >>>
> > > >> > >>> @Michael:
> > > >> > >>> Could you include a tiny bit of example? THX!
> > > >> > >>>
> > > >> > >>> Thx to you all
> > > >> > >>> cheers
> > > >> > >>> janos
> > > >> > >>>
> > > >> > >>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > > >> > >>>
> > > >> > >>>
> > > >> > >>>
> > > >> > >>>> 5) @InjectPage the page and call the getter
> > > >> > >>>>
> > > >> > >>>> Kristian Marinkovic wrote:
> > > >> > >>>>
> > > >> > >>>>
> > > >> > >>>>> hi janos,
> > > >> > >>>>>
> > > >> > >>>>> there are several possibilities:
> > > >> > >>>>>
> > > >> > >>>>> 1) declare a component parameter and pass in the variable
> > > >> > >>>>>
> > > >> > >>>>> 2) put it in a ASO and inject the ASO in all your
> > components
> > > >> > (using
> > > >> > >>>>> @ApplicationState)
> > > >> > >>>>> the drawback is that any other page or component will be
> > > able to
> > > >> > >>>>>
> > > >> > >> access
> > > >> > >>
> > > >> > >>>>> the ASO
> > > >> > >>>>>
> > > >> > >>>>> 3) put it into the Environment and read it whereever you
> > > need it
> > > >> > in
> > > >> > >>>>>
> > > >> > >> your
> > > >> > >>
> > > >> > >>>>> nested components.
> > > >> > >>>>> be careful when you put your object in your environment. if
> > > you
> > > >> > put it
> > > >> > >>>>>
> > > >> > >>>>>
> > > >> > >>>> in
> > > >> > >>>>
> > > >> > >>>>
> > > >> > >>>>> during the action
> > > >> > >>>>> request it will not be able in the render request (because
> > > of
> > > > the
> > > >> > page
> > > >> > >>>>> redirect).
> > > >> > >>>>>
> > > >> > >>>>> page:
> > > >> > >>>>>
> > > >> > >>>>> @Inject Environment env;
> > > >> > >>>>>
> > > >> > >>>>> @Persist("flash") whateverclass w;
> > > >> > >>>>>
> > > >> > >>>>> onActivate(w) {  this.w= w }
> > > >> > >>>>>
> > > >> > >>>>> setupRender() { env.push(whateverclass.class,w);}
> > > >> > >>>>>
> > > >> > >>>>> components:
> > > >> > >>>>>
> > > >> > >>>>> @Environmental Whateverclass var;
> > > >> > >>>>>
> > > >> > >>>>> 4) define a service that can take this variable (and saves
> > > it
> > > >> > >>>>>
> > > >> > >>>>>
> > > >> > >>>> appropriatly
> > > >> > >>>>
> > > >> > >>>>
> > > >> > >>>>> so it is not
> > > >> > >>>>> lost on a redirect:)) and inject your service in the
> > > components
> > > >> > where
> > > >> > >>>>> needed
> > > >> > >>>>> to retrieve the value.
> > > >> > >>>>>
> > > >> > >>>>> maybe there are some more possibilities :)
> > > >> > >>>>>
> > > >> > >>>>> g,
> > > >> > >>>>> kris
> > > >> > >>>>>
> > > >> > >>>>>
> > > >> > >>>>>
> > > >> > >>>>>
> > > >> > >>>>> "János Jarecsni" <ja...@gmail.com>
> > > >> > >>>>> 29.04.2008 08:15
> > > >> > >>>>> Bitte antworten an
> > > >> > >>>>> "Tapestry users" <us...@tapestry.apache.org>
> > > >> > >>>>>
> > > >> > >>>>>
> > > >> > >>>>> An
> > > >> > >>>>> "Tapestry users" <us...@tapestry.apache.org>
> > > >> > >>>>> Kopie
> > > >> > >>>>>
> > > >> > >>>>> Thema
> > > >> > >>>>> page activation + components
> > > >> > >>>>>
> > > >> > >>>>>
> > > >> > >>>>>
> > > >> > >>>>>
> > > >> > >>>>>
> > > >> > >>>>>
> > > >> > >>>>> Hi there,
> > > >> > >>>>>
> > > >> > >>>>> I have an activatable page, in its onActivate(String param)
> > > > method
> > > >> > I
> > > >> > >>>>>
> > > >> > >>>>>
> > > >> > >>>> save
> > > >> > >>>>
> > > >> > >>>>
> > > >> > >>>>> the param to a normal instance variable of the page class
> > > (no
> > > >> > >>>>> persistence!).
> > > >> > >>>>> How can any component embedded within this page access this
> > > >> > variable?
> > > >> > >>>>>
> > > >> > >>>>> the page class:
> > > >> > >>>>>
> > > >> > >>>>> //...
> > > >> > >>>>> private String param;
> > > >> > >>>>>
> > > >> > >>>>> public void onActivate(String param) {
> > > >> > >>>>>    this.param = param;
> > > >> > >>>>> }
> > > >> > >>>>>
> > > >> > >>>>>
> > > >> > >>>>> public String getParam() {...}
> > > >> > >>>>>
> > > >> > >>>>>
> > > >> > >>>>> Thx in advance!
> > > >> > >>>>> Janos
> > > >> > >>>>>
> > > >> > >>>>>
> > > >> > >>>>>
> > > >> > >>>>>
> > > >> > >>>>>
> > > >> > >>>> --
> > > >> > >>>> http://thegodcode.net
> > > >> > >>>>
> > > >> > >>>>
> > > >> > >>>>
> > > >> >
> > ------------------------------------------------------------------
> > > ---
> > > >> > >>>> To unsubscribe, e-mail:
> > users-unsubscribe@tapestry.apache.org
> > > >> > >>>> For additional commands, e-mail: users-
> > > help@tapestry.apache.org
> > > >> > >>>>
> > > >> > >>>>
> > > >> > >>>>
> > > >> > >>>>
> > > >> > >> --
> > > >> > >> http://thegodcode.net
> > > >> > >>
> > > >> > >>
> > > >> > >>
> > > >
> > ---------------------------------------------------------------------
> > > >> > >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > >> > >> For additional commands, e-mail:
> > users-help@tapestry.apache.org
> > > >> > >>
> > > >> > >>
> > > >> > >>
> > > >> >
> > > >> > --
> > > >> > http://thegodcode.net
> > > >> >
> > > >> >
> > > >> >
> > ------------------------------------------------------------------
> > > ---
> > > >> > 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: page activation + components

Posted by János Jarecsni <ja...@gmail.com>.
No, I think then I misunderstood you :)
The essential thing, is I'd like to have something similar to request scoped
variables... something that would be available to all components and the
page itself in the same request. Intention is to avoid creating a session as
far as possible.

thx!
cheers
janos

2008/4/30 Blower, Andy <An...@proquest.co.uk>:

> This is not what I understood 'perthread' scope to be. I thought that it
> meant that each thread using a service gets its own instance of the service
> to use, even though that instance may not be the same as any previous
> instance it used. In other words, nothing to do with user sessions, it's
> just for services that are not thread safe and cannot be singletons.
>
> Have I got the wrong end of the stick here?
>
> > -----Original Message-----
> > From: Andy Huhn [mailto:amhuhn@hrtc.net]
> > Sent: 29 April 2008 17:34
> > To: Tapestry users
> > Subject: Re: page activation + components
> >
> >
> > Hello,
> >
> > You can define the scope of each service...you can set that particular
> > service to be tied to only one session.
> >
> > See http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html, and
> > search for "perthread".
> >
> > Thanks,
> > Andy
> >
> > On Tue, 29 Apr 2008 18:02:52 +0200, "János Jarecsni"
> > <ja...@gmail.com> wrote:
> > > Hi there,
> > >
> > > the service approach (as I expected) is session-agnostic (and is
> > > page-independent so concurrent users would interfere badly),
> > therefore is
> > > not ok.
> > >
> > > I will now try the Environment approach... if that is session-aware
> > :)
> > >
> > > thx again
> > > janos
> > >
> > > 2008/4/29 János Jarecsni <ja...@gmail.com>:
> > >
> > >> Hi Chris,
> > >>
> > >> even so you could help :) I want this kind of generic way of passing
> > >> around information (component to component communication :)) so I'll
> > > look
> > >> for the solutions Kristian and you outlined.
> > >>
> > >> thanks!
> > >>
> > >> cheers,
> > >> janos
> > >>
> > >> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > >>
> > >> > Janos,
> > >> >
> > >> > Without code or a description of your actual goal, I'm finding
> > your
> > >> > situation too hypothetical to really digest. The one thing I can
> > point
> > >> > out is what you said about wanting a component to set a property
> > in
> > > the
> > >> > page. If you want to do that, then you have to know the class of
> > the
> > >> > page and so injecting a page would make sense. Of course that
> > means
> > >> > tightly coupling a component to a page, which to me doesn't make
> > > sense.
> > >> > If you simply need a generic way of passing data between pages and
> > >> > components, consider using a service that provides an untyped list
> > or
> > >> > putting something in the environment as Kristian suggested. I'm
> > sorry
> > > I
> > >> > can't be more helpful but as I said I'm not clear on what you're
> > > really
> > >> > trying to do.
> > >> >
> > >> > good luck
> > >> > chris
> > >> >
> > >> > János Jarecsni wrote:
> > >> > > Hi Chris,
> > >> > >
> > >> > > I thought of pages as "contexts" for the components embedded
> > within
> > >> > them.
> > >> > > So, in one event handler of a component I would like to set some
> > >> > property or
> > >> > > another (in the page object), and the other components in the
> > page,
> > >> > which
> > >> > > are also able to access this property may change their
> > appearance
> > >> > (say, the
> > >> > > .TML would test the property). Maybe I'm on a wrong track,
> > please
> > > let
> > >> > me
> > >> > > know :)
> > >> > >
> > >> > > thx
> > >> > > Cheers,
> > >> > > janos
> > >> > >
> > >> > > 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > >> > >
> > >> > >
> > >> > >> Janos,
> > >> > >>
> > >> > >> I'm having a hard time understanding a case that a component
> > should
> > >> > know
> > >> > >> in which page it is embedded, so my suggestion probably wasn't
> > a
> > > good
> > >> > >> one. Activation contexts aren't meant for components but for
> > pages
> > > -
> > >> > you
> > >> > >> should be using component parameters to configure them, and if
> > it's
> > > a
> > >> > >> more sophisticated component, probably a service.
> > >> > >>
> > >> > >> chris
> > >> > >>
> > >> > >> János Jarecsni wrote:
> > >> > >>
> > >> > >>> and how a component can get to know the page in which it is
> > >> > included? I
> > >> > >>> mean, I can't @InjectPage, as the component will be included
> > in
> > > many
> > >> > >>>
> > >> > >> kinds
> > >> > >>
> > >> > >>> of pages.
> > >> > >>>
> > >> > >>> @Kristian: thx for the many ways :) I'll try these, hope that
> > the
> > >> > >>> @Environmental stuff is scalable (I'm trying to bypass session
> > >> > creation
> > >> > >>>
> > >> > >> as
> > >> > >>
> > >> > >>> much as possible)
> > >> > >>>
> > >> > >>> Is there a doc on the various annotations available?
> > >> > >>>
> > >> > >>> @Michael:
> > >> > >>> Could you include a tiny bit of example? THX!
> > >> > >>>
> > >> > >>> Thx to you all
> > >> > >>> cheers
> > >> > >>> janos
> > >> > >>>
> > >> > >>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > >> > >>>
> > >> > >>>
> > >> > >>>
> > >> > >>>> 5) @InjectPage the page and call the getter
> > >> > >>>>
> > >> > >>>> Kristian Marinkovic wrote:
> > >> > >>>>
> > >> > >>>>
> > >> > >>>>> hi janos,
> > >> > >>>>>
> > >> > >>>>> there are several possibilities:
> > >> > >>>>>
> > >> > >>>>> 1) declare a component parameter and pass in the variable
> > >> > >>>>>
> > >> > >>>>> 2) put it in a ASO and inject the ASO in all your components
> > >> > (using
> > >> > >>>>> @ApplicationState)
> > >> > >>>>> the drawback is that any other page or component will be
> > able to
> > >> > >>>>>
> > >> > >> access
> > >> > >>
> > >> > >>>>> the ASO
> > >> > >>>>>
> > >> > >>>>> 3) put it into the Environment and read it whereever you
> > need it
> > >> > in
> > >> > >>>>>
> > >> > >> your
> > >> > >>
> > >> > >>>>> nested components.
> > >> > >>>>> be careful when you put your object in your environment. if
> > you
> > >> > put it
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>> in
> > >> > >>>>
> > >> > >>>>
> > >> > >>>>> during the action
> > >> > >>>>> request it will not be able in the render request (because
> > of
> > > the
> > >> > page
> > >> > >>>>> redirect).
> > >> > >>>>>
> > >> > >>>>> page:
> > >> > >>>>>
> > >> > >>>>> @Inject Environment env;
> > >> > >>>>>
> > >> > >>>>> @Persist("flash") whateverclass w;
> > >> > >>>>>
> > >> > >>>>> onActivate(w) {  this.w= w }
> > >> > >>>>>
> > >> > >>>>> setupRender() { env.push(whateverclass.class,w);}
> > >> > >>>>>
> > >> > >>>>> components:
> > >> > >>>>>
> > >> > >>>>> @Environmental Whateverclass var;
> > >> > >>>>>
> > >> > >>>>> 4) define a service that can take this variable (and saves
> > it
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>> appropriatly
> > >> > >>>>
> > >> > >>>>
> > >> > >>>>> so it is not
> > >> > >>>>> lost on a redirect:)) and inject your service in the
> > components
> > >> > where
> > >> > >>>>> needed
> > >> > >>>>> to retrieve the value.
> > >> > >>>>>
> > >> > >>>>> maybe there are some more possibilities :)
> > >> > >>>>>
> > >> > >>>>> g,
> > >> > >>>>> kris
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>> "János Jarecsni" <ja...@gmail.com>
> > >> > >>>>> 29.04.2008 08:15
> > >> > >>>>> Bitte antworten an
> > >> > >>>>> "Tapestry users" <us...@tapestry.apache.org>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>> An
> > >> > >>>>> "Tapestry users" <us...@tapestry.apache.org>
> > >> > >>>>> Kopie
> > >> > >>>>>
> > >> > >>>>> Thema
> > >> > >>>>> page activation + components
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>> Hi there,
> > >> > >>>>>
> > >> > >>>>> I have an activatable page, in its onActivate(String param)
> > > method
> > >> > I
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>> save
> > >> > >>>>
> > >> > >>>>
> > >> > >>>>> the param to a normal instance variable of the page class
> > (no
> > >> > >>>>> persistence!).
> > >> > >>>>> How can any component embedded within this page access this
> > >> > variable?
> > >> > >>>>>
> > >> > >>>>> the page class:
> > >> > >>>>>
> > >> > >>>>> //...
> > >> > >>>>> private String param;
> > >> > >>>>>
> > >> > >>>>> public void onActivate(String param) {
> > >> > >>>>>    this.param = param;
> > >> > >>>>> }
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>> public String getParam() {...}
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>> Thx in advance!
> > >> > >>>>> Janos
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>> --
> > >> > >>>> http://thegodcode.net
> > >> > >>>>
> > >> > >>>>
> > >> > >>>>
> > >> > ------------------------------------------------------------------
> > ---
> > >> > >>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > >> > >>>> For additional commands, e-mail: users-
> > help@tapestry.apache.org
> > >> > >>>>
> > >> > >>>>
> > >> > >>>>
> > >> > >>>>
> > >> > >> --
> > >> > >> http://thegodcode.net
> > >> > >>
> > >> > >>
> > >> > >>
> > > ---------------------------------------------------------------------
> > >> > >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > >> > >> For additional commands, e-mail: users-help@tapestry.apache.org
> > >> > >>
> > >> > >>
> > >> > >>
> > >> >
> > >> > --
> > >> > http://thegodcode.net
> > >> >
> > >> >
> > >> > ------------------------------------------------------------------
> > ---
> > >> > 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: page activation + components

Posted by "Blower, Andy" <An...@proquest.co.uk>.
This is not what I understood 'perthread' scope to be. I thought that it meant that each thread using a service gets its own instance of the service to use, even though that instance may not be the same as any previous instance it used. In other words, nothing to do with user sessions, it's just for services that are not thread safe and cannot be singletons.

Have I got the wrong end of the stick here?

> -----Original Message-----
> From: Andy Huhn [mailto:amhuhn@hrtc.net]
> Sent: 29 April 2008 17:34
> To: Tapestry users
> Subject: Re: page activation + components
>
>
> Hello,
>
> You can define the scope of each service...you can set that particular
> service to be tied to only one session.
>
> See http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html, and
> search for "perthread".
>
> Thanks,
> Andy
>
> On Tue, 29 Apr 2008 18:02:52 +0200, "János Jarecsni"
> <ja...@gmail.com> wrote:
> > Hi there,
> >
> > the service approach (as I expected) is session-agnostic (and is
> > page-independent so concurrent users would interfere badly),
> therefore is
> > not ok.
> >
> > I will now try the Environment approach... if that is session-aware
> :)
> >
> > thx again
> > janos
> >
> > 2008/4/29 János Jarecsni <ja...@gmail.com>:
> >
> >> Hi Chris,
> >>
> >> even so you could help :) I want this kind of generic way of passing
> >> around information (component to component communication :)) so I'll
> > look
> >> for the solutions Kristian and you outlined.
> >>
> >> thanks!
> >>
> >> cheers,
> >> janos
> >>
> >> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> >>
> >> > Janos,
> >> >
> >> > Without code or a description of your actual goal, I'm finding
> your
> >> > situation too hypothetical to really digest. The one thing I can
> point
> >> > out is what you said about wanting a component to set a property
> in
> > the
> >> > page. If you want to do that, then you have to know the class of
> the
> >> > page and so injecting a page would make sense. Of course that
> means
> >> > tightly coupling a component to a page, which to me doesn't make
> > sense.
> >> > If you simply need a generic way of passing data between pages and
> >> > components, consider using a service that provides an untyped list
> or
> >> > putting something in the environment as Kristian suggested. I'm
> sorry
> > I
> >> > can't be more helpful but as I said I'm not clear on what you're
> > really
> >> > trying to do.
> >> >
> >> > good luck
> >> > chris
> >> >
> >> > János Jarecsni wrote:
> >> > > Hi Chris,
> >> > >
> >> > > I thought of pages as "contexts" for the components embedded
> within
> >> > them.
> >> > > So, in one event handler of a component I would like to set some
> >> > property or
> >> > > another (in the page object), and the other components in the
> page,
> >> > which
> >> > > are also able to access this property may change their
> appearance
> >> > (say, the
> >> > > .TML would test the property). Maybe I'm on a wrong track,
> please
> > let
> >> > me
> >> > > know :)
> >> > >
> >> > > thx
> >> > > Cheers,
> >> > > janos
> >> > >
> >> > > 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> >> > >
> >> > >
> >> > >> Janos,
> >> > >>
> >> > >> I'm having a hard time understanding a case that a component
> should
> >> > know
> >> > >> in which page it is embedded, so my suggestion probably wasn't
> a
> > good
> >> > >> one. Activation contexts aren't meant for components but for
> pages
> > -
> >> > you
> >> > >> should be using component parameters to configure them, and if
> it's
> > a
> >> > >> more sophisticated component, probably a service.
> >> > >>
> >> > >> chris
> >> > >>
> >> > >> János Jarecsni wrote:
> >> > >>
> >> > >>> and how a component can get to know the page in which it is
> >> > included? I
> >> > >>> mean, I can't @InjectPage, as the component will be included
> in
> > many
> >> > >>>
> >> > >> kinds
> >> > >>
> >> > >>> of pages.
> >> > >>>
> >> > >>> @Kristian: thx for the many ways :) I'll try these, hope that
> the
> >> > >>> @Environmental stuff is scalable (I'm trying to bypass session
> >> > creation
> >> > >>>
> >> > >> as
> >> > >>
> >> > >>> much as possible)
> >> > >>>
> >> > >>> Is there a doc on the various annotations available?
> >> > >>>
> >> > >>> @Michael:
> >> > >>> Could you include a tiny bit of example? THX!
> >> > >>>
> >> > >>> Thx to you all
> >> > >>> cheers
> >> > >>> janos
> >> > >>>
> >> > >>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> >> > >>>
> >> > >>>
> >> > >>>
> >> > >>>> 5) @InjectPage the page and call the getter
> >> > >>>>
> >> > >>>> Kristian Marinkovic wrote:
> >> > >>>>
> >> > >>>>
> >> > >>>>> hi janos,
> >> > >>>>>
> >> > >>>>> there are several possibilities:
> >> > >>>>>
> >> > >>>>> 1) declare a component parameter and pass in the variable
> >> > >>>>>
> >> > >>>>> 2) put it in a ASO and inject the ASO in all your components
> >> > (using
> >> > >>>>> @ApplicationState)
> >> > >>>>> the drawback is that any other page or component will be
> able to
> >> > >>>>>
> >> > >> access
> >> > >>
> >> > >>>>> the ASO
> >> > >>>>>
> >> > >>>>> 3) put it into the Environment and read it whereever you
> need it
> >> > in
> >> > >>>>>
> >> > >> your
> >> > >>
> >> > >>>>> nested components.
> >> > >>>>> be careful when you put your object in your environment. if
> you
> >> > put it
> >> > >>>>>
> >> > >>>>>
> >> > >>>> in
> >> > >>>>
> >> > >>>>
> >> > >>>>> during the action
> >> > >>>>> request it will not be able in the render request (because
> of
> > the
> >> > page
> >> > >>>>> redirect).
> >> > >>>>>
> >> > >>>>> page:
> >> > >>>>>
> >> > >>>>> @Inject Environment env;
> >> > >>>>>
> >> > >>>>> @Persist("flash") whateverclass w;
> >> > >>>>>
> >> > >>>>> onActivate(w) {  this.w= w }
> >> > >>>>>
> >> > >>>>> setupRender() { env.push(whateverclass.class,w);}
> >> > >>>>>
> >> > >>>>> components:
> >> > >>>>>
> >> > >>>>> @Environmental Whateverclass var;
> >> > >>>>>
> >> > >>>>> 4) define a service that can take this variable (and saves
> it
> >> > >>>>>
> >> > >>>>>
> >> > >>>> appropriatly
> >> > >>>>
> >> > >>>>
> >> > >>>>> so it is not
> >> > >>>>> lost on a redirect:)) and inject your service in the
> components
> >> > where
> >> > >>>>> needed
> >> > >>>>> to retrieve the value.
> >> > >>>>>
> >> > >>>>> maybe there are some more possibilities :)
> >> > >>>>>
> >> > >>>>> g,
> >> > >>>>> kris
> >> > >>>>>
> >> > >>>>>
> >> > >>>>>
> >> > >>>>>
> >> > >>>>> "János Jarecsni" <ja...@gmail.com>
> >> > >>>>> 29.04.2008 08:15
> >> > >>>>> Bitte antworten an
> >> > >>>>> "Tapestry users" <us...@tapestry.apache.org>
> >> > >>>>>
> >> > >>>>>
> >> > >>>>> An
> >> > >>>>> "Tapestry users" <us...@tapestry.apache.org>
> >> > >>>>> Kopie
> >> > >>>>>
> >> > >>>>> Thema
> >> > >>>>> page activation + components
> >> > >>>>>
> >> > >>>>>
> >> > >>>>>
> >> > >>>>>
> >> > >>>>>
> >> > >>>>>
> >> > >>>>> Hi there,
> >> > >>>>>
> >> > >>>>> I have an activatable page, in its onActivate(String param)
> > method
> >> > I
> >> > >>>>>
> >> > >>>>>
> >> > >>>> save
> >> > >>>>
> >> > >>>>
> >> > >>>>> the param to a normal instance variable of the page class
> (no
> >> > >>>>> persistence!).
> >> > >>>>> How can any component embedded within this page access this
> >> > variable?
> >> > >>>>>
> >> > >>>>> the page class:
> >> > >>>>>
> >> > >>>>> //...
> >> > >>>>> private String param;
> >> > >>>>>
> >> > >>>>> public void onActivate(String param) {
> >> > >>>>>    this.param = param;
> >> > >>>>> }
> >> > >>>>>
> >> > >>>>>
> >> > >>>>> public String getParam() {...}
> >> > >>>>>
> >> > >>>>>
> >> > >>>>> Thx in advance!
> >> > >>>>> Janos
> >> > >>>>>
> >> > >>>>>
> >> > >>>>>
> >> > >>>>>
> >> > >>>>>
> >> > >>>> --
> >> > >>>> http://thegodcode.net
> >> > >>>>
> >> > >>>>
> >> > >>>>
> >> > ------------------------------------------------------------------
> ---
> >> > >>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> > >>>> For additional commands, e-mail: users-
> help@tapestry.apache.org
> >> > >>>>
> >> > >>>>
> >> > >>>>
> >> > >>>>
> >> > >> --
> >> > >> http://thegodcode.net
> >> > >>
> >> > >>
> >> > >>
> > ---------------------------------------------------------------------
> >> > >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> > >> For additional commands, e-mail: users-help@tapestry.apache.org
> >> > >>
> >> > >>
> >> > >>
> >> >
> >> > --
> >> > http://thegodcode.net
> >> >
> >> >
> >> > ------------------------------------------------------------------
> ---
> >> > 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: page activation + components

Posted by Andy Huhn <am...@hrtc.net>.
Hello,

You can define the scope of each service...you can set that particular
service to be tied to only one session.

See http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html, and
search for "perthread".

Thanks,
Andy

On Tue, 29 Apr 2008 18:02:52 +0200, "János Jarecsni"
<ja...@gmail.com> wrote:
> Hi there,
> 
> the service approach (as I expected) is session-agnostic (and is
> page-independent so concurrent users would interfere badly), therefore is
> not ok.
> 
> I will now try the Environment approach... if that is session-aware :)
> 
> thx again
> janos
> 
> 2008/4/29 János Jarecsni <ja...@gmail.com>:
> 
>> Hi Chris,
>>
>> even so you could help :) I want this kind of generic way of passing
>> around information (component to component communication :)) so I'll
> look
>> for the solutions Kristian and you outlined.
>>
>> thanks!
>>
>> cheers,
>> janos
>>
>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>>
>> > Janos,
>> >
>> > Without code or a description of your actual goal, I'm finding your
>> > situation too hypothetical to really digest. The one thing I can point
>> > out is what you said about wanting a component to set a property in
> the
>> > page. If you want to do that, then you have to know the class of the
>> > page and so injecting a page would make sense. Of course that means
>> > tightly coupling a component to a page, which to me doesn't make
> sense.
>> > If you simply need a generic way of passing data between pages and
>> > components, consider using a service that provides an untyped list or
>> > putting something in the environment as Kristian suggested. I'm sorry
> I
>> > can't be more helpful but as I said I'm not clear on what you're
> really
>> > trying to do.
>> >
>> > good luck
>> > chris
>> >
>> > János Jarecsni wrote:
>> > > Hi Chris,
>> > >
>> > > I thought of pages as "contexts" for the components embedded within
>> > them.
>> > > So, in one event handler of a component I would like to set some
>> > property or
>> > > another (in the page object), and the other components in the page,
>> > which
>> > > are also able to access this property may change their appearance
>> > (say, the
>> > > .TML would test the property). Maybe I'm on a wrong track, please
> let
>> > me
>> > > know :)
>> > >
>> > > thx
>> > > Cheers,
>> > > janos
>> > >
>> > > 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>> > >
>> > >
>> > >> Janos,
>> > >>
>> > >> I'm having a hard time understanding a case that a component should
>> > know
>> > >> in which page it is embedded, so my suggestion probably wasn't a
> good
>> > >> one. Activation contexts aren't meant for components but for pages
> -
>> > you
>> > >> should be using component parameters to configure them, and if it's
> a
>> > >> more sophisticated component, probably a service.
>> > >>
>> > >> chris
>> > >>
>> > >> János Jarecsni wrote:
>> > >>
>> > >>> and how a component can get to know the page in which it is
>> > included? I
>> > >>> mean, I can't @InjectPage, as the component will be included in
> many
>> > >>>
>> > >> kinds
>> > >>
>> > >>> of pages.
>> > >>>
>> > >>> @Kristian: thx for the many ways :) I'll try these, hope that the
>> > >>> @Environmental stuff is scalable (I'm trying to bypass session
>> > creation
>> > >>>
>> > >> as
>> > >>
>> > >>> much as possible)
>> > >>>
>> > >>> Is there a doc on the various annotations available?
>> > >>>
>> > >>> @Michael:
>> > >>> Could you include a tiny bit of example? THX!
>> > >>>
>> > >>> Thx to you all
>> > >>> cheers
>> > >>> janos
>> > >>>
>> > >>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>> > >>>
>> > >>>
>> > >>>
>> > >>>> 5) @InjectPage the page and call the getter
>> > >>>>
>> > >>>> Kristian Marinkovic wrote:
>> > >>>>
>> > >>>>
>> > >>>>> hi janos,
>> > >>>>>
>> > >>>>> there are several possibilities:
>> > >>>>>
>> > >>>>> 1) declare a component parameter and pass in the variable
>> > >>>>>
>> > >>>>> 2) put it in a ASO and inject the ASO in all your components
>> > (using
>> > >>>>> @ApplicationState)
>> > >>>>> the drawback is that any other page or component will be able to
>> > >>>>>
>> > >> access
>> > >>
>> > >>>>> the ASO
>> > >>>>>
>> > >>>>> 3) put it into the Environment and read it whereever you need it
>> > in
>> > >>>>>
>> > >> your
>> > >>
>> > >>>>> nested components.
>> > >>>>> be careful when you put your object in your environment. if you
>> > put it
>> > >>>>>
>> > >>>>>
>> > >>>> in
>> > >>>>
>> > >>>>
>> > >>>>> during the action
>> > >>>>> request it will not be able in the render request (because of
> the
>> > page
>> > >>>>> redirect).
>> > >>>>>
>> > >>>>> page:
>> > >>>>>
>> > >>>>> @Inject Environment env;
>> > >>>>>
>> > >>>>> @Persist("flash") whateverclass w;
>> > >>>>>
>> > >>>>> onActivate(w) {  this.w= w }
>> > >>>>>
>> > >>>>> setupRender() { env.push(whateverclass.class,w);}
>> > >>>>>
>> > >>>>> components:
>> > >>>>>
>> > >>>>> @Environmental Whateverclass var;
>> > >>>>>
>> > >>>>> 4) define a service that can take this variable (and saves it
>> > >>>>>
>> > >>>>>
>> > >>>> appropriatly
>> > >>>>
>> > >>>>
>> > >>>>> so it is not
>> > >>>>> lost on a redirect:)) and inject your service in the components
>> > where
>> > >>>>> needed
>> > >>>>> to retrieve the value.
>> > >>>>>
>> > >>>>> maybe there are some more possibilities :)
>> > >>>>>
>> > >>>>> g,
>> > >>>>> kris
>> > >>>>>
>> > >>>>>
>> > >>>>>
>> > >>>>>
>> > >>>>> "János Jarecsni" <ja...@gmail.com>
>> > >>>>> 29.04.2008 08:15
>> > >>>>> Bitte antworten an
>> > >>>>> "Tapestry users" <us...@tapestry.apache.org>
>> > >>>>>
>> > >>>>>
>> > >>>>> An
>> > >>>>> "Tapestry users" <us...@tapestry.apache.org>
>> > >>>>> Kopie
>> > >>>>>
>> > >>>>> Thema
>> > >>>>> page activation + components
>> > >>>>>
>> > >>>>>
>> > >>>>>
>> > >>>>>
>> > >>>>>
>> > >>>>>
>> > >>>>> Hi there,
>> > >>>>>
>> > >>>>> I have an activatable page, in its onActivate(String param)
> method
>> > I
>> > >>>>>
>> > >>>>>
>> > >>>> save
>> > >>>>
>> > >>>>
>> > >>>>> the param to a normal instance variable of the page class (no
>> > >>>>> persistence!).
>> > >>>>> How can any component embedded within this page access this
>> > variable?
>> > >>>>>
>> > >>>>> the page class:
>> > >>>>>
>> > >>>>> //...
>> > >>>>> private String param;
>> > >>>>>
>> > >>>>> public void onActivate(String param) {
>> > >>>>>    this.param = param;
>> > >>>>> }
>> > >>>>>
>> > >>>>>
>> > >>>>> public String getParam() {...}
>> > >>>>>
>> > >>>>>
>> > >>>>> Thx in advance!
>> > >>>>> Janos
>> > >>>>>
>> > >>>>>
>> > >>>>>
>> > >>>>>
>> > >>>>>
>> > >>>> --
>> > >>>> http://thegodcode.net
>> > >>>>
>> > >>>>
>> > >>>>
>> > ---------------------------------------------------------------------
>> > >>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> > >>>> For additional commands, e-mail: users-help@tapestry.apache.org
>> > >>>>
>> > >>>>
>> > >>>>
>> > >>>>
>> > >> --
>> > >> http://thegodcode.net
>> > >>
>> > >>
>> > >>
> ---------------------------------------------------------------------
>> > >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> > >> For additional commands, e-mail: users-help@tapestry.apache.org
>> > >>
>> > >>
>> > >>
>> >
>> > --
>> > http://thegodcode.net
>> >
>> >
>> > ---------------------------------------------------------------------
>> > 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: page activation + components

Posted by János Jarecsni <ja...@gmail.com>.
Hi there,

the service approach (as I expected) is session-agnostic (and is
page-independent so concurrent users would interfere badly), therefore is
not ok.

I will now try the Environment approach... if that is session-aware :)

thx again
janos

2008/4/29 János Jarecsni <ja...@gmail.com>:

> Hi Chris,
>
> even so you could help :) I want this kind of generic way of passing
> around information (component to component communication :)) so I'll look
> for the solutions Kristian and you outlined.
>
> thanks!
>
> cheers,
> janos
>
> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>
> > Janos,
> >
> > Without code or a description of your actual goal, I'm finding your
> > situation too hypothetical to really digest. The one thing I can point
> > out is what you said about wanting a component to set a property in the
> > page. If you want to do that, then you have to know the class of the
> > page and so injecting a page would make sense. Of course that means
> > tightly coupling a component to a page, which to me doesn't make sense.
> > If you simply need a generic way of passing data between pages and
> > components, consider using a service that provides an untyped list or
> > putting something in the environment as Kristian suggested. I'm sorry I
> > can't be more helpful but as I said I'm not clear on what you're really
> > trying to do.
> >
> > good luck
> > chris
> >
> > János Jarecsni wrote:
> > > Hi Chris,
> > >
> > > I thought of pages as "contexts" for the components embedded within
> > them.
> > > So, in one event handler of a component I would like to set some
> > property or
> > > another (in the page object), and the other components in the page,
> > which
> > > are also able to access this property may change their appearance
> > (say, the
> > > .TML would test the property). Maybe I'm on a wrong track, please let
> > me
> > > know :)
> > >
> > > thx
> > > Cheers,
> > > janos
> > >
> > > 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > >
> > >
> > >> Janos,
> > >>
> > >> I'm having a hard time understanding a case that a component should
> > know
> > >> in which page it is embedded, so my suggestion probably wasn't a good
> > >> one. Activation contexts aren't meant for components but for pages -
> > you
> > >> should be using component parameters to configure them, and if it's a
> > >> more sophisticated component, probably a service.
> > >>
> > >> chris
> > >>
> > >> János Jarecsni wrote:
> > >>
> > >>> and how a component can get to know the page in which it is
> > included? I
> > >>> mean, I can't @InjectPage, as the component will be included in many
> > >>>
> > >> kinds
> > >>
> > >>> of pages.
> > >>>
> > >>> @Kristian: thx for the many ways :) I'll try these, hope that the
> > >>> @Environmental stuff is scalable (I'm trying to bypass session
> > creation
> > >>>
> > >> as
> > >>
> > >>> much as possible)
> > >>>
> > >>> Is there a doc on the various annotations available?
> > >>>
> > >>> @Michael:
> > >>> Could you include a tiny bit of example? THX!
> > >>>
> > >>> Thx to you all
> > >>> cheers
> > >>> janos
> > >>>
> > >>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> > >>>
> > >>>
> > >>>
> > >>>> 5) @InjectPage the page and call the getter
> > >>>>
> > >>>> Kristian Marinkovic wrote:
> > >>>>
> > >>>>
> > >>>>> hi janos,
> > >>>>>
> > >>>>> there are several possibilities:
> > >>>>>
> > >>>>> 1) declare a component parameter and pass in the variable
> > >>>>>
> > >>>>> 2) put it in a ASO and inject the ASO in all your components
> > (using
> > >>>>> @ApplicationState)
> > >>>>> the drawback is that any other page or component will be able to
> > >>>>>
> > >> access
> > >>
> > >>>>> the ASO
> > >>>>>
> > >>>>> 3) put it into the Environment and read it whereever you need it
> > in
> > >>>>>
> > >> your
> > >>
> > >>>>> nested components.
> > >>>>> be careful when you put your object in your environment. if you
> > put it
> > >>>>>
> > >>>>>
> > >>>> in
> > >>>>
> > >>>>
> > >>>>> during the action
> > >>>>> request it will not be able in the render request (because of the
> > page
> > >>>>> redirect).
> > >>>>>
> > >>>>> page:
> > >>>>>
> > >>>>> @Inject Environment env;
> > >>>>>
> > >>>>> @Persist("flash") whateverclass w;
> > >>>>>
> > >>>>> onActivate(w) {  this.w= w }
> > >>>>>
> > >>>>> setupRender() { env.push(whateverclass.class,w);}
> > >>>>>
> > >>>>> components:
> > >>>>>
> > >>>>> @Environmental Whateverclass var;
> > >>>>>
> > >>>>> 4) define a service that can take this variable (and saves it
> > >>>>>
> > >>>>>
> > >>>> appropriatly
> > >>>>
> > >>>>
> > >>>>> so it is not
> > >>>>> lost on a redirect:)) and inject your service in the components
> > where
> > >>>>> needed
> > >>>>> to retrieve the value.
> > >>>>>
> > >>>>> maybe there are some more possibilities :)
> > >>>>>
> > >>>>> g,
> > >>>>> kris
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>> "János Jarecsni" <ja...@gmail.com>
> > >>>>> 29.04.2008 08:15
> > >>>>> Bitte antworten an
> > >>>>> "Tapestry users" <us...@tapestry.apache.org>
> > >>>>>
> > >>>>>
> > >>>>> An
> > >>>>> "Tapestry users" <us...@tapestry.apache.org>
> > >>>>> Kopie
> > >>>>>
> > >>>>> Thema
> > >>>>> page activation + components
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>> Hi there,
> > >>>>>
> > >>>>> I have an activatable page, in its onActivate(String param) method
> > I
> > >>>>>
> > >>>>>
> > >>>> save
> > >>>>
> > >>>>
> > >>>>> the param to a normal instance variable of the page class (no
> > >>>>> persistence!).
> > >>>>> How can any component embedded within this page access this
> > variable?
> > >>>>>
> > >>>>> the page class:
> > >>>>>
> > >>>>> //...
> > >>>>> private String param;
> > >>>>>
> > >>>>> public void onActivate(String param) {
> > >>>>>    this.param = param;
> > >>>>> }
> > >>>>>
> > >>>>>
> > >>>>> public String getParam() {...}
> > >>>>>
> > >>>>>
> > >>>>> Thx in advance!
> > >>>>> Janos
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>> --
> > >>>> http://thegodcode.net
> > >>>>
> > >>>>
> > >>>>
> > ---------------------------------------------------------------------
> > >>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > >>>> For additional commands, e-mail: users-help@tapestry.apache.org
> > >>>>
> > >>>>
> > >>>>
> > >>>>
> > >> --
> > >> http://thegodcode.net
> > >>
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > >> For additional commands, e-mail: users-help@tapestry.apache.org
> > >>
> > >>
> > >>
> >
> > --
> > http://thegodcode.net
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>

Re: page activation + components

Posted by János Jarecsni <ja...@gmail.com>.
Hi Chris,

even so you could help :) I want this kind of generic way of passing around
information (component to component communication :)) so I'll look for the
solutions Kristian and you outlined.

thanks!
cheers,
janos

2008/4/29 Chris Lewis <ch...@bellsouth.net>:

> Janos,
>
> Without code or a description of your actual goal, I'm finding your
> situation too hypothetical to really digest. The one thing I can point
> out is what you said about wanting a component to set a property in the
> page. If you want to do that, then you have to know the class of the
> page and so injecting a page would make sense. Of course that means
> tightly coupling a component to a page, which to me doesn't make sense.
> If you simply need a generic way of passing data between pages and
> components, consider using a service that provides an untyped list or
> putting something in the environment as Kristian suggested. I'm sorry I
> can't be more helpful but as I said I'm not clear on what you're really
> trying to do.
>
> good luck
> chris
>
> János Jarecsni wrote:
> > Hi Chris,
> >
> > I thought of pages as "contexts" for the components embedded within
> them.
> > So, in one event handler of a component I would like to set some
> property or
> > another (in the page object), and the other components in the page,
> which
> > are also able to access this property may change their appearance (say,
> the
> > .TML would test the property). Maybe I'm on a wrong track, please let me
> > know :)
> >
> > thx
> > Cheers,
> > janos
> >
> > 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> >
> >
> >> Janos,
> >>
> >> I'm having a hard time understanding a case that a component should
> know
> >> in which page it is embedded, so my suggestion probably wasn't a good
> >> one. Activation contexts aren't meant for components but for pages -
> you
> >> should be using component parameters to configure them, and if it's a
> >> more sophisticated component, probably a service.
> >>
> >> chris
> >>
> >> János Jarecsni wrote:
> >>
> >>> and how a component can get to know the page in which it is included?
> I
> >>> mean, I can't @InjectPage, as the component will be included in many
> >>>
> >> kinds
> >>
> >>> of pages.
> >>>
> >>> @Kristian: thx for the many ways :) I'll try these, hope that the
> >>> @Environmental stuff is scalable (I'm trying to bypass session
> creation
> >>>
> >> as
> >>
> >>> much as possible)
> >>>
> >>> Is there a doc on the various annotations available?
> >>>
> >>> @Michael:
> >>> Could you include a tiny bit of example? THX!
> >>>
> >>> Thx to you all
> >>> cheers
> >>> janos
> >>>
> >>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> >>>
> >>>
> >>>
> >>>> 5) @InjectPage the page and call the getter
> >>>>
> >>>> Kristian Marinkovic wrote:
> >>>>
> >>>>
> >>>>> hi janos,
> >>>>>
> >>>>> there are several possibilities:
> >>>>>
> >>>>> 1) declare a component parameter and pass in the variable
> >>>>>
> >>>>> 2) put it in a ASO and inject the ASO in all your components (using
> >>>>> @ApplicationState)
> >>>>> the drawback is that any other page or component will be able to
> >>>>>
> >> access
> >>
> >>>>> the ASO
> >>>>>
> >>>>> 3) put it into the Environment and read it whereever you need it in
> >>>>>
> >> your
> >>
> >>>>> nested components.
> >>>>> be careful when you put your object in your environment. if you put
> it
> >>>>>
> >>>>>
> >>>> in
> >>>>
> >>>>
> >>>>> during the action
> >>>>> request it will not be able in the render request (because of the
> page
> >>>>> redirect).
> >>>>>
> >>>>> page:
> >>>>>
> >>>>> @Inject Environment env;
> >>>>>
> >>>>> @Persist("flash") whateverclass w;
> >>>>>
> >>>>> onActivate(w) {  this.w= w }
> >>>>>
> >>>>> setupRender() { env.push(whateverclass.class,w);}
> >>>>>
> >>>>> components:
> >>>>>
> >>>>> @Environmental Whateverclass var;
> >>>>>
> >>>>> 4) define a service that can take this variable (and saves it
> >>>>>
> >>>>>
> >>>> appropriatly
> >>>>
> >>>>
> >>>>> so it is not
> >>>>> lost on a redirect:)) and inject your service in the components
> where
> >>>>> needed
> >>>>> to retrieve the value.
> >>>>>
> >>>>> maybe there are some more possibilities :)
> >>>>>
> >>>>> g,
> >>>>> kris
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>> "János Jarecsni" <ja...@gmail.com>
> >>>>> 29.04.2008 08:15
> >>>>> Bitte antworten an
> >>>>> "Tapestry users" <us...@tapestry.apache.org>
> >>>>>
> >>>>>
> >>>>> An
> >>>>> "Tapestry users" <us...@tapestry.apache.org>
> >>>>> Kopie
> >>>>>
> >>>>> Thema
> >>>>> page activation + components
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>> Hi there,
> >>>>>
> >>>>> I have an activatable page, in its onActivate(String param) method I
> >>>>>
> >>>>>
> >>>> save
> >>>>
> >>>>
> >>>>> the param to a normal instance variable of the page class (no
> >>>>> persistence!).
> >>>>> How can any component embedded within this page access this
> variable?
> >>>>>
> >>>>> the page class:
> >>>>>
> >>>>> //...
> >>>>> private String param;
> >>>>>
> >>>>> public void onActivate(String param) {
> >>>>>    this.param = param;
> >>>>> }
> >>>>>
> >>>>>
> >>>>> public String getParam() {...}
> >>>>>
> >>>>>
> >>>>> Thx in advance!
> >>>>> Janos
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>> --
> >>>> http://thegodcode.net
> >>>>
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >>>> For additional commands, e-mail: users-help@tapestry.apache.org
> >>>>
> >>>>
> >>>>
> >>>>
> >> --
> >> http://thegodcode.net
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
> >>
>
> --
> http://thegodcode.net
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: page activation + components

Posted by Chris Lewis <ch...@bellsouth.net>.
Janos,

Without code or a description of your actual goal, I'm finding your
situation too hypothetical to really digest. The one thing I can point
out is what you said about wanting a component to set a property in the
page. If you want to do that, then you have to know the class of the
page and so injecting a page would make sense. Of course that means
tightly coupling a component to a page, which to me doesn't make sense.
If you simply need a generic way of passing data between pages and
components, consider using a service that provides an untyped list or
putting something in the environment as Kristian suggested. I'm sorry I
can't be more helpful but as I said I'm not clear on what you're really
trying to do.

good luck
chris

János Jarecsni wrote:
> Hi Chris,
>
> I thought of pages as "contexts" for the components embedded within them.
> So, in one event handler of a component I would like to set some property or
> another (in the page object), and the other components in the page, which
> are also able to access this property may change their appearance (say, the
> .TML would test the property). Maybe I'm on a wrong track, please let me
> know :)
>
> thx
> Cheers,
> janos
>
> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>
>   
>> Janos,
>>
>> I'm having a hard time understanding a case that a component should know
>> in which page it is embedded, so my suggestion probably wasn't a good
>> one. Activation contexts aren't meant for components but for pages - you
>> should be using component parameters to configure them, and if it's a
>> more sophisticated component, probably a service.
>>
>> chris
>>
>> János Jarecsni wrote:
>>     
>>> and how a component can get to know the page in which it is included? I
>>> mean, I can't @InjectPage, as the component will be included in many
>>>       
>> kinds
>>     
>>> of pages.
>>>
>>> @Kristian: thx for the many ways :) I'll try these, hope that the
>>> @Environmental stuff is scalable (I'm trying to bypass session creation
>>>       
>> as
>>     
>>> much as possible)
>>>
>>> Is there a doc on the various annotations available?
>>>
>>> @Michael:
>>> Could you include a tiny bit of example? THX!
>>>
>>> Thx to you all
>>> cheers
>>> janos
>>>
>>> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>>>
>>>
>>>       
>>>> 5) @InjectPage the page and call the getter
>>>>
>>>> Kristian Marinkovic wrote:
>>>>
>>>>         
>>>>> hi janos,
>>>>>
>>>>> there are several possibilities:
>>>>>
>>>>> 1) declare a component parameter and pass in the variable
>>>>>
>>>>> 2) put it in a ASO and inject the ASO in all your components (using
>>>>> @ApplicationState)
>>>>> the drawback is that any other page or component will be able to
>>>>>           
>> access
>>     
>>>>> the ASO
>>>>>
>>>>> 3) put it into the Environment and read it whereever you need it in
>>>>>           
>> your
>>     
>>>>> nested components.
>>>>> be careful when you put your object in your environment. if you put it
>>>>>
>>>>>           
>>>> in
>>>>
>>>>         
>>>>> during the action
>>>>> request it will not be able in the render request (because of the page
>>>>> redirect).
>>>>>
>>>>> page:
>>>>>
>>>>> @Inject Environment env;
>>>>>
>>>>> @Persist("flash") whateverclass w;
>>>>>
>>>>> onActivate(w) {  this.w= w }
>>>>>
>>>>> setupRender() { env.push(whateverclass.class,w);}
>>>>>
>>>>> components:
>>>>>
>>>>> @Environmental Whateverclass var;
>>>>>
>>>>> 4) define a service that can take this variable (and saves it
>>>>>
>>>>>           
>>>> appropriatly
>>>>
>>>>         
>>>>> so it is not
>>>>> lost on a redirect:)) and inject your service in the components where
>>>>> needed
>>>>> to retrieve the value.
>>>>>
>>>>> maybe there are some more possibilities :)
>>>>>
>>>>> g,
>>>>> kris
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> "János Jarecsni" <ja...@gmail.com>
>>>>> 29.04.2008 08:15
>>>>> Bitte antworten an
>>>>> "Tapestry users" <us...@tapestry.apache.org>
>>>>>
>>>>>
>>>>> An
>>>>> "Tapestry users" <us...@tapestry.apache.org>
>>>>> Kopie
>>>>>
>>>>> Thema
>>>>> page activation + components
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Hi there,
>>>>>
>>>>> I have an activatable page, in its onActivate(String param) method I
>>>>>
>>>>>           
>>>> save
>>>>
>>>>         
>>>>> the param to a normal instance variable of the page class (no
>>>>> persistence!).
>>>>> How can any component embedded within this page access this variable?
>>>>>
>>>>> the page class:
>>>>>
>>>>> //...
>>>>> private String param;
>>>>>
>>>>> public void onActivate(String param) {
>>>>>    this.param = param;
>>>>> }
>>>>>
>>>>>
>>>>> public String getParam() {...}
>>>>>
>>>>>
>>>>> Thx in advance!
>>>>> Janos
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>           
>>>> --
>>>> http://thegodcode.net
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>>
>>>>
>>>>         
>> --
>> http://thegodcode.net
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>     

-- 
http://thegodcode.net


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


Re: page activation + components

Posted by János Jarecsni <ja...@gmail.com>.
Hi Chris,

I thought of pages as "contexts" for the components embedded within them.
So, in one event handler of a component I would like to set some property or
another (in the page object), and the other components in the page, which
are also able to access this property may change their appearance (say, the
.TML would test the property). Maybe I'm on a wrong track, please let me
know :)

thx
Cheers,
janos

2008/4/29 Chris Lewis <ch...@bellsouth.net>:

> Janos,
>
> I'm having a hard time understanding a case that a component should know
> in which page it is embedded, so my suggestion probably wasn't a good
> one. Activation contexts aren't meant for components but for pages - you
> should be using component parameters to configure them, and if it's a
> more sophisticated component, probably a service.
>
> chris
>
> János Jarecsni wrote:
> > and how a component can get to know the page in which it is included? I
> > mean, I can't @InjectPage, as the component will be included in many
> kinds
> > of pages.
> >
> > @Kristian: thx for the many ways :) I'll try these, hope that the
> > @Environmental stuff is scalable (I'm trying to bypass session creation
> as
> > much as possible)
> >
> > Is there a doc on the various annotations available?
> >
> > @Michael:
> > Could you include a tiny bit of example? THX!
> >
> > Thx to you all
> > cheers
> > janos
> >
> > 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
> >
> >
> >> 5) @InjectPage the page and call the getter
> >>
> >> Kristian Marinkovic wrote:
> >>
> >>> hi janos,
> >>>
> >>> there are several possibilities:
> >>>
> >>> 1) declare a component parameter and pass in the variable
> >>>
> >>> 2) put it in a ASO and inject the ASO in all your components (using
> >>> @ApplicationState)
> >>> the drawback is that any other page or component will be able to
> access
> >>> the ASO
> >>>
> >>> 3) put it into the Environment and read it whereever you need it in
> your
> >>> nested components.
> >>> be careful when you put your object in your environment. if you put it
> >>>
> >> in
> >>
> >>> during the action
> >>> request it will not be able in the render request (because of the page
> >>> redirect).
> >>>
> >>> page:
> >>>
> >>> @Inject Environment env;
> >>>
> >>> @Persist("flash") whateverclass w;
> >>>
> >>> onActivate(w) {  this.w= w }
> >>>
> >>> setupRender() { env.push(whateverclass.class,w);}
> >>>
> >>> components:
> >>>
> >>> @Environmental Whateverclass var;
> >>>
> >>> 4) define a service that can take this variable (and saves it
> >>>
> >> appropriatly
> >>
> >>> so it is not
> >>> lost on a redirect:)) and inject your service in the components where
> >>> needed
> >>> to retrieve the value.
> >>>
> >>> maybe there are some more possibilities :)
> >>>
> >>> g,
> >>> kris
> >>>
> >>>
> >>>
> >>>
> >>> "János Jarecsni" <ja...@gmail.com>
> >>> 29.04.2008 08:15
> >>> Bitte antworten an
> >>> "Tapestry users" <us...@tapestry.apache.org>
> >>>
> >>>
> >>> An
> >>> "Tapestry users" <us...@tapestry.apache.org>
> >>> Kopie
> >>>
> >>> Thema
> >>> page activation + components
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>> Hi there,
> >>>
> >>> I have an activatable page, in its onActivate(String param) method I
> >>>
> >> save
> >>
> >>> the param to a normal instance variable of the page class (no
> >>> persistence!).
> >>> How can any component embedded within this page access this variable?
> >>>
> >>> the page class:
> >>>
> >>> //...
> >>> private String param;
> >>>
> >>> public void onActivate(String param) {
> >>>    this.param = param;
> >>> }
> >>>
> >>>
> >>> public String getParam() {...}
> >>>
> >>>
> >>> Thx in advance!
> >>> Janos
> >>>
> >>>
> >>>
> >>>
> >> --
> >> http://thegodcode.net
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
> >>
>
> --
> http://thegodcode.net
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: page activation + components

Posted by Chris Lewis <ch...@bellsouth.net>.
Janos,

I'm having a hard time understanding a case that a component should know
in which page it is embedded, so my suggestion probably wasn't a good
one. Activation contexts aren't meant for components but for pages - you
should be using component parameters to configure them, and if it's a
more sophisticated component, probably a service.

chris

János Jarecsni wrote:
> and how a component can get to know the page in which it is included? I
> mean, I can't @InjectPage, as the component will be included in many kinds
> of pages.
>
> @Kristian: thx for the many ways :) I'll try these, hope that the
> @Environmental stuff is scalable (I'm trying to bypass session creation as
> much as possible)
>
> Is there a doc on the various annotations available?
>
> @Michael:
> Could you include a tiny bit of example? THX!
>
> Thx to you all
> cheers
> janos
>
> 2008/4/29 Chris Lewis <ch...@bellsouth.net>:
>
>   
>> 5) @InjectPage the page and call the getter
>>
>> Kristian Marinkovic wrote:
>>     
>>> hi janos,
>>>
>>> there are several possibilities:
>>>
>>> 1) declare a component parameter and pass in the variable
>>>
>>> 2) put it in a ASO and inject the ASO in all your components (using
>>> @ApplicationState)
>>> the drawback is that any other page or component will be able to access
>>> the ASO
>>>
>>> 3) put it into the Environment and read it whereever you need it in your
>>> nested components.
>>> be careful when you put your object in your environment. if you put it
>>>       
>> in
>>     
>>> during the action
>>> request it will not be able in the render request (because of the page
>>> redirect).
>>>
>>> page:
>>>
>>> @Inject Environment env;
>>>
>>> @Persist("flash") whateverclass w;
>>>
>>> onActivate(w) {  this.w= w }
>>>
>>> setupRender() { env.push(whateverclass.class,w);}
>>>
>>> components:
>>>
>>> @Environmental Whateverclass var;
>>>
>>> 4) define a service that can take this variable (and saves it
>>>       
>> appropriatly
>>     
>>> so it is not
>>> lost on a redirect:)) and inject your service in the components where
>>> needed
>>> to retrieve the value.
>>>
>>> maybe there are some more possibilities :)
>>>
>>> g,
>>> kris
>>>
>>>
>>>
>>>
>>> "János Jarecsni" <ja...@gmail.com>
>>> 29.04.2008 08:15
>>> Bitte antworten an
>>> "Tapestry users" <us...@tapestry.apache.org>
>>>
>>>
>>> An
>>> "Tapestry users" <us...@tapestry.apache.org>
>>> Kopie
>>>
>>> Thema
>>> page activation + components
>>>
>>>
>>>
>>>
>>>
>>>
>>> Hi there,
>>>
>>> I have an activatable page, in its onActivate(String param) method I
>>>       
>> save
>>     
>>> the param to a normal instance variable of the page class (no
>>> persistence!).
>>> How can any component embedded within this page access this variable?
>>>
>>> the page class:
>>>
>>> //...
>>> private String param;
>>>
>>> public void onActivate(String param) {
>>>    this.param = param;
>>> }
>>>
>>>
>>> public String getParam() {...}
>>>
>>>
>>> Thx in advance!
>>> Janos
>>>
>>>
>>>
>>>       
>> --
>> http://thegodcode.net
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>     

-- 
http://thegodcode.net


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


Re: page activation + components

Posted by János Jarecsni <ja...@gmail.com>.
and how a component can get to know the page in which it is included? I
mean, I can't @InjectPage, as the component will be included in many kinds
of pages.

@Kristian: thx for the many ways :) I'll try these, hope that the
@Environmental stuff is scalable (I'm trying to bypass session creation as
much as possible)

Is there a doc on the various annotations available?

@Michael:
Could you include a tiny bit of example? THX!

Thx to you all
cheers
janos

2008/4/29 Chris Lewis <ch...@bellsouth.net>:

> 5) @InjectPage the page and call the getter
>
> Kristian Marinkovic wrote:
> > hi janos,
> >
> > there are several possibilities:
> >
> > 1) declare a component parameter and pass in the variable
> >
> > 2) put it in a ASO and inject the ASO in all your components (using
> > @ApplicationState)
> > the drawback is that any other page or component will be able to access
> > the ASO
> >
> > 3) put it into the Environment and read it whereever you need it in your
> > nested components.
> > be careful when you put your object in your environment. if you put it
> in
> > during the action
> > request it will not be able in the render request (because of the page
> > redirect).
> >
> > page:
> >
> > @Inject Environment env;
> >
> > @Persist("flash") whateverclass w;
> >
> > onActivate(w) {  this.w= w }
> >
> > setupRender() { env.push(whateverclass.class,w);}
> >
> > components:
> >
> > @Environmental Whateverclass var;
> >
> > 4) define a service that can take this variable (and saves it
> appropriatly
> > so it is not
> > lost on a redirect:)) and inject your service in the components where
> > needed
> > to retrieve the value.
> >
> > maybe there are some more possibilities :)
> >
> > g,
> > kris
> >
> >
> >
> >
> > "János Jarecsni" <ja...@gmail.com>
> > 29.04.2008 08:15
> > Bitte antworten an
> > "Tapestry users" <us...@tapestry.apache.org>
> >
> >
> > An
> > "Tapestry users" <us...@tapestry.apache.org>
> > Kopie
> >
> > Thema
> > page activation + components
> >
> >
> >
> >
> >
> >
> > Hi there,
> >
> > I have an activatable page, in its onActivate(String param) method I
> save
> > the param to a normal instance variable of the page class (no
> > persistence!).
> > How can any component embedded within this page access this variable?
> >
> > the page class:
> >
> > //...
> > private String param;
> >
> > public void onActivate(String param) {
> >    this.param = param;
> > }
> >
> >
> > public String getParam() {...}
> >
> >
> > Thx in advance!
> > Janos
> >
> >
> >
>
> --
> http://thegodcode.net
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: page activation + components

Posted by Chris Lewis <ch...@bellsouth.net>.
5) @InjectPage the page and call the getter

Kristian Marinkovic wrote:
> hi janos,
>
> there are several possibilities:
>
> 1) declare a component parameter and pass in the variable
>
> 2) put it in a ASO and inject the ASO in all your components (using 
> @ApplicationState)
> the drawback is that any other page or component will be able to access 
> the ASO
>
> 3) put it into the Environment and read it whereever you need it in your 
> nested components.
> be careful when you put your object in your environment. if you put it in 
> during the action
> request it will not be able in the render request (because of the page 
> redirect).
>
> page:
>
> @Inject Environment env;
>
> @Persist("flash") whateverclass w;
>
> onActivate(w) {  this.w= w }
>
> setupRender() { env.push(whateverclass.class,w);}
>
> components:
>
> @Environmental Whateverclass var;
>
> 4) define a service that can take this variable (and saves it appropriatly 
> so it is not
> lost on a redirect:)) and inject your service in the components where 
> needed 
> to retrieve the value.
>
> maybe there are some more possibilities :)
>
> g,
> kris
>
>
>
>
> "János Jarecsni" <ja...@gmail.com> 
> 29.04.2008 08:15
> Bitte antworten an
> "Tapestry users" <us...@tapestry.apache.org>
>
>
> An
> "Tapestry users" <us...@tapestry.apache.org>
> Kopie
>
> Thema
> page activation + components
>
>
>
>
>
>
> Hi there,
>
> I have an activatable page, in its onActivate(String param) method I save
> the param to a normal instance variable of the page class (no 
> persistence!).
> How can any component embedded within this page access this variable?
>
> the page class:
>
> //...
> private String param;
>
> public void onActivate(String param) {
>    this.param = param;
> }
>
>
> public String getParam() {...}
>
>
> Thx in advance!
> Janos
>
>
>   

-- 
http://thegodcode.net


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


Re: page activation + components

Posted by Kristian Marinkovic <kr...@porsche.co.at>.
hi janos,

there are several possibilities:

1) declare a component parameter and pass in the variable

2) put it in a ASO and inject the ASO in all your components (using 
@ApplicationState)
the drawback is that any other page or component will be able to access 
the ASO

3) put it into the Environment and read it whereever you need it in your 
nested components.
be careful when you put your object in your environment. if you put it in 
during the action
request it will not be able in the render request (because of the page 
redirect).

page:

@Inject Environment env;

@Persist("flash") whateverclass w;

onActivate(w) {  this.w= w }

setupRender() { env.push(whateverclass.class,w);}

components:

@Environmental Whateverclass var;

4) define a service that can take this variable (and saves it appropriatly 
so it is not
lost on a redirect:)) and inject your service in the components where 
needed 
to retrieve the value.

maybe there are some more possibilities :)

g,
kris




"János Jarecsni" <ja...@gmail.com> 
29.04.2008 08:15
Bitte antworten an
"Tapestry users" <us...@tapestry.apache.org>


An
"Tapestry users" <us...@tapestry.apache.org>
Kopie

Thema
page activation + components






Hi there,

I have an activatable page, in its onActivate(String param) method I save
the param to a normal instance variable of the page class (no 
persistence!).
How can any component embedded within this page access this variable?

the page class:

//...
private String param;

public void onActivate(String param) {
   this.param = param;
}


public String getParam() {...}


Thx in advance!
Janos