2013-10-15 19 views
1

這是我的網絡流的一部分:是有可能訪問在網絡流上下文值包屬性?

<?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> 

我想插入文本從屬性捆綁或支持豆成一個屬性。我嘗試這樣做:

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

其中consultaDeutesHandler.filAriadna是返回一個字符串的函數。取而代之的是預期值的我只看到「consultaDeutesHandler.filAriadna」的字面。

有沒有辦法從屬性包中設置屬性的值?

回答

4

<attribute>標記將不起作用,因爲它只支持普通字符串,而不支持EL表達式。

<set>應該做的伎倆:

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

(替代requestScope,conversationScope等,爲flowScope如適用)

您可以參考這個值在後面的XML流量,並從觀點。對於JSF例如,

<div>#{caption}</div> 

最終將包含您的時間從consultaDeutesHandler.filAriadna()

+0

這個偉大的,但標題的返回值沒有得到任何二傳手,但TY。 – ZaoTaoBao

+0

你不應該需要一個setter。這將創建一個名爲「標題」,你可以在流動XML和視圖訪問其他地方的流量範圍的變量。 –

+0

好的,所以如果我的變量在:RequestContext ctx \t \t \t ctx.getActiveFlow()。getCaption(),我該怎麼做呢? TY。 – ZaoTaoBao