java - Zero returned getting url parameter in jsf -


i trying parameter passed url ..and returns 0.

here managedbean...a simple bean 2 variables.

    import javax.faces.bean.applicationscoped;     import javax.faces.bean.managedbean;     import javax.faces.bean.managedproperty;     import javax.faces.bean.requestscoped;       @managedbean     @requestscoped      public class userbean {          @managedproperty("#{param.id}")          private int id;         private string name;         public int getid() {             system.out.println(id);             return id;         }         public void setid(int id) {             system.out.println(id);             this.id = id;         }         public string getname() {             return name;         }         public void setname(string name) {             this.name = name;         }         public userbean() {             super();         }          public string createurl()         {             return "yoga.xhtml?id=267";         }       } 

here xhtml page parameter passed...i'm using commandbutton redirect page query param

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">  <html xmlns="http://www.w3.org/1999/xhtml"             xmlns:f="http://java.sun.com/jsf/core"             xmlns:h="http://java.sun.com/jsf/html"> <head> </head> <h:body>  <f:metadata>         <f:viewparam name="id" value="#{userbean.id}" /> </f:metadata>  <h:form> <h:commandbutton action = "yoga.xhtml?id=345" value = "click here pass paramter">  </h:commandbutton> </h:form>  </h:body> </html> 

and i'm redirecting page display id passed

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">  <html xmlns="http://www.w3.org/1999/xhtml"             xmlns:f="http://java.sun.com/jsf/core"             xmlns:h="http://java.sun.com/jsf/html">   <h:body>  passed parameter <h1>#{userbean.id}</h1>   </h:body> </html> 


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -