会话变量不与 GXT 保持一致
我在使用 GXT 2.1 和 Grails 1.2 后端的会话中遇到了一个奇怪的问题。我正在创建两个 FormPanel
,panelA
和 panelB
,它们提交给 action1
和 action2< /code> 分别在 Grails 中。在action1中我设置了一个硬编码的会话变量并在action2中检索它,但它总是返回null!如果我手动转到操作 1,然后在浏览器中转到操作 2,它会完全按预期工作。我尝试在 Firefox 和 Safari 上以开发模式运行,并得到相同的结果。关于我应该寻找什么有什么想法吗?一些相关片段:
在 GXT 中:
final FormPanel panelA = new FormPanel();
panelA.setVisible(false);
panelA.setAction(action1);
panelA.setMethod(Method.POST);
RootPanel.get().add(panelA);
panelA.submit();
在 Grails 中:
def a1 = {
session.a1 = "Hello A1"
println "Set A1 to $session.a1"
render "Set A1 to $session.a1"
}
def a2 = {
println "From A2, A1 is set to: $session.a1"
render "From A2, A1 is set to: $session.a1"
}
I'm encountering a strange problem with the session using GXT 2.1 and a Grails 1.2 backend. I'm creating two FormPanel
s, panelA
and panelB
, which submit to action1
and action2
in Grails respectively. In action1 I set a hardcoded session variable and retrieve it in action2, but it is always returning null! If I manually go to action1 then follow by going to action2 in a browser it works exactly as expected. I've tried running on both Firefox and Safari in development mode and get the same result on both. Any ideas on what I should look for? Some relevant snippets:
In GXT:
final FormPanel panelA = new FormPanel();
panelA.setVisible(false);
panelA.setAction(action1);
panelA.setMethod(Method.POST);
RootPanel.get().add(panelA);
panelA.submit();
In Grails:
def a1 = {
session.a1 = "Hello A1"
println "Set A1 to $session.a1"
render "Set A1 to $session.a1"
}
def a2 = {
println "From A2, A1 is set to: $session.a1"
render "From A2, A1 is set to: $session.a1"
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最终使用跨域表单帖子和 JSON-P 的组合作为解决方案,这是一个很好的解决方法,因为我可以只发布表单(带有事务 ID),在会话中存储任何反馈/结果,然后检索该数据使用 JSON-P 调用。
I ended up using a combination of cross domain form posts and JSON-P as a solution, it's a great workaround as I can just post the form (with a transaction id), store any feedback/results in the session, then retrieve that data using a JSON-P call.