简体   繁体   English

Spring Web Flow-在视图之间存储请求参数(jsf页)

[英]Spring Web Flow - store request param across views(jsf pages)

Have transition configuration for Spring Web Flow: 具有Spring Web Flow的过渡配置:

<transition on="getFiles">
    <evaluate expression="searchService.getFiles(flowScope.searchCriteria, requestParameters.fileId)"
     result="viewScope.file" result-type="dataModel"/>
</transition>

It's needed to invoke searchService.getFiles(flowScope.searchCriteria, requestParameters.fileId) method in two cases: 在两种情况下searchService.getFiles(flowScope.searchCriteria, requestParameters.fileId)需要调用searchService.getFiles(flowScope.searchCriteria, requestParameters.fileId)方法:

1. retrieve files (occurred on 1.xhtml ) 1.检索文件(在1.xhtml发生)
2. sort files (occurred on 2.xhtml ) 2.对文件排序(发生在2.xhtml

Problem is that, when sorting(step 2) files, requestParameters.fileId is lost. 问题是,在对文件进行排序(第2步)时, requestParameters.fileId丢失了。

Is it way to store fileId param cross 1.xhtml and 2.xhtml views? 是否可以跨1.xhtml2.xhtml视图存储fileId参数?

Dont request the fileId attribute by the requestParameters. 不要通过requestParameters请求fileId属性。 The requestParameters object is basically the request attributes. requestParameters对象基本上是请求属性。 You can observe that you set the file as viewScope.file. 您会看到将文件设置为viewScope.file。 That means that anywhere within the view you can access the file accordingly. 这意味着您可以在视图中的任何位置访问文件。 Does viewScope.file.fileId exist? viewScope.file.fileId是否存在?

The request is lost after the first transition, an alternative is you can try setting it into the flashScope. 第一次转换后,请求丢失了,您可以尝试将其设置到flashScope中。

Update based on your comment. 根据您的评论进行更新。 Try setting it into the flash/viewScope first. 尝试先将其设置到flash / viewScope中。

You can do it like this 你可以这样

<transition on="getFiles">
    <set var="flashScope.fileId" value="requestParameters.fileId"/>
    <evaluate expression="searchService.getFiles(flowScope.searchCriteria, requestParameters.fileId)"
     result="viewScope.file" result-type="dataModel"/>
</transition>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM