I forgot to say:
I do it like this and not like in the code below:

if(firstTab){
            tab.setClassStyle("tab_selected");
        }else{
            tab.setClassStyle("tab");
        }


Remo




-----Original Message-----
From: Remo Liechti [mailto:[EMAIL PROTECTED] 
Sent: Mittwoch, 14. Juni 2006 13:14
To: [email protected]
Subject: Dynamically adding tabs to t:panelTabbedPane

Hi all

I have a t:panelTabbedPane which has dynamic tab numbers and titles.
Well, the CSS style classes are not used for the input html components. The 
tabs are still in default look.

Any ideas?




My jsf:
<t:panelTabbedPane binding="#{cockpitTabbedPaneBean.tabbedPane}" 
activeTabStyleClass="tab_selected" inactiveTabStyleClass="tab" 
tabContentStyleClass="tabbedPane"/>


The component is bind to a backing bean, which generates all the tabs using the 
getter and the addTab methods:

public void setTabbedPane(HtmlPanelTabbedPane pane){
        tabbedPane = pane;
    }

public HtmlPanelTabbedPane getTabbedPane(){
        boolean firstTab = true;
        
// tabs is a member that contains Strings for the tab titles
        for (Iterator it = tabs.iterator(); it.hasNext();) {
            String tabName = (String) it.next();
            addTab(tabName, firstTab);
            firstTab = false;
        }
        return tabbedPane;
    }


private void addTab(String tabName, boolean firstTab) {
        List tabbedPaneChildren = tabbedPane.getChildren();
        
        HtmlPanelTab tab = new HtmlPanelTab();
        tab.setLabel(tabName);
        if(firstTab){
            tab.setStyle("background-color: #EEEEEE");
        }else{
            tab.setStyle("background-color: #CCCCCC");
        }
        
        HtmlGraphicImage img = new HtmlGraphicImage();
        img.setUrl(getImagePathByName(tabName));
        
        List tabChildren = tab.getChildren();
        tabChildren.add(img);
        
        tabbedPaneChildren.add(tab);
    }


CSS:
.tab {
        border-style: solid; border-width: 1px; border-bottom-width: 0px; 
border-left-color: #FFFFFF; border-right-color: #888888; border-top-color: 
#FFFFFF;
        background-color: #CCCCCC; font-size: 10pt; font-weight: normal;
        padding-left: 6px; padding-right: 6px; padding-top: 2px; 
padding-bottom: 2px;
}

.tab_selected {
        border-style: solid; border-width: 1px; border-bottom-width: 0px; 
border-left-color: #FFFFFF; border-right-color: #888888; border-top-color: 
FFFFFF;
        background-color: #EEEEEE; font-size: 10pt; font-weight: bold; 
padding-left: 6px; padding-right: 6px; padding-top: 2px; padding-bottom: 2px;
}

.tabbedPane{
background-color: #EEEEEE; font-size: 10pt; font-weight: bold; padding-left: 
0px; padding-right: 0px; padding-top: 0px; padding-bottom: 0px;
}


-- 
Remo Liechti
Application Developer
Swisslog Warehouse and Distribution Solutions
 
Direct: +41 (0)62 837 4345
Mobile: +41 (0)76 329 8660
CH Fax: +41 (0)62 837 4197
Internet: www.swisslog.com
----------------------------------------------------------------
About Swisslog 
Swisslog is a global provider of logistic solutions for warehouses, 
distribution centers and hospitals. Swisslog's solutions increase their 
customers' flexibility, responsiveness, and quality of service, while 
minimizing logistics costs. 


Reply via email to