【问题标题】:is it possible to access value bundle properties in web-flow context?是否可以在 web 流上下文中访问价值包属性?
【发布时间】:2013-10-23 01:37:59
【问题描述】:

这是我的网络流程的一部分:

<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/webflow
        http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd"
    parent="estatGeneral" start-state="a_cargar_info">

    <attribute name="caption" value="consultaDeutesHandler.filAriadna" />

    <action-state id="a_cargar_info">
        <evaluate expression="consultaDeutesHandler.primeraCarrega(flowRequestContext, usuari)"></evaluate>
        <transition on="success" to="v_formulariDeutesInici"/>
        <transition on="error" to="error"/>
    </action-state>

我想将属性包或支持 bean 中的文本插入到属性中。我试过这个:

<attribute name="caption" value="consultaDeutesHandler.filAriadna" />

其中consultaDeutesHandler.filAriadna 是一个返回字符串的函数。我只是从字面上看到“consultaDeutesHandler.filAriadna”,而不是预期值。

有没有办法从属性包中设置属性的值?

【问题讨论】:

    标签: java spring jsf spring-webflow


    【解决方案1】:

    &lt;attribute&gt; 标签不起作用,因为它只支持纯字符串,不支持 EL 表达式。

    &lt;set&gt; 应该可以解决问题:

    <set name="flowScope.caption" value="consultaDeutesHandler.filAriadna()" />
    

    (酌情用 requestScope、conversationScope 等替换 flowScope。)

    您可以稍后在流 xml 中以及从您的视图中引用此值。对于 JSF 示例,

    <div>#{caption}</div>
    

    最终将包含从consultaDeutesHandler.filAriadna()返回的值

    【讨论】:

    • 这个很棒但标题没有任何设置器,但你的时间。
    • 您不需要二传手。这将创建一个名为“caption”的流范围变量,您可以在流 xml 和视图中的其他位置访问它。
    • 好的,所以如果我的变量在:RequestContext ctx ctx.getActiveFlow().getCaption(),我该怎么做?泰。
    • 如果你有 RequestContext 对象,你可以做 ctx.getFlowScope().getString("caption")
    猜你喜欢
    • 1970-01-01
    • 2011-04-20
    • 2020-09-05
    • 1970-01-01
    • 2012-03-13
    • 1970-01-01
    • 1970-01-01
    • 2022-01-01
    • 1970-01-01
    相关资源
    最近更新 更多