Re: properties not persisting across requests
On Wed, 14 Sep 2011 17:53:38 -0300, Josh Canfield wrote: Hey Thiago. Hi, Josh! You can't use @Component and declare the component in the template at the> same time. One or other, not both. I don't understand what you mean by this. You have to have the component in the template, you can leave off the t:type though. Well, I should have said that you shouldn't use @Component and component definition parameters for *the same component instance at the same time* instead of you can't. If you use @Component, you're at least supposed to define the component type and parameters in the annotation itself, leaving just the t:id in the template. Defining parameters for the same component instance in two different places is a recipe for confusion. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: properties not persisting across requests
Hey Thiago. > You can't use @Component and declare the component in the template at the > same time. One or other, not both. I don't understand what you mean by this. You have to have the component in the template, you can leave off the t:type though. Josh On Wed, Sep 14, 2011 at 1:27 PM, Thiago H. de Paula Figueiredo wrote: > On Wed, 14 Sep 2011 16:40:51 -0300, Ken in Nashua wrote: > >> Hey thanks Thiago... > > Hi! > >> @Component(parameters = {"clientId=itemsPerPageSelect"}) >> private Select itemsPerPageSelect; > > You can't use @Component and declare the component in the template at the > same time. One or other, not both. > >> public Object onActionFromItemsPerPageSelect() >> { >> logger.info("In itemsPerPageChangeListener : "); >> } > > Select doesn't trigger an "action" event, so your method will never be > invoked. Check the Select documentation to know what events it triggers and > when: > http://tapestry.apache.org/current/tapestry-core/ref/org/apache/tapestry5/corelib/components/Select.html. > Instead, handle the success event of the Form surrounding the Select > component. > > -- > Thiago H. de Paula Figueiredo > Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and > instructor > Owner, Ars Machina Tecnologia da Informação Ltda. > http://www.arsmachina.com.br > > - > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
RE: properties not persisting across requests
Hey thanks Thiago... that worked nicely... just what I needed... for initialization... still figuring out the refresh logic... Items Per Page @Persist("session") @Property(read = true, write = true) private int itemsPerPage; @Component(parameters = {"clientId=itemsPerPageSelect"}) private Select itemsPerPageSelect; public Object onActionFromItemsPerPageSelect() { logger.info("In itemsPerPageChangeListener : "); } I got the gallery items editing now too on click... and just wired up the handlers... Kinda stuck on the onchange handler for the select control though... I dont know how to get a breakpoint to happen at the handler. Any ideas? I tried several variations of handler right on th emethod as follows without luck... //@OnEvent(value = "action", component = "select") //@OnEvent(value = "itemsPerPageChange", component = "itemsPerPageSelect") //@EventListener(events = //{ "onchange" }, targets = //{ "itemsPerPageSelect" }, submitForm = "galleryForm", async = true) When I am done with this I will post it and see who can soup this gallery up further... I got entity object rendering already... just by specifying an entity class as the type. its looking like within th enext 14 days I will have something to share Thanks kcola...@live.com > To: users@tapestry.apache.org; kcola...@live.com > Subject: Re: properties not persisting across requests > Date: Wed, 14 Sep 2011 08:39:25 -0300 > From: thiag...@gmail.com > > On Wed, 14 Sep 2011 00:14:11 -0300, Ken in Nashua > wrote: > > > I need a default value in order to load my collection... otherwise this > > variable is interpreted as null or 0...depending on which type I use... > > Integer, String or int > > How would you set a default ? > > Use onActivate() or @BeginRender. > > -- > Thiago H. de Paula Figueiredo > Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, > and instructor > Owner, Ars Machina Tecnologia da Informação Ltda. > http://www.arsmachina.com.br
Re: properties not persisting across requests
On Wed, 14 Sep 2011 00:14:11 -0300, Ken in Nashua wrote: I need a default value in order to load my collection... otherwise this variable is interpreted as null or 0...depending on which type I use... Integer, String or int How would you set a default ? Use onActivate() or @BeginRender. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: properties not persisting across requests
It looks like you want 'itemsPerPage' to be a Parameter as well as being persisted. As @Parameter and @Persist cannot be placed on the same field one approach is to persis the field in the Page and pass it down to the Gallery component. The the code is then just as Robert says: Home.java @Property @Persist private int itemsPerPage; Home.tml Gallery.java: @Parameter(required=true, value="literal:50") @Property private int itemsPerPage Gallery.tml: Steve. On 14 September 2011 12:29, Ken in Nashua wrote: > > Well I got the gallery component wrapped in a form so I think I need to > probably actually perform a submit... > So I rigged up my handlers and did the submit... > > Still no luck... select keep reverting back to default on refresh > - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
RE: properties not persisting across requests
Well I got the gallery component wrapped in a form so I think I need to probably actually perform a submit... So I rigged up my handlers and did the submit... Still no luck... select keep reverting back to default on refresh
RE: properties not persisting across requests
@Persist("session") @Property(read = true, write = true) //@Parameter(required = true, cache = true, defaultPrefix = "50") private int itemsPerPage; This is what I have so far... Nothing gets persisted... blue in the face Any suggestions ? Thank You
Re: properties not persisting across requests
Home.java: @Property @Persist private int itemsPerPage; Gallery.java: @Parameter(required=true, cache=true, value="50") @Property private int itemsPerPage Gallery.tml: You've got "defaultPrefix" set as "50". Default prefix refers to the default interpretation of a bound value. The default defaultPrefix ;) is "prop". So when a user does: @Component(parameters={"itemsPerPage=50"}) private Gallery gallery; The value "50" would be handled by the property expression binding (which knows how to interpret integers). Other possible values are "literal" (the value is taken 'as is', possibly with type coercion), "message" (the value is interpreted as the key in the message catalog), or validate (the value is transformed into a field validator). So you definitely don't want "50" as the defaultPrefix. :) What you want is to set the default value. To set the default parameter value, either use the "default" method, in this case: int defaultItemsPerPage() { return 50; } Or else use the "value" attribute of the @Parameter annotation, as I did above. Robert On Sep 12, 2011, at 9/1211:51 PM , Ken in Nashua wrote: > > > Hi All, > > I have page Home and a component Gallery whereby the page contains the > component. > > So I tell the page to house a variable itemsPerPage so I can persist it into > the component and I rig the component so accommodate and retain the state of > this variable. > > Nothing get persisted or initialized and when I hit refresh any values I set > on the select control get wiped out. > > Are there limitation to using String, int, Integer ? > > Home.java >@Persist >@Property(read = true, write = true) >//@Parameter(required = false, cache = true, defaultPrefix = "50") >private int itemsPerPage; > > Gallery.java >@Persist >//@Property(read = true, write = true) >//@Parameter(required = true, cache = true, defaultPrefix = "50") >private int itemsPerPage; > >@Component(parameters = {"clientId=itemsPerPageSelect"}) >private Select itemsPerPageSelect; > >@OnEvent(value = "itemsPerPageChange", component = "select") >public Object onItemsPerPageChange() >{ >} > > nothing seems to work... ideally I would like to use Integer > > Gallery.tml >Items Per Page > > t:model="literal:5,10,15,25,50,100,250,500,1000,5000,1" >value="itemsPerPage" >defaultValue="50" >onchange="tapestry.form.refresh(this.form)" >/> > > I am having trouble with PERSIST, PROPERTY and PARAMETER... nomatter what > combinations I try with initialized value or not I produce every app > exception possible and if I do get it running... nothing gets persisted. > > Any help is appreciated. > Best Regards and thanks > Ken > > - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
RE: properties not persisting across requests
Well I got rid of defaults and ran it... My home page contains a gallery component I have a button rigged on my browser set to http://localhost:8080/Home I clock the launch button set to the above URL The page comes up... and I see the first element in the visible So I change the value of the to another... Then I re-click my browser button... (which I assume invokes a refresh) and the value reverts back to the first element in the instead of the one I set it to. Is this a bug ? I am using tap-5.3.0 Thanks
RE: properties not persisting across requests
Also wondered why @Parameter could not do the job... way I see it is components take parameters... and I wanted to adhere to that... but every time I hit refresh button I lose my state.
RE: properties not persisting across requests
Thanks Steve... I am trying that... There is no way to set default value though... Error persisting field Home:gallerywidget:itemsPerPage: Persistent fields may not be updated until after the page has finished loading. This may be due to a persistent field with a default value. The default value should be removed. I need a default value in order to load my collection... otherwise this variable is interpreted as null or 0...depending on which type I use... Integer, String or int How would you set a default ?
Re: properties not persisting across requests
Hi, Not sure what it is exactly you want to achieve, for there a lot of unnessacery annotations floating around in your code. To simply persist the int variable from the select, the following works fine: @Persist @Property private int itemsPerPage; Items Per Page Steve. On 13 September 2011 12:51, Ken in Nashua wrote: > > > Hi All, > > I have page Home and a component Gallery whereby the page contains the > component. > > So I tell the page to house a variable itemsPerPage so I can persist it into > the component and I rig the component so accommodate and retain the state of > this variable. > > Nothing get persisted or initialized and when I hit refresh any values I set > on the select control get wiped out. > > Are there limitation to using String, int, Integer ? > > Home.java > @Persist > @Property(read = true, write = true) > //@Parameter(required = false, cache = true, defaultPrefix = "50") > private int itemsPerPage; > > Gallery.java > @Persist > //@Property(read = true, write = true) > //@Parameter(required = true, cache = true, defaultPrefix = "50") > private int itemsPerPage; > > @Component(parameters = {"clientId=itemsPerPageSelect"}) > private Select itemsPerPageSelect; > > @OnEvent(value = "itemsPerPageChange", component = "select") > public Object onItemsPerPageChange() > { > } > > nothing seems to work... ideally I would like to use Integer > > Gallery.tml > Items Per Page > > t:model="literal:5,10,15,25,50,100,250,500,1000,5000,1" > value="itemsPerPage" > defaultValue="50" > onchange="tapestry.form.refresh(this.form)" > /> > > I am having trouble with PERSIST, PROPERTY and PARAMETER... nomatter what > combinations I try with initialized value or not I produce every app > exception possible and if I do get it running... nothing gets persisted. > > Any help is appreciated. > Best Regards and thanks > Ken > > - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
properties not persisting across requests
Hi All, I have page Home and a component Gallery whereby the page contains the component. So I tell the page to house a variable itemsPerPage so I can persist it into the component and I rig the component so accommodate and retain the state of this variable. Nothing get persisted or initialized and when I hit refresh any values I set on the select control get wiped out. Are there limitation to using String, int, Integer ? Home.java @Persist @Property(read = true, write = true) //@Parameter(required = false, cache = true, defaultPrefix = "50") private int itemsPerPage; Gallery.java @Persist //@Property(read = true, write = true) //@Parameter(required = true, cache = true, defaultPrefix = "50") private int itemsPerPage; @Component(parameters = {"clientId=itemsPerPageSelect"}) private Select itemsPerPageSelect; @OnEvent(value = "itemsPerPageChange", component = "select") public Object onItemsPerPageChange() { } nothing seems to work... ideally I would like to use Integer Gallery.tml Items Per Page I am having trouble with PERSIST, PROPERTY and PARAMETER... nomatter what combinations I try with initialized value or not I produce every app exception possible and if I do get it running... nothing gets persisted. Any help is appreciated. Best Regards and thanks Ken