Does f:viewParam only pass query string in url when first page uses the same managed bean as the second page?

后端 未结 2 1847
说谎
说谎 2020-12-10 09:21

Let\'s use a search page and a results page for example. If i have a ViewScoped bean that handles my search page and my results page, i\'m able to pass parameters through th

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-10 09:50

    I suggest you to implement two @ViewScoped managed beans, one for the search page and the other for the results page. You should also have two xhtml pages, each one related with a bean. Obviusly its page will have its own url (as it seems you're doing right now with the same bean).

    You can make the second page's bean expect two parameters, firstName and lastName. After, in the preRenderView method, when parameters are already set into the second managed bean, query your DB with that values. So how to achieve the transition between the beans? An outcome should be enough.

    
        
        
    
    

    This makes JSF build an url with the params you need. After you can do exactly the same that you're doing right now, but using your second bean to get your params (I strongly suggest you not to use a getter method for the preRenderView method):

    
      
      
      
    
    

提交回复
热议问题