Re: Properties persisted (compulsorily?) in the session
This is a leaky abstraction around the fact that pages are pooled. They are just too expensive to reconstruct fresh each request, and there's a lot of opportunities for optimizations that occur because the pages are pooled and re-used. On Thu, Mar 25, 2010 at 11:09 AM, Juan Isern wrote: > > Thank you guys for your answers... now I can see it pretty clearer :) > > I was blundering really bad! > > Best, Juan > > > > Howard Lewis Ship wrote: >> >> Actually, what's happening here is that the result of invoking new >> Service() is being stored with the page instance and used to reset the >> service field to its default value at the end of each request. >> >> This isn't quite the same as storing it in the session, as the Service >> instance will be carried with the page and used by multiple >> *different* clients. In this way, data can bleed from one client to >> another. >> >> On Thu, Mar 25, 2010 at 5:07 AM, Juan Isern wrote: >>> >>> Hi guys, I hope you're doing great. >>> >>> I'm pretty new to Tapestry and I'm having some trouble with forms. >>> >>> It turns out that when some field of a form (e.g. a textfield) references >>> some property that's accessed by a dot notation (I mean, it's not a >>> simple >>> page property but a property that belongs to a model object which in turn >>> is >>> owned by the page) it doesn't clear its value when, for instance, I hit >>> refresh. Just as if it were persisted in the session. >>> >>> Simple properties are working okay. >>> >>> This is the code: >>> >>> public class ServicePublication { >>> �...@property >>> private Service service = new Service(); >>> �...@property >>> private String vanillaProperty; >>> >>> "service" here seems to be in the session whereas vanillaProperty behaves >>> normally. >>> >>> I understand there may be some rationale behind this but I'd like to be >>> able >>> to control it, in this case I want to work with a fresh Service instance >>> every time the form is submitted. Does anyone know about a workaround for >>> this issue? >>> >>> I'll appreciate your thoughts. >>> -- >>> View this message in context: >>> http://old.nabble.com/Properties-persisted-%28compulsorily-%29-in-the-session-tp28027934p28027934.html >>> Sent from the Tapestry - User mailing list archive at Nabble.com. >>> >>> >>> - >>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org >>> For additional commands, e-mail: users-h...@tapestry.apache.org >>> >>> >> >> >> >> -- >> Howard M. Lewis Ship >> >> Creator of Apache Tapestry >> >> The source for Tapestry training, mentoring and support. Contact me to >> learn how I can get you up and productive in Tapestry fast! >> >> (971) 678-5210 >> http://howardlewisship.com >> >> - >> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org >> For additional commands, e-mail: users-h...@tapestry.apache.org >> >> >> > > -- > View this message in context: > http://old.nabble.com/Properties-persisted-%28compulsorily-%29-in-the-session-tp28027934p28032812.html > Sent from the Tapestry - User mailing list archive at Nabble.com. > > > - > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > -- Howard M. Lewis Ship Creator of Apache Tapestry The source for Tapestry training, mentoring and support. Contact me to learn how I can get you up and productive in Tapestry fast! (971) 678-5210 http://howardlewisship.com - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Properties persisted (compulsorily?) in the session
Thank you guys for your answers... now I can see it pretty clearer :) I was blundering really bad! Best, Juan Howard Lewis Ship wrote: > > Actually, what's happening here is that the result of invoking new > Service() is being stored with the page instance and used to reset the > service field to its default value at the end of each request. > > This isn't quite the same as storing it in the session, as the Service > instance will be carried with the page and used by multiple > *different* clients. In this way, data can bleed from one client to > another. > > On Thu, Mar 25, 2010 at 5:07 AM, Juan Isern wrote: >> >> Hi guys, I hope you're doing great. >> >> I'm pretty new to Tapestry and I'm having some trouble with forms. >> >> It turns out that when some field of a form (e.g. a textfield) references >> some property that's accessed by a dot notation (I mean, it's not a >> simple >> page property but a property that belongs to a model object which in turn >> is >> owned by the page) it doesn't clear its value when, for instance, I hit >> refresh. Just as if it were persisted in the session. >> >> Simple properties are working okay. >> >> This is the code: >> >> public class ServicePublication { >> �...@property >> private Service service = new Service(); >> �...@property >> private String vanillaProperty; >> >> "service" here seems to be in the session whereas vanillaProperty behaves >> normally. >> >> I understand there may be some rationale behind this but I'd like to be >> able >> to control it, in this case I want to work with a fresh Service instance >> every time the form is submitted. Does anyone know about a workaround for >> this issue? >> >> I'll appreciate your thoughts. >> -- >> View this message in context: >> http://old.nabble.com/Properties-persisted-%28compulsorily-%29-in-the-session-tp28027934p28027934.html >> Sent from the Tapestry - User mailing list archive at Nabble.com. >> >> >> - >> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org >> For additional commands, e-mail: users-h...@tapestry.apache.org >> >> > > > > -- > Howard M. Lewis Ship > > Creator of Apache Tapestry > > The source for Tapestry training, mentoring and support. Contact me to > learn how I can get you up and productive in Tapestry fast! > > (971) 678-5210 > http://howardlewisship.com > > - > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > > -- View this message in context: http://old.nabble.com/Properties-persisted-%28compulsorily-%29-in-the-session-tp28027934p28032812.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Properties persisted (compulsorily?) in the session
Actually, what's happening here is that the result of invoking new Service() is being stored with the page instance and used to reset the service field to its default value at the end of each request. This isn't quite the same as storing it in the session, as the Service instance will be carried with the page and used by multiple *different* clients. In this way, data can bleed from one client to another. On Thu, Mar 25, 2010 at 5:07 AM, Juan Isern wrote: > > Hi guys, I hope you're doing great. > > I'm pretty new to Tapestry and I'm having some trouble with forms. > > It turns out that when some field of a form (e.g. a textfield) references > some property that's accessed by a dot notation (I mean, it's not a simple > page property but a property that belongs to a model object which in turn is > owned by the page) it doesn't clear its value when, for instance, I hit > refresh. Just as if it were persisted in the session. > > Simple properties are working okay. > > This is the code: > > public class ServicePublication { > �...@property > private Service service = new Service(); > �...@property > private String vanillaProperty; > > "service" here seems to be in the session whereas vanillaProperty behaves > normally. > > I understand there may be some rationale behind this but I'd like to be able > to control it, in this case I want to work with a fresh Service instance > every time the form is submitted. Does anyone know about a workaround for > this issue? > > I'll appreciate your thoughts. > -- > View this message in context: > http://old.nabble.com/Properties-persisted-%28compulsorily-%29-in-the-session-tp28027934p28027934.html > Sent from the Tapestry - User mailing list archive at Nabble.com. > > > - > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > -- Howard M. Lewis Ship Creator of Apache Tapestry The source for Tapestry training, mentoring and support. Contact me to learn how I can get you up and productive in Tapestry fast! (971) 678-5210 http://howardlewisship.com - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Properties persisted (compulsorily?) in the session
Thanks, Thiago. I'm glad to have helped Juan and that my answer was "absolutely correct". ;-) Atenciosamente, Matheus Eduardo Machado Moreira matheus@gmail.com "Violence is the last refuge of the incompetent." Salvor Hardin (The Foundation, Isaac Asimov) 2010/3/25 Thiago H. de Paula Figueiredo > On Thu, 25 Mar 2010 09:27:21 -0300, Matheus Eduardo Machado Moreira < > matheus@gmail.com> wrote: > >Hi, folks. I'm just learning Tapestry too but I want to participate in >> the list. :-) >> > > Welcome to this list, Matheus! > > >Juan, I don't know much about Tapestry (yet!) but if I'm not mistaken >> that declaration of your service isn't adequate. >> > > Absolutely correct. It isn't adequate because every field that hasn't > annotations (except @Property), after a request, is set to its initial value > (the one defined in its declaration). In your code, the field always point > to the same Service object. It isn't in the session: actually, it's shared > by all users that use that specific page instance. Tapestry page instances > are pooled. Read more about the pool in the "Principle 1 -- Static > Structure, Dynamic Behavior" session of > http://tapestry.apache.org/tapestry5.1/. > > > You should use a method to handle the "activate" event and there >> initialize your property: >> > > Or some rendering event handler, like @SetupRender. > > -- > Thiago H. de Paula Figueiredo > Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, > and instructor > Owner, software architect and developer, 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 persisted (compulsorily?) in the session
On Thu, 25 Mar 2010 09:27:21 -0300, Matheus Eduardo Machado Moreira wrote: Hi, folks. I'm just learning Tapestry too but I want to participate in the list. :-) Welcome to this list, Matheus! Juan, I don't know much about Tapestry (yet!) but if I'm not mistaken that declaration of your service isn't adequate. Absolutely correct. It isn't adequate because every field that hasn't annotations (except @Property), after a request, is set to its initial value (the one defined in its declaration). In your code, the field always point to the same Service object. It isn't in the session: actually, it's shared by all users that use that specific page instance. Tapestry page instances are pooled. Read more about the pool in the "Principle 1 -- Static Structure, Dynamic Behavior" session of http://tapestry.apache.org/tapestry5.1/. You should use a method to handle the "activate" event and there initialize your property: Or some rendering event handler, like @SetupRender. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, software architect and developer, 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 persisted (compulsorily?) in the session
Hi, folks. I'm just learning Tapestry too but I want to participate in the list. :-) Juan, I don't know much about Tapestry (yet!) but if I'm not mistaken that declaration of your service isn't adequate. You should use a method to handle the "activate" event and there initialize your property: @Property private Service service; public void onActivate() { this.service = new Service(); } Good luck! And I'm looking for learning a lot about Tapestry. Atenciosamente, Matheus Eduardo Machado Moreira matheus@gmail.com "Violence is the last refuge of the incompetent." Salvor Hardin (The Foundation, Isaac Asimov) 2010/3/25 Juan Isern > > Hi guys, I hope you're doing great. > > I'm pretty new to Tapestry and I'm having some trouble with forms. > > It turns out that when some field of a form (e.g. a textfield) references > some property that's accessed by a dot notation (I mean, it's not a simple > page property but a property that belongs to a model object which in turn > is > owned by the page) it doesn't clear its value when, for instance, I hit > refresh. Just as if it were persisted in the session. > > Simple properties are working okay. > > This is the code: > > public class ServicePublication { >@Property >private Service service = new Service(); >@Property >private String vanillaProperty; > > "service" here seems to be in the session whereas vanillaProperty behaves > normally. > > I understand there may be some rationale behind this but I'd like to be > able > to control it, in this case I want to work with a fresh Service instance > every time the form is submitted. Does anyone know about a workaround for > this issue? > > I'll appreciate your thoughts. > -- > View this message in context: > http://old.nabble.com/Properties-persisted-%28compulsorily-%29-in-the-session-tp28027934p28027934.html > Sent from the Tapestry - User mailing list archive at Nabble.com. > > > - > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > >
Properties persisted (compulsorily?) in the session
Hi guys, I hope you're doing great. I'm pretty new to Tapestry and I'm having some trouble with forms. It turns out that when some field of a form (e.g. a textfield) references some property that's accessed by a dot notation (I mean, it's not a simple page property but a property that belongs to a model object which in turn is owned by the page) it doesn't clear its value when, for instance, I hit refresh. Just as if it were persisted in the session. Simple properties are working okay. This is the code: public class ServicePublication { @Property private Service service = new Service(); @Property private String vanillaProperty; "service" here seems to be in the session whereas vanillaProperty behaves normally. I understand there may be some rationale behind this but I'd like to be able to control it, in this case I want to work with a fresh Service instance every time the form is submitted. Does anyone know about a workaround for this issue? I'll appreciate your thoughts. -- View this message in context: http://old.nabble.com/Properties-persisted-%28compulsorily-%29-in-the-session-tp28027934p28027934.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org