如何从 Stripes ActionBean 获取 javascript 的返回值?

发布于 2024-12-04 14:35:48 字数 373 浏览 4 评论 0原文

我正在尝试使用 Google 的 Channel API 构建 2 人游戏会话。我正在使用 JavaScript 函数开始打开通道,并且我有一个 Stripes ActionBean,可以打开通道并为特定用户获取新的令牌。

如何从 JavaScript 调用 ActionBean 并从 ActionBean 获取“字符串令牌”? ${actionBean.token} 在 .js 文件中不起作用。

PS:我对这些语言很陌生,希望您能投入时间和精力来回答我的问题。谢谢 !

编辑:谢谢!我已阅读建议的链接,并且对 JavaScriptResolution 感到很兴奋。如何在 javascript 中接收 JavaScriptResolution?任何人都可以提供一个代码片段吗?

I am attempting to use Google's Channel API to construct a 2-player game session. I am using a JavaScript function to start opening the channel, and I have a Stripes ActionBean that opens the channel and obtains a new Token for the specific user.

How do I call the ActionBean from JavaScript and get the "String token" from the ActionBean? ${actionBean.token} did not work in the .js file.

PS: I am new to these languages and would appreciate the time and effort invested in answering my question. Thanks !

Edit: Thank you ! I have read the proposed links and I am excited about the JavaScriptResolution. How do I receive the JavaScriptResolution in javascript? Can anyone kindly provide a code snippet perhaps?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

游魂 2024-12-11 14:35:48

除非您在使用 Javascript 生成页面的 actionBean 中生成 Javascript,否则 ${actionBean.token} 将不起作用。在这种情况下,您需要 Ajax,您需要使用 Javascript 发出 http 请求。您可能想看一下这个 Stripes Ajax 示例:

Stripes Ajax 示例

您也可以想要使用 JavaScriptResolution 将对象从actionBean返回到Javascript,请参阅示例代码:

Amis JavaScriptResolution 示例

Unless you are generating the Javascript in the actionBean that generates the page with the Javascript, the ${actionBean.token} will not work. In that case you need Ajax, you need to make the http request in Javascript. You might want to take a look at this Stripes Ajax example:

Stripes Ajax Example

You might also want to use a JavaScriptResolution to return objects from an actionBean to Javascript, see example code:

Amis JavaScriptResolution Example

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