简体   繁体   中英

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

Have transition configuration for 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:

1. retrieve files (occurred on 1.xhtml )
2. sort files (occurred on 2.xhtml )

Problem is that, when sorting(step 2) files, requestParameters.fileId is lost.

Is it way to store fileId param cross 1.xhtml and 2.xhtml views?

Dont request the fileId attribute by the requestParameters. The requestParameters object is basically the request attributes. You can observe that you set the file as viewScope.file. That means that anywhere within the view you can access the file accordingly. Does viewScope.file.fileId exist?

The request is lost after the first transition, an alternative is you can try setting it into the flashScope.

Update based on your comment. Try setting it into the flash/viewScope first.

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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