Thanks, that would solve a problem
2005/9/19, Muralidhar Y. <[EMAIL PROTECTED]>: > > Try also with this and see. There is a method " protected void finishLoad()" > in AbstractComponent and also "finishLoad(IRequestCycle, IPageLoader, > IComponentSpecification)". Both the methods are in the same class. > > finishLoad() will be internally called by finishLoad(IRequestCycle, > IPageLoader, IComponentSpecification). Use one of the method for your > initalization and check. I hope this should work out. > > > Muralidhar Y > Software Engineer, > Adastrum technologies-Nikai groups, > EmiratesGroup-I.T Division, > Dubai, UAE. > Mobile : 00971-50-2256149. > http://www.adastrumtech.com > http://www.mercator.aero > (Keep Smiling. Be happy All The Time.) > > -----Original Message----- > From: Tomáš Drencák [mailto:[EMAIL PROTECTED] > Sent: 18 September 2005 18:42 > To: Tapestry users > Subject: Re: jwc files and annotations > > But again... > > public abstract Collection getCollection(); public abstract void > setCollection(Collection col); > > public abstract Integer getCollectionId(); public abstract void > setCollectionId(Integer id); > > @InjectObject("service:someService") > public abstract SomeService getSomeService(); > > public void pageBeginRender(PageEvent) { > if(getCollection() == null) { > setCollection(getSomeService().getCollectionById()); > } > } > > @Component(type="contrib:Table", bindings={"source=collection", > "columns=name, type"}) public abstract Table getTable(); > > This is my problem: I have collection identifier. Service methods returns > collection by it's identifier. But I can't sort that collection (on page, > clicking on column), because contrib:Table sorting listener needs collection > to be not null, but initialization appears after triggering listener. So > initialization of collection should be done as soon as possible in request > but before listener method... > > 2005/9/18, Muralidhar Y. <[EMAIL PROTECTED]>: > > I could not understand clearly but one thing is for sure if you can do > > something with intialize method the same thing could be done with > > detach method. Look at the following examples:- still not solved mail > back. > > > > One approach:- > > > > public class aa extends BasePage > > { > > ArrayList arraylist; > > > > public void someMethod() > > { > > // did some thing with arraylist and changed > > the value. > > } > > public void detach() > > { > > super.detach(); > > arraylist=null; > > } > > > > } > > > > > > Second Approach:- > > > > public class aa extends BasePage implements PageRenderListener > > { > > ArrayList arraylist; > > > > public void initialization() > > { > > arrayList=new ArrayList(); > > } > > > > public void pageBeginRender(PageEvent event) > > { > > initialization(); > > // other part of the code goes here. > > > > } > > > > public void detach() > > { > > super.detach(); > > initialization(); > > } > > > > } > > > > > > Third Approach(you said something like you want to change with every > > request so I consider you are taking something from IRequestCycle):- > > > > public class aa extends BasePage implements PageRenderListener > > { > > ArrayList arrayList; > > > > public void initialization(IrequestCycle cycle) > > { > > arrayList=cycle.getAttribute("name") ; > > } > > > > public void pageBeginRender(PageEvent event) > > { > > initialization(getRequestCycle()); > > // other part of the code goes here. > > > > } > > > > public void detach() > > { > > super.detach(); > > arrayList=null; > > } > > > > } > > > > documentation of detach method:- > > > > detach > > public void detach()Prepares the page to be returned to the pool. > > Clears the changeObserved property > > Invokes PageDetachListener.pageDetached(PageEvent) on all listeners > > Invokes initialize() to clear/reset any properties Clears the engine, > > visit and requestCycle properties Subclasses may override this method, > > but must invoke this implementation (usually, last). > > > > > > Specified by: > > detach in interface IPage > > See Also: > > IPageSource.releasePage(IPage) > > > > Muralidhar Y > > Software Engineer, > > Adastrum technologies-Nikai groups, > > EmiratesGroup-I.T Division, > > Dubai, UAE. > > Mobile : 00971-50-2256149. > > http://www.adastrumtech.com > > http://www.mercator.aero > > (Keep Smiling. Be happy All The Time.) > > > > -----Original Message----- > > From: Tomáš Drencák [mailto:[EMAIL PROTECTED] > > Sent: 17 September 2005 23:25 > > To: Tapestry users > > Subject: Re: jwc files and annotations > > > > Yes you're right, but what if I'd like to initialize properties to non > > default values specific for each request. For instance I will get > > identifier into persistent (userId) property in page and want some > > method to initialize non persistent property (user). > > > > 2005/9/17, Muralidhar Y. <[EMAIL PROTECTED]>: > > > > > > > > > Hi actually what I mean to say is by using detach method we can > > > achieve the same thing. For example without initializing variables > > > in initialize method you initialize them directly and set them to > > > initial values in detach method. So when you initialize them > > > directly they will be initialized and when going to the pool after > > > the request, the detach method is called . So in detach method again > > > you initialize them to initial values so when they go to pool they > > > will have initial > > values only. That's what I mean to say. > > > > > > In detach method we can detach the variable values and can > > > initialize them to initial values. But when writing detach method > > > you have to call > > > super.detach() also. Is my explanation clear now or shall I explain > > > with small example. > > > > > > One more approach is you write your own method something like > > > Initialize and initialize the variables in that method and write the > > > detach method and call > > > super.detach() first and then call your method which is initializing > > > the values. It does the same job as the old initialize method. > > > > > > > > > Muralidhar Y > > > Software Engineer, > > > Adastrum technologies-Nikai groups, > > > EmiratesGroup-I.T Division, > > > Dubai, UAE. > > > Mobile : 00971-50-2256149. > > > http://www.adastrumtech.com > > > http://www.mercator.aero > > > (Keep Smiling. Be happy All The Time.) > > > > > > -----Original Message----- > > > From: Tomáš Drencák [mailto:[EMAIL PROTECTED] > > > Sent: 17 September 2005 21:39 > > > To: Tapestry users > > > Subject: Re: jwc files and annotations > > > > > > Detach method is not deprecated, it shold be use to set properties > > > to their initial state not initialization. > > > > > > 2005/9/17, Muralidhar Y. <[EMAIL PROTECTED]>: > > > > What about detach method. Is it also depricated? i am not sure but > > > > have a look at detach method. It does the same job. > > > > > > > > > > > > Muralidhar Y > > > > Software Engineer, > > > > Adastrum technologies-Nikai groups, EmiratesGroup-I.T Division, > > > > Dubai, UAE. > > > > Mobile : 00971-50-2256149. > > > > http://www.adastrumtech.com > > > > http://www.mercator.aero > > > > (Keep Smiling. Be happy All The Time.) > > > > > > > > -----Original Message----- > > > > From: Nick Stuart [mailto:[EMAIL PROTECTED] > > > > Sent: 17 September 2005 16:32 > > > > To: Tapestry users; [EMAIL PROTECTED] > > > > Subject: Re: jwc files and annotations > > > > > > > > In tapestry 4 you should use the pageBeginRender method and > > > > implement the PageBeginRenderListener. You should be able to > > > > initialize any page properties you want here. > > > > > > > > There is also a coresponding pageEndRender and > > > > PageEndRenderListener but I dont think its used quite as much, but its > there. > > > > > > > > -Nick > > > > > > > > On 9/17/05, Tomáš Drenčák <[EMAIL PROTECTED]> wrote: > > > > > Yes initialize method is good and even its name sounds like it's > > > > > initializing smth. I have used it in tapestry 3 but now it is > > > > > deprecated. Is there an alternative method to initialize? > > > > > > > > > > 2005/9/17, Muralidhar Y. <[EMAIL PROTECTED]>: > > > > > > > > > > > > hi some times I got error when I am not passing IRequestCycle > > > > > > as parameter to listener method. > > > > > > > > > > > > To initialize the parameters there is initialize method you > > > > > > also can have a look at detach method and see.page begin > > > > > > render is , if you want to do something before any component > renders itself. > > > > > > Page validate is if you want to do any validations like user > > > > > > is authenticated or not and any other page validations you can use > it. > > > > > > > > > > > > > > > > > > Muralidhar Y > > > > > > Software Engineer, > > > > > > Adastrum technologies-Nikai groups, EmiratesGroup-I.T > > > > > > Division, Dubai, UAE. > > > > > > Mobile : 00971-50-2256149. > > > > > > http://www.adastrumtech.com > > > > > > http://www.mercator.aero > > > > > > (Keep Smiling. Be happy All The Time.) > > > > > > > > > > > > -----Original Message----- > > > > > > From: Alan Chandler [mailto:[EMAIL PROTECTED] > > > > > > Sent: 16 September 2005 22:49 > > > > > > To: [email protected] > > > > > > Subject: Re: jwc files and annotations > > > > > > > > > > > > On Friday 16 September 2005 18:29, Tomáš Drenčák wrote: > > > > > > > Thanks a lot. > > > > > > > > > > > > > > Another question... You are using pageValidate to set up > > > > > > > thisPerson property. I'm still little bit confused about > > > > > > > page > > > > initialization. > > > > > > > What are pageBeginRender, pageValidate and prepareForRender for? > > > > > > > Where to initialize e.g. thisPerson from passed personId > > > > > > > parameter? I've used pageBeginRender, lazy initialization, > > > > > > > but which method is specially designed for this purpose? > > > > > > > > > > > > > > > > > > I must admit, this was a bit trial and error. > > > > > > > > > > > > I pass the personId parameter via the following code in > > > > > > another > > > > component. > > > > > > > > > > > > > > > > > > @InjectPage("Details") > > > > > > public abstract Details getDetailsPage(); > > > > > > > > > > > > public IPage doShowDetails(int personId) { > > > > > > Details details = getDetailsPage(); > > > > > > details.setPersonId(personId); > > > > > > return details; > > > > > > } > > > > > > } > > > > > > > > > > > > Where this code gets set up in the html template for this > > > > > > component as > > > > > > > > > > > > <div class="surname"> > > > > > > <span jwcid="@DirectLink" > > > > > > listener="listener:doShowDetails" > > > > > > parameters="ognl:person.id" > > > > > > ><span jwcid="@Insert" > > > > > > value="ognl:person.surname" > > > > > > >Chandler</span></span> </div> > > > > > > > > > > > > > > > > > > I think PageBeginRender failed (thinking back to when I > > > > > > orginally had > > > > it > > > > > > here) because there seems to be a validation phase of the page > > > > > > before > > > > then, > > > > > > and I had not set up the record, and had null pointer exceptions. > > > > > > > > > > > > I think the page initialisation failed because the setPersonId > > > > > > call > > > > hadn't > > > > > > happened (maybe - difficult to remember now) the > > > > > > initialisation got > > > > called > > > > > > when I did the first call to getDetailsPage in the listener above. > > > > > > > > > > > > -- > > > > > > Alan Chandler > > > > > > http://www.chandlerfamily.org.uk > > > > > > > > > > > > -------------------------------------------------------------- > > > > > > -- > > > > > > -- > > > > > > --- To unsubscribe, e-mail: > > > > > > [EMAIL PROTECTED] > > > > > > For additional commands, e-mail: > > > > > > [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
