Re: @Persist(session) field is null after AjaxRequest
https://issues.apache.org/jira/browse/TAPESTRY-2765 Andreas Andreou wrote: I tried this example (and some non-ajax permutations) and i indeed see different behavior with cookies enabled vs. disabled. If that's not expected, then a new issue should be raised in jira. On Fri, May 28, 2010 at 09:51, Paul Stanton p...@mapshed.com.au wrote: well, its worth discussing - the question being should tapestry work with cookies disabled. i did notice that the jsessionid param was being appended to the form's action however submitting said form had unexpected results. its no longer holding me up, but i have worked on apps where cookies are not an option (cross domain security etc) so i can imagine cases where it would be a serious issue for someone. the test case is there. p. Thiago H. de Paula Figueiredo wrote: On Fri, 28 May 2010 00:31:18 -0300, Paul Stanton p...@mapshed.com.au wrote: Surely this is a bug in t5 ... I disagree. HTTP is purely stateless. Session keeping is the container's (server) responsibility, not Tapestry's. With cookies disabled, the only way to find out what is the session is appending the ;jsessionid=xxx string to the URLs. This is done by HttpServletResponde.encodeURL(String url), which is indirectly invoked for every single link generated by Tapestry. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: @Persist(session) field is null after AjaxRequest
well, its worth discussing - the question being should tapestry work with cookies disabled. i did notice that the jsessionid param was being appended to the form's action however submitting said form had unexpected results. its no longer holding me up, but i have worked on apps where cookies are not an option (cross domain security etc) so i can imagine cases where it would be a serious issue for someone. the test case is there. p. Thiago H. de Paula Figueiredo wrote: On Fri, 28 May 2010 00:31:18 -0300, Paul Stanton p...@mapshed.com.au wrote: Surely this is a bug in t5 ... I disagree. HTTP is purely stateless. Session keeping is the container's (server) responsibility, not Tapestry's. With cookies disabled, the only way to find out what is the session is appending the ;jsessionid=xxx string to the URLs. This is done by HttpServletResponde.encodeURL(String url), which is indirectly invoked for every single link generated by Tapestry. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: @Persist(session) field is null after AjaxRequest
I tried this example (and some non-ajax permutations) and i indeed see different behavior with cookies enabled vs. disabled. If that's not expected, then a new issue should be raised in jira. On Fri, May 28, 2010 at 09:51, Paul Stanton p...@mapshed.com.au wrote: well, its worth discussing - the question being should tapestry work with cookies disabled. i did notice that the jsessionid param was being appended to the form's action however submitting said form had unexpected results. its no longer holding me up, but i have worked on apps where cookies are not an option (cross domain security etc) so i can imagine cases where it would be a serious issue for someone. the test case is there. p. Thiago H. de Paula Figueiredo wrote: On Fri, 28 May 2010 00:31:18 -0300, Paul Stanton p...@mapshed.com.au wrote: Surely this is a bug in t5 ... I disagree. HTTP is purely stateless. Session keeping is the container's (server) responsibility, not Tapestry's. With cookies disabled, the only way to find out what is the session is appending the ;jsessionid=xxx string to the URLs. This is done by HttpServletResponde.encodeURL(String url), which is indirectly invoked for every single link generated by Tapestry. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- Andreas Andreou - andy...@apache.org - http://blog.andyhot.gr Tapestry / Tacos developer Open Source / JEE Consulting - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
@Persist(session) field is null after AjaxRequest
Hi all, I'm making a few different types of ajax requests on my page, and a couple of fields on components and pages are annotated with @Persist(session). Some of the ajax requests are made via t:actionlink components, others are via Ajax.Requests I've constructed myself (via resources.createEventLink().toAbsoluteURI(). I've noticed that the value for the apparently persistent field is reset to null when the second type of ajax requests are made ... this may be because the actions point to different components as listeners. I thought that marking @Persist(session) would mean their values were stored in the HttpSession until session death or I specifically set the value to null, regardless of which component/class is handling the request ?? How do I achieve this if not by @Persist(session) ? - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: @Persist(session) field is null after AjaxRequest
On Thu, 27 May 2010 23:08:37 -0300, Paul Stanton p...@mapshed.com.au wrote: Hi all, Hi! I've noticed that the value for the apparently persistent field is reset to null when the second type of ajax requests are made ... this may be because the actions point to different components as listeners. How you noticed that? If it was through a debugger, you are looking at a field which access was replaced by method invocations, so its value may not be what you expect. I thought that marking @Persist(session) would mean their values were stored in the HttpSession until session death or I specifically set the value to null, That's exactly what happens. I guess you're misunderstanding something in your application. -- 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: @Persist(session) field is null after AjaxRequest
I've also tried with @SessionState with no luck. I'm imagining it's because one request goes to componentA (where the persistent field is) the other goes to componentB. The subsequent request to componentA reveals that the persistent field is reset. ie: 1. Ajax.Request to componentA via actionlink componentA.persistentField does not exist, initialised 2. Ajax.Request to componentA via actionlink componentA.persistentField exists 3. Ajax.Request to componentB via manually constructed must be what resets the state 4. Ajax.Request to componentA via actionlink componentA.persistentField does NOT exist (problem) What is responsible for evicting my session variable? Do I need to revert to HttpSession handling myself? Paul Stanton wrote: Hi all, I'm making a few different types of ajax requests on my page, and a couple of fields on components and pages are annotated with @Persist(session). Some of the ajax requests are made via t:actionlink components, others are via Ajax.Requests I've constructed myself (via resources.createEventLink().toAbsoluteURI(). I've noticed that the value for the apparently persistent field is reset to null when the second type of ajax requests are made ... this may be because the actions point to different components as listeners. I thought that marking @Persist(session) would mean their values were stored in the HttpSession until session death or I specifically set the value to null, regardless of which component/class is handling the request ?? How do I achieve this if not by @Persist(session) ? - 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: @Persist(session) field is null after AjaxRequest
Hi Thiago, please bare with me... I'm not imagining it. I'm guessing it's something to do with my manually created ajax request... I'm not inspecting via debugger, I'm testing the value of the field in code, ie: via @Persist(session) if (persistentField == null) LOG.debug(state reset); and via the @SessionState if (!persistentFieldExists) LOG.debug(state reset); please see other email for more info thanks. Thiago H. de Paula Figueiredo wrote: On Thu, 27 May 2010 23:08:37 -0300, Paul Stanton p...@mapshed.com.au wrote: Hi all, Hi! I've noticed that the value for the apparently persistent field is reset to null when the second type of ajax requests are made ... this may be because the actions point to different components as listeners. How you noticed that? If it was through a debugger, you are looking at a field which access was replaced by method invocations, so its value may not be what you expect. I thought that marking @Persist(session) would mean their values were stored in the HttpSession until session death or I specifically set the value to null, That's exactly what happens. I guess you're misunderstanding something in your application. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: @Persist(session) field is null after AjaxRequest
On Thu, 27 May 2010 23:32:38 -0300, Paul Stanton p...@mapshed.com.au wrote: Hi Thiago, Hi! please bare with me... I'm not imagining it. I'm guessing it's something to do with my manually created ajax request... Tapestry's session handling works the same regardless how the request was made. I'm not inspecting via debugger, I'm testing the value of the field in code, ie: via @Persist(session) if (persistentField == null) LOG.debug(state reset); I don't know if that's the case, but a persistent field from a given page is only accessible in the same page, even when some other page has a similar field. and via the @SessionState if (!persistentFieldExists) LOG.debug(state reset); Use @SessionState(create = false) instead and test for null. -- 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: @Persist(session) field is null after AjaxRequest
On Thu, 27 May 2010 23:26:13 -0300, Paul Stanton p...@mapshed.com.au wrote: I've also tried with @SessionState with no luck. Please post your code. Without it, it will be very hard to understand what's happening. I'm imagining it's because one request goes to componentA (where the persistent field is) the other goes to componentB. The subsequent request to componentA reveals that the persistent field is reset. ie: 1. Ajax.Request to componentA via actionlink componentA.persistentField does not exist, initialised 2. Ajax.Request to componentA via actionlink componentA.persistentField exists 3. Ajax.Request to componentB via manually constructed must be what resets the state If componentB state is completely independent of componentA state when using @Persist. In addition, if you have a component instance in one page and another in another page, their state is independent, because, ultimately, all @Persist handling is done per page. On the other hand, a @SessionState private Class1 class1; is one for the whole session. 4. Ajax.Request to componentA via actionlink componentA.persistentField does NOT exist (problem) What is responsible for evicting my session variable? Again, please post your code. Do I need to revert to HttpSession handling myself? Only if you need to interact with some non-Tapestry code that uses the session. -- 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: @Persist(session) field is null after AjaxRequest
I'm with Thiago, what you are describing doesn't make sense. It doesn't matter how you make the request the session stored attributes should still be there. Since it doesn't make sense I'll ask all the dumb question: Are you setting the value somewhere? If you have a setter for it try setting a breakpoint or add logging... -- Josh On May 27, 2010, at 7:32 PM, Paul Stanton p...@mapshed.com.au wrote: Hi Thiago, please bare with me... I'm not imagining it. I'm guessing it's something to do with my manually created ajax request... I'm not inspecting via debugger, I'm testing the value of the field in code, ie: via @Persist(session) if (persistentField == null) LOG.debug(state reset); and via the @SessionState if (!persistentFieldExists) LOG.debug(state reset); please see other email for more info thanks. Thiago H. de Paula Figueiredo wrote: On Thu, 27 May 2010 23:08:37 -0300, Paul Stanton p...@mapshed.com.au wrote: Hi all, Hi! I've noticed that the value for the apparently persistent field is reset to null when the second type of ajax requests are made ... this may be because the actions point to different components as listeners. How you noticed that? If it was through a debugger, you are looking at a field which access was replaced by method invocations, so its value may not be what you expect. I thought that marking @Persist(session) would mean their values were stored in the HttpSession until session death or I specifically set the value to null, That's exactly what happens. I guess you're misunderstanding something in your application. - 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: @Persist(session) field is null after AjaxRequest
Thiago, I tried with @SessionState(create=false) and the same occurs (testing the field for null). I also tried (as a sanity check) to inject HttpRequest and manage the session attribute manually. Interestingly, the session Id is changing! This must be the cause - somehow my manual Ajax.Request to a url derived from resources.createEventLink().toAbsoluteURI() is creating a new session p. Thiago H. de Paula Figueiredo wrote: On Thu, 27 May 2010 23:32:38 -0300, Paul Stanton p...@mapshed.com.au wrote: Hi Thiago, Hi! please bare with me... I'm not imagining it. I'm guessing it's something to do with my manually created ajax request... Tapestry's session handling works the same regardless how the request was made. I'm not inspecting via debugger, I'm testing the value of the field in code, ie: via @Persist(session) if (persistentField == null) LOG.debug(state reset); I don't know if that's the case, but a persistent field from a given page is only accessible in the same page, even when some other page has a similar field. and via the @SessionState if (!persistentFieldExists) LOG.debug(state reset); Use @SessionState(create = false) instead and test for null. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: @Persist(session) field is null after AjaxRequest
Actually, the 2nd request (which clears the session) is not a manually created Ajax.Request. Sorry for the confusion. It's actually a async form submit, and to simplify the issue somewhat every submit of this form prints a different sessionId: t:form t:id=someForm t:zone=someZone input t:type=TextField t:id=someInput / input type=submit value=search / /t:form @Inject private HttpServletRequest request; Object onSuccessFromSomeForm() { LOG.debug(onSuccessFromSomeForm + httpRequest.getSession().getId()); return null; } Surely that can't be correct? p. Paul Stanton wrote: Thiago, I tried with @SessionState(create=false) and the same occurs (testing the field for null). I also tried (as a sanity check) to inject HttpRequest and manage the session attribute manually. Interestingly, the session Id is changing! This must be the cause - somehow my manual Ajax.Request to a url derived from resources.createEventLink().toAbsoluteURI() is creating a new session p. Thiago H. de Paula Figueiredo wrote: On Thu, 27 May 2010 23:32:38 -0300, Paul Stanton p...@mapshed.com.au wrote: Hi Thiago, Hi! please bare with me... I'm not imagining it. I'm guessing it's something to do with my manually created ajax request... Tapestry's session handling works the same regardless how the request was made. I'm not inspecting via debugger, I'm testing the value of the field in code, ie: via @Persist(session) if (persistentField == null) LOG.debug(state reset); I don't know if that's the case, but a persistent field from a given page is only accessible in the same page, even when some other page has a similar field. and via the @SessionState if (!persistentFieldExists) LOG.debug(state reset); Use @SessionState(create = false) instead and test for null. - 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: @Persist(session) field is null after AjaxRequest
Here is a concrete example which I've constructed separate to the rest of my app to exclude any quirks intruduced by it's complexity: public class Start { private final static Logger LOG = Logger.getLogger(Start.class); @Inject private ComponentResources resources; @Inject @Property private HttpServletRequest httpRequest; Object onSuccessFromMyForm() { LOG.debug(httpRequest.getSession().getId()); return new MultiZoneUpdate(myZone, resources.getEmbeddedComponent(myZone)); } } --- !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd; html xmlns:t=http://tapestry.apache.org/schema/tapestry_5_1_0.xsd; xmlns:p=tapestry:parameter head /head body t:form t:id=myForm t:zone=myZone input type=submit / /t:form t:zone t:id=myZone ${httpRequest.session.id} /t:zone /body /html -- Paul Stanton wrote: Actually, the 2nd request (which clears the session) is not a manually created Ajax.Request. Sorry for the confusion. It's actually a async form submit, and to simplify the issue somewhat every submit of this form prints a different sessionId: t:form t:id=someForm t:zone=someZone input t:type=TextField t:id=someInput / input type=submit value=search / /t:form @Inject private HttpServletRequest request; Object onSuccessFromSomeForm() { LOG.debug(onSuccessFromSomeForm + httpRequest.getSession().getId()); return null; } Surely that can't be correct? p. Paul Stanton wrote: Thiago, I tried with @SessionState(create=false) and the same occurs (testing the field for null). I also tried (as a sanity check) to inject HttpRequest and manage the session attribute manually. Interestingly, the session Id is changing! This must be the cause - somehow my manual Ajax.Request to a url derived from resources.createEventLink().toAbsoluteURI() is creating a new session p. Thiago H. de Paula Figueiredo wrote: On Thu, 27 May 2010 23:32:38 -0300, Paul Stanton p...@mapshed.com.au wrote: Hi Thiago, Hi! please bare with me... I'm not imagining it. I'm guessing it's something to do with my manually created ajax request... Tapestry's session handling works the same regardless how the request was made. I'm not inspecting via debugger, I'm testing the value of the field in code, ie: via @Persist(session) if (persistentField == null) LOG.debug(state reset); I don't know if that's the case, but a persistent field from a given page is only accessible in the same page, even when some other page has a similar field. and via the @SessionState if (!persistentFieldExists) LOG.debug(state reset); Use @SessionState(create = false) instead and test for null. - 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 - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: @Persist(session) field is null after AjaxRequest
Sorry guys, I found the problem. I had disabled cookies on the webapp. Surely this is a bug in t5 ... in that with cookies disabled, an ajax form submit acquires a new session every time? Regards, p. Paul Stanton wrote: Here is a concrete example which I've constructed separate to the rest of my app to exclude any quirks intruduced by it's complexity: public class Start { private final static Logger LOG = Logger.getLogger(Start.class); @Inject private ComponentResources resources; @Inject @Property private HttpServletRequest httpRequest; Object onSuccessFromMyForm() { LOG.debug(httpRequest.getSession().getId()); return new MultiZoneUpdate(myZone, resources.getEmbeddedComponent(myZone)); } } --- !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd; html xmlns:t=http://tapestry.apache.org/schema/tapestry_5_1_0.xsd; xmlns:p=tapestry:parameter head /head body t:form t:id=myForm t:zone=myZone input type=submit / /t:form t:zone t:id=myZone ${httpRequest.session.id} /t:zone /body /html -- Paul Stanton wrote: Actually, the 2nd request (which clears the session) is not a manually created Ajax.Request. Sorry for the confusion. It's actually a async form submit, and to simplify the issue somewhat every submit of this form prints a different sessionId: t:form t:id=someForm t:zone=someZone input t:type=TextField t:id=someInput / input type=submit value=search / /t:form @Inject private HttpServletRequest request; Object onSuccessFromSomeForm() { LOG.debug(onSuccessFromSomeForm + httpRequest.getSession().getId()); return null; } Surely that can't be correct? p. Paul Stanton wrote: Thiago, I tried with @SessionState(create=false) and the same occurs (testing the field for null). I also tried (as a sanity check) to inject HttpRequest and manage the session attribute manually. Interestingly, the session Id is changing! This must be the cause - somehow my manual Ajax.Request to a url derived from resources.createEventLink().toAbsoluteURI() is creating a new session p. Thiago H. de Paula Figueiredo wrote: On Thu, 27 May 2010 23:32:38 -0300, Paul Stanton p...@mapshed.com.au wrote: Hi Thiago, Hi! please bare with me... I'm not imagining it. I'm guessing it's something to do with my manually created ajax request... Tapestry's session handling works the same regardless how the request was made. I'm not inspecting via debugger, I'm testing the value of the field in code, ie: via @Persist(session) if (persistentField == null) LOG.debug(state reset); I don't know if that's the case, but a persistent field from a given page is only accessible in the same page, even when some other page has a similar field. and via the @SessionState if (!persistentFieldExists) LOG.debug(state reset); Use @SessionState(create = false) instead and test for null. - 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 - 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: @Persist(session) field is null after AjaxRequest
On Fri, 28 May 2010 00:31:18 -0300, Paul Stanton p...@mapshed.com.au wrote: Surely this is a bug in t5 ... I disagree. HTTP is purely stateless. Session keeping is the container's (server) responsibility, not Tapestry's. With cookies disabled, the only way to find out what is the session is appending the ;jsessionid=xxx string to the URLs. This is done by HttpServletResponde.encodeURL(String url), which is indirectly invoked for every single link generated by Tapestry. -- 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