You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Sam <bl...@yahoo.com.hk> on 2005/03/30 16:08:55 UTC

How can my Visit to get the Global object?

Dear all,
I am the beignner of tapestry..

Is there are any way that my Visit can get the Global object??
Because my Visit object cannot access the global object without new it..

Sam.


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


Re: How can my Visit to get the Global object?

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
One way to do this is to override BaseEngine.createVisit to construct 
your Visit passing Global (from getGlobal()) to it's constructor or 
setter.  Be sure to set your custom engine class in your .application 
file.

	Erik

On Mar 30, 2005, at 9:08 AM, Sam wrote:

> Dear all,
> I am the beignner of tapestry..
>
> Is there are any way that my Visit can get the Global object??
> Because my Visit object cannot access the global object without new 
> it..
>
> Sam.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


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


Re: How can my Visit to get the Global object?

Posted by Kent Tong <ke...@cpttm.org.mo>.
Sam <blksamleung <at> yahoo.com.hk> writes:

> Dear all,
> I am the beignner of tapestry..
> 
> Is there are any way that my Visit can get the Global object??
> Because my Visit object cannot access the global object without new it..

While there are solutions to this problem (like Erik's), I'd
like to suggest that you store data in your Visit object only.
If you need processing logic, you should put it somewhere
else (eg, in Global) and pass the data contained in the Visit 
object to it:

class Global {
  void someProcessing(User user) {
    ...
  }
}

Call it like:

void someListener(IRequestCycle cycle) {
  ((Global)getGlobal()).someProcessing(((Visit)getVisit()).getUser());
}


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