gpt4 book ai didi

java - Web Flow 中的简单变量

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:10:23 26 4
gpt4 key购买 nike

我在 flow.xml 中有不同的 view-state。所有这些国家都有相同的看法。现在我想设置一个只包含一个字符串的变量,并在 View 文件中调用它来自定义内容。
这是我的文件:
flow.xml:对于 View 状态的两个示例

<view-state id="rcpm" view="rc/rcmembers.xhtml">
<on-entry>
<evaluate expression="RCHtmlCache.getCommunityList('rcpm')"
result="flowScope.members" />
</on-entry>
</view-state>

<view-state id="rcarch" view="rc/rcmembers.xhtml">
<on-entry>
<evaluate expression="RCHtmlCache.getCommunityList('rcarch')"
result="flowScope.members" />
</on-entry>
</view-state>

在此文件中,我需要一个具有 View 状态 ID 值的变量,例如“rarch”。

rcmembers.xhtml 只是我想调用变量的代码部分

<p:panel id="panel" header="Memberslist of **Here comes the value of the variable">

希望你能理解我的问题...

最佳答案

你有两个选择:

首先,您可以在流定义级别定义它并直接将其暴露给 View :

<on-entry>
<set name="flowScope.myView" value="flowRequestContext.currentState.id"/>
</on-entry>

或者您可以将流上下文传递给 Controller ​​,然后在那里公开它:

<evaluate expression="RCHtmlCache.getCommunityList(flowRequestContext)" result="flowScope.members"/>

在 Controller 上:

public String getCommunityList(RequestContext context) {
context.getFlowScope().put("myView", context.getCurrentState().getId());
...
}

希望对你有帮助

关于java - Web Flow 中的简单变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15267107/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com