将参数从 JSF 发送到 Webflow 转换

发布于 2024-12-09 19:10:59 字数 1140 浏览 0 评论 0原文

基本上我现在拥有的是这样的:

<view-state id="pageOne" view="pageone.xhtml">
    <transition on="gotoPageTwo" to="doGotoPageTwo" />
</view-state>
<subflow-state id="doGotoPageTwo" subflow="pageTwo">
    <transition on="return" to="pageOne" />
</subflow-state>

JSF 代码是:

<h:commandLink value="Page Two" action="gotoPageTwo" />

到目前为止一切顺利。接下来我想做的是类似于:

<h:commandLink value="Page Two" action="gotoPageTwo(customArgument)" />

并且:

<view-state id="pageOne" view="pageone.xhtml">
    <transition on="gotoPageTwo" to="doGotoPageTwo" />
</view-state>
<subflow-state id="doGotoPageTwo" subflow="pageTwo">
    <input name="myCustomArgument" value="customArgument" />
    <transition on="return" to="pageOne" />
</subflow-state>

我知道这显然不能按原样工作,但希望您能理解这个概念。我发现的唯一解决方案是使用 actionListener 将数据放入某种伪全局变量中(在链接 bean 中或在 flash-/flow-Scope 中)。这似乎是一个丑陋的解耦解决方案,与将参数放入全局变量而不是在 C++ 中传递它们没有太大区别。有没有更好的方法来做到这一点?

诗。我们也使用 Primefaces,但我认为这与这种情况无关。

Basically what I have now is something like:

<view-state id="pageOne" view="pageone.xhtml">
    <transition on="gotoPageTwo" to="doGotoPageTwo" />
</view-state>
<subflow-state id="doGotoPageTwo" subflow="pageTwo">
    <transition on="return" to="pageOne" />
</subflow-state>

With the JSF code being:

<h:commandLink value="Page Two" action="gotoPageTwo" />

So far so good. What I want to do next is something similar to:

<h:commandLink value="Page Two" action="gotoPageTwo(customArgument)" />

And:

<view-state id="pageOne" view="pageone.xhtml">
    <transition on="gotoPageTwo" to="doGotoPageTwo" />
</view-state>
<subflow-state id="doGotoPageTwo" subflow="pageTwo">
    <input name="myCustomArgument" value="customArgument" />
    <transition on="return" to="pageOne" />
</subflow-state>

I know this obviously doesn't work as is, but hopefully you get the concept. The only solution I've found is using an actionListener to put the data in some kind of pseudo-global variable (either in a linked bean or in the flash-/flow-Scope). This seems like an ugly decoupled solution, not much different from putting your arguments in global variables instead of passing them in c++. Is there any better way to do this?

Ps. We also use Primefaces but I don't think that's relevant in this situation.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文