Bean不会发送到另一个页面

时间:2015-08-12 09:21:49

标签: jsf jsf-2

我遇到了一个没有将响应发送到另一个页面的bean的问题。 这是代码:

        @ManagedBean(name = "ssoServiceBean")
    public class SSOServiceBean {

        @ManagedProperty(value="#{param.samlRequest}")
        private String samlRequest;

        @ManagedProperty(value="#{param.relayState}")
        private String relayState;


        @PostConstruct
        public void submit() {

            System.out.println("1) PostConstruct method called");

            //samlRequest = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("samlRequest");

            //relayState = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("relayState");        

            processResponse();
        } 

 //getters and setters omitted for succinctness

        private void processResponse(){

            System.out.println("2) Processing response");

            String uri;

            if(samlRequest != null && !samlRequest.equals("") && relayState != null && !relayState.equals("")) {

                System.out.println("SAMLRequest: "+samlRequest);
                System.out.println("RelayState: "+relayState);

                uri = "challenge.xhtml";

                System.out.println("3) Sending challenge...");  

            } else {

                uri = "dashboard.xhtml";

                System.out.println("3) Sending dashboard...");
            }

            try {
                FacesContext.getCurrentInstance().getExternalContext().dispatch(uri);
                System.out.println("4) Done.");
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }

问题是dispatch()方法无法正常工作,似乎被忽略了。

事实上系统响应错误的相关bean的页面ssoservice.xhtml

我已使用Postconstruct注释,因为使用此bean我可以拦截来自第三方网页的POST参数。 我收到帖子参数后,即可使用重定向指令呈现challenge.xhtml页面。

接下来,用户会将challenge.xhtml提交给相关的bean ChallengeBean.java

那么,问题是什么?为什么派遣不起作用?

0 个答案:

没有答案