jsf 2 - Reference a managedBean inside Controller bean -


i want pass reference of managedbean inside controller bean argument. domain entity brand. , want set properties of brand jsf page component. , want pass managedbean reference in controller method , controller addbrand method getbrandservice , save respective brand bean. please guide me. :) managed bean code:

@managedbean @requestscoped public class brandbean implements serializable{     private static final long serialversionuid = 1l;     private string brandname;     private string branddecription; //getters , setters } 

and controller bean brand: // addbrand method takes brand instance parameter. brand model object.

@managedbean @requestscoped public class brandcontroller extends abstractcontroller{     private ibrandservice brandservice;      public ibrandservice getbrandservice() {         brandservice = new brandservice();         return brandservice;     }      public void setbrandservice(ibrandservice brandservice) {         this.brandservice = brandservice;     }      @override     protected modelandview handlerequestinternal(httpservletrequest request,             httpservletresponse response) throws exception {         return null;     }     public void addbrand(string brandname, string branddecription){         try{             brand brand = new brand();             brand.setbrandname(brandname);             brand.setbranddecription(branddecription);             getbrandservice().addbrand(brand);         }         catch(exception ex){             ex.printstacktrace();         }     }  } 

@managedbean @requestscoped @suppresswarnings("serial") public class brandbean implements serializable {     private int brandid;     private string brandname;     private string branddescription;     private list<brand> brands;     private list<brand> filter;       public list<brand> getfilter() {         return filter;     }     public void setfilter(list<brand> filter) {         this.filter = filter;     }     public list<brand> getbrands() {         return brands;     }     public void setbrands(list<brand> brands) {         this.brands = brands;     }     public int getbrandid() {         return brandid;     }     public void setbrandid(int brandid) {         this.brandid = brandid;     }     public string getbrandname() {         return brandname;     }     public void setbrandname(string brandname) {         this.brandname = brandname;     }     public string getbranddescription() {         return branddescription;     }     public void setbranddescription(string branddescription) {         this.branddescription = branddescription;     }  }  @managedbean @requestscoped public class brandcontroller {     private brandbean bean;     @managedproperty(value = "#{brandservice}")     private brandservice brandservice; public brandcontroller() {         bean = new brandbean();       }     } 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -