Thanks! So how would such a ThreadLocal example look like ?
The problem with the Visit object is that is should not be created until it is really necessary.... > --- Urspr�ngliche Nachricht --- > Von: Pablo Ruggia <[EMAIL PROTECTED]> > An: Tapestry users <[email protected]> > Betreff: Re: BasePage, BaseComponent and thread issues with database > queries > Datum: Sat, 28 May 2005 14:45:06 -0300 > > On 5/28/05, [EMAIL PROTECTED] > <[EMAIL PROTECTED]> wrote: > > Hello everyone! > > > > Both all my pages and components need to perform the same database > queries > > where client specific stuff (language, country) determines how they are > > rendered. > > > > (a) would it be a good idea to do everything in BasePage and let > > BaseComponent do a getPage() and then call all methods on there ? > > Personally i don't use pages to do my logic. I'd rather use my > Business Layer. Anyway, depends on you, it's a design issue. If you > use a logic from many components, then put that logic in the page. If > you use the logic from one or to components, let's put that logic in > the page. > > > (b) imagine there are 10 possible groups of users and 10 possible kinds > of > > sql queries for all users/visitors. These are never changing, so where > and > > how would I cache those queries, > > You can put that cach� in many places. Can be a map in the Global. > Perhaps in your database. > > > (c) is it correct that instance variables within page classes are > forbidden? > > > > e.g. > > > > Something something = null; > > > > public Something getSomething(){ > > if (something!=null) { > > return something; > > } > > else { > > something=getFromDatabase(clientSpecificParameters), > > return someting ? > > } > > } > > > > Would that be threadsafe? Or would users get random data belonging to > other > > users? > > It's thread safe. But it will NOT WORK. The same user for different > request can get different Page instances. And different users can get > the same page instance. > It's better to cache that thigs out of Page classes, and get those > things from Visit, Global, ThreadLocal variables, or whatever you want > to use. > > > > > > Thanks! > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
