会话变量不与 GXT 保持一致

发布于 2024-08-20 08:02:16 字数 821 浏览 4 评论 0原文

我在使用 GXT 2.1 和 Grails 1.2 后端的会话中遇到了一个奇怪的问题。我正在创建两个 FormPanelpanelApanelB,它们提交给 action1action2< /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 FormPanels, 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花期渐远 2024-08-27 08:02:17

我最终使用跨域表单帖子和 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文