jsf - Need to pass the current tab name to the backing managed bean from dynamically generated tab -


i using primefaces. , requirement have number of tabs generated based on list specified in backing bean. second criteria if tab changes content under tab should changes. kept onchange event , tried value through event.gettab().gettitle(), returning null backing bean.

<p:tabview id="tabview" binding="#{dndproductsview.tabview}">         <p:ajax event="tabchange" listener="#{dndproductsview.ontabchange}"/> </p:tabview> 

managed bean required codes :-

@postconstruct public void init() {     user = sessionbean.getusername();     categorylist = categorylogics.findallorderedbycategoryname();     productlist = productlogics.findallorderedbyproductname();     droppedproducts = new arraylist<product>(); }  private tabview tabview;  @inject private facescontext facescontext;  public void settabview(tabview tabview) {     this.tabview = tabview; }  public tabview gettabview() {     tabview = new tabview();     (category c : categorylist) {         tab t = new tab();         t.settitle(c.getcategoryname());         tabview.getchildren().add(t);     }     return tabview; }  public void ontabchange(tabchangeevent event) {     string titlename =  event.gettab().gettitle();     system.out.println("" + titlename); } 

the tab getting generated , when tab changes, ontabchange() method called event.gettab().gettitle() returns null.

integer index=(integer)tabview.getactiveindex(); 

it not name index of activ tab witch in case 1 interested in. index starts 0 being first tab :)


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -