Expand tab on p:accordionpanel

UI Components for JSF
Post Reply
3man
Posts: 99
Joined: 16 Jun 2011, 16:13

24 Nov 2011, 11:12

hello,

can someone help me with expand tab on accordionpanel

I try with activeIndex, but unsuccessfully

index.xhtml:

Code: Select all

        <p:accordionPanel id="menuPanel" value="#{menuBean.menus}" var="menu"  activeIndex="#{menuBean.active}" >
                <p:tab id="tab_menu" title="#{menu.title}"  >
                        <p:dataList value="#{menu.list}" var="list" styleClass="menu_style" >  
                                <p:column>  
                                        <p:commandLink title="#{list.id}" value="#{list.name}" actionListener="#{menuBean.processAction}" >  
                                                <h:outputText value="#{list.name}" />
                                        </p:commandLink>  
                                </p:column>  
                        </p:dataList>
                </p:tab>
        </p:accordionPanel> 
MenuBean.java:

Code: Select all

public class menuBean implements Serializable, ActionListener  {

     private int active;

   @Override
    public void processAction(ActionEvent ae) throws AbortProcessingException 
    {
                CommandLink itm = (CommandLink)ae.getSource();
                String menu_name = itm.getValue().toString();
                selection = itm.getTitle().toString();
                String message = "CLICK ON MENU ITEM: " + menu_name;
                Severity severity = FacesMessage.SEVERITY_INFO;

                FacesMessage msg = new FacesMessage(severity, "PROGRAM SELECT", message);

                FacesContext.getCurrentInstance().addMessage(null, msg);

                RequestContext requestContext = RequestContext.getCurrentInstance();

                requestContext.addPartialUpdateTarget("frmContent:growl");
    }

    public class MenuList implements Serializable{

        private String id;
        private String name;

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

    }

    public class MenuTab implements Serializable {

        private String id;
        private String title;
        private List<MenuList> list;

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public List<MenuList> getList() {
            return list;
        }

        public void setList(List<MenuList> list) {
            this.list = list;
        }
    }

    private List<MenuTab> menus = new ArrayList<MenuTab>();

    public List<MenuTab> getMenus() {
        return menus;
    }

    @PostConstruct
    private void initModel() {

        List<MenuList> list;
        MenuTab tab;
        MenuList item;

        for(int i=1; i< 4; i++){
                list = new ArrayList<MenuList>();
                tab = new MenuTab();        
                tab.setId("tab" + i);
                tab.setTitle("Menu "+i);

                //test
                setActive(3);

                for(int j=1; j<5; j++){
                      item = new MenuList();
                      item.setId(id);
                      item.setName("Submenu "+i+" - "+j);
        
                      list.add(item);
               }

               tab.setList(list);
               menus.add(tab);

       }

    }


    public int getActive() {
        return active;
    }

    public void setActive(int active) {
        System.out.println("set active tab:"+active);
        this.active = active;
    }

}


With this only accordion panel get selected but tab is not expanded.
-----------
primefaces-3.3-SNAPSHOT
tomcat 7.0.22
Mojarra 2.1.1 (FCS 20110408)
NetBeans 7.1

blake.neal
Posts: 30
Joined: 23 May 2011, 22:03

14 Dec 2011, 07:25

I ran into the same issue, even when using a hard-coded number. Are you able to get it to expand if you enter an int into the activeIndex attribute? It could very well be a bug. The only issue is that it works on the PrimeFaces Showcase http://www.primefaces.org/showcase-labs ... nPanel.jsf

The Showcase uses RC1, so I don't even know the main issue.
Primefaces 4.0 // Majorra 2.1.24 // Tomcat 7.x

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 52 guests