Saturday, September 29, 2012

redirect a page according to view parameter

in jsf page




  <f:metadata>
            
            <f:viewParam name="id" value="#{testBean.val}" />
        </f:metadata>




in managed bean

  public void setVal(String val) throws IOException {
        System.out.println("Value Set"+ new Date());
        if(val.startsWith("1"))
             FacesContext.getCurrentInstance().getExternalContext().dispatch("/foo.xhtml");
        else
            FacesContext.getCurrentInstance().getExternalContext().dispatch("/bar.xhtml");
           
        this.val = val;
    }

No comments:

Post a Comment