Primefaces tabview tabChange event fired after displaying tab

前端 未结 3 1189
南方客
南方客 2021-01-14 03:31

I am working on a project using Primefaces 3.5 & JSF2.1 (Mojarra)

I have created a primefaces wit

3条回答
  •  逝去的感伤
    2021-01-14 04:00

    I think the answer of ali saleh is right.

    If you get problems with the tabchangelistener perhaps this can help you:

    I had a similar problem with Primefaces 5.1

    As long as i put the tabview into a form everything worked fine. But because i wanted to use seperate forms in my tabs i had to remove the surrounding form of the tabview to avoid nested forms. Without the surrounding form the ajax event didn´t get triggered any more when changing the tab.

    My solution was to use a remotecommand in a form parallel to the tabview.
    The remotecommand is triggered by the onTabChange attribute of the tabview element. At that call i forwarded the index parameter to the global request parameters.

    
        // Tabs...  
    
    
    
        
        
    

    In the backing bean i catched the value again from the request parameter map and set the active index.

    public void onTabChange()
    {   
        FacesContext context = FacesContext.getCurrentInstance();
        Map paramMap = context.getExternalContext().getRequestParameterMap();
        String paramIndex = paramMap.get("activeIndex");
        setActiveTabIndex(Integer.valueOf(paramIndex));
        System.out.println("Active index changed to " + activeTabIndex);
    }    
    

    Hope that can help you

提交回复
热议问题