【问题标题】:Spring Webflow and primefaces ActionListnersSpring Webflow 和 primefaces ActionListners
【发布时间】:2013-01-16 17:07:22
【问题描述】:

如何从 Primefaces actionlistner 调用 Spring Webflow 转换?

我有一个 Primefaces 组件SelectOneMenu。每当 Component 的值发生变化时,我想调用 Spring Webflow 中的转换以在 outPutText 中显示 SelectItem 上的描述。

我是 Spring Webflow 和 Primefaces 的新手。

如果以下内容不正确,请告诉我。

JSF 代码

<h:outputText value="Script " style="font-weight: bold" />
    <p:selectOneMenu value="#{selectedDN.cdrScript}" >
      <p:ajax event="change" listener="scriptChange" update="scriptDesc" />
      <f:selectItems value="#{sctiptOptions}" />
    </p:selectOneMenu>
<h:outputText value="#{scriptDesc}" id="scriptDesc" />

视图的网络流配置

<view-state id="Edit">
<on-entry>
<evaluate expression="scriptService.getOptions()"
              result="flowScope.sctiptOptions"/>
  <set name="flowScope.scriptDesc" value="selectedDN.cdrScript.scriptDesc"/>
    </on-entry>
<transition on="scriptChange">
  <set name="flowScope.scriptDesc"
       value="flowScope.selectedDN.cdrScript.scriptName"/>
  <render fragments="form:scriptDesc" />
</transition>

<transition on="Update" to="Edit">
</transition>

<transition on="Cancel" to="View">
</transition>
</view-state>

【问题讨论】:

    标签: primefaces spring-webflow


    【解决方案1】:

    为此,您不需要 SWF 转换或侦听器。像下面这样的东西会起作用:

    <h:outputText value="Script " style="font-weight: bold" />
        <p:selectOneMenu value="#{selectedDN.cdrScript}" >
          <p:ajax event="change" update="scriptDesc" />
          <f:selectItems value="#{scriptService.getOptions()}" var="script" itemLabel="#{script.scriptName}" itemValue="#{script.id}"/>
        </p:selectOneMenu>
    <h:outputText value="#{selectedDN.cdrScript.scriptName}" id="scriptDesc" />
    

    如果还没有,则添加“selectedDN”变量定义:

    <view-state id="Edit">
    <on-entry>
      <set name="flowScope.selectedDN" value="scriptService.getCurrentSelectedDN()"/>
    </on-entry>
    

    注意添加了 itemLabel 和 itemValue 属性。您可能还需要在 selectOneMenu 上指定一个转换器。

    在 PF 部分渲染的情况下,SWF 开箱即用的效果不佳。将以下内容添加到标签下的 MVC servlet 配置中:

            <webflow:flow-execution-attributes>
                <webflow:redirect-in-same-state value="false"/>
            </webflow:flow-execution-attributes>
    

    【讨论】:

    • 非常感谢,我能够在输出文本字段上显示描述,主要是转换器,如果实现正确,一切正常。
    猜你喜欢
    • 2012-12-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-07
    • 1970-01-01
    • 2011-03-30
    • 1970-01-01
    • 2011-09-16
    相关资源
    最近更新 更多