将组件添加到UITab

时间:2013-01-27 10:10:50

标签: jsf-2 richfaces

我疯了因为我有这个问题

我有这个菜单组件

<rich:panelMenuItem label="Users" name="Users"  action="#{tabsBean.createTabs('tab Users')}" render="tabs" />       

   <rich:panel>
      <h:panelGrid id="tabs" binding="#{tabsBean.panelGrid}"/>
   </rich:panel>

单击“用户”项时,菜单添加新选项卡

@ManagedBean
@SessionScoped
public class TabsBean {

private HtmlPanelGrid panelGrid;
private UITabPanel tabPanel;
private List<UITab> tabsList;
private Application application;


public TabsBean() {

    tabsList = new LinkedList<UITab>();
    FacesContext context = FacesContext.getCurrentInstance();
    application = context.getApplication();
    tabPanel = (UITabPanel)application.createComponent(UITabPanel.COMPONENT_TYPE);
    tabPanel.setSwitchType(SwitchType.ajax);

}

public void createTabs (String name){       


    UITab tab = new UITab();
    tab = (UITab)application.createComponent(UITab.COMPONENT_TYPE);
    tab.setName(name);
    tabPanel.getChildren().add(tab);

    //I would add here a component to my new tab

    panelGrid.getChildren().add(tabPanel);


}

所以一切正常,但现在我想将组件添加到新标签页,例如下表

 <rich:extendedDataTable id="UsersTable" value="#{userController.allUsers}" var="user" />
        <rich:column>
            <f:facet name="header">Id</f:facet>
            <h:outputText value="#{user.id}" />
        </rich:column>
        <rich:column>
            <f:facet name="header">Name</f:facet>
            <h:outputText value="#{users.name}" />

        </rich:column>
    </rich:extendedDataTable>

我该怎么办?

0 个答案:

没有答案