JSF 2: page redirect after ajax call

前端 未结 1 463
Happy的楠姐
Happy的楠姐 2021-01-24 02:08

I\'m stuck in a navigation case problem similar to this one. In a few words, I\'m trying to redirect navigation from one page to another, using an ajax rendered h:commandL

1条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-24 02:24

    The rendered attribute of all input and command components is re-evaluated when the form is submitted. So if it evaluates false, then JSF simply won't invoke the action. The Flash scope is terminated when the request/response of the search() method is finished. It isn't there in the Flash scope anymore when you send the request of the showResult(). I suggest to put the bean in the view scope and bind the rendered attribute to its property instead.

    @ManagedBean
    @ViewScoped
    public class StartBean {
    
        private String result;
    
        public void search(){
            result = "hooray";
        }
    
        public String showResult(){
            return "result?faces-redirect=true";
        }
    
        public String getResult() {
            return result;
        }
    
    }
    

    with

    
    

    See also:

    • commandButton/commandLink/ajax action/listener method not invoked or input value not updated

    0 讨论(0)
提交回复
热议问题