JSF: bean scope; session vs request

后端 未结 2 1199
终归单人心
终归单人心 2020-12-30 15:09

I have a managed bean called UserSearchHandler, it has a doSearch method that populates UserSearchHandler.searchResults which are disp

相关标签:
2条回答
  • 2020-12-30 15:19

    I have a couple of ideas. If you're using a in your navigation you can try taking that out. Doing so would mean the browser will not make a new HTTP request when it renders the second window. It is the new HTTP request which clears the request scoped beans by. If that is not an option, you may be able to pass a parameter in your link such as a record id, which could allow you to pull data from your data source matching that id.

    0 讨论(0)
  • 2020-12-30 15:29

    That's because the #{userSearchHandler.searchResults} is empty during the new request and therefore JSF is unable to locate the associated row where the commandlink is been invoked in order invoke the action (and to pass/set properties if any).

    You need to ensure that the same #{userSearchHandler.searchResults} is precreated during bean's construction/initialization. If it's to be created based on a specific set of parameters, then you've to pass them along with the form as well.

    That's exactly the reason why solutions like Tomahawk's <t:saveState /> and new JSF 2.0 view scope exist.

    See also:

    • What are the main disadvantages of JSF 2.0?
    0 讨论(0)
提交回复
热议问题