从bean添加facet到primefaces面板

时间:2015-12-12 10:41:11

标签: jsf jsf-2 primefaces

<h:form>
    <p:dashboard id="board"
    binding="#{fundamentFormCreatorBean.dashboard}">
    </p:dashboard>
</h:form>    

 FacesContext fc = FacesContext.getCurrentInstance();
            Application application = fc.getApplication();
            dashboard = (Dashboard) application.createComponent(fc,
                    "org.primefaces.component.Dashboard",
                    "org.primefaces.component.DashboardRenderer");
            dashboard.setId("dashboard");
            DashboardModel model = new DefaultDashboardModel();
                column1 = new DefaultDashboardColumn();
            Panel panel = (Panel) application.createComponent(fc,
                    "org.primefaces.component.Panel",
                    "org.primefaces.component.PanelRenderer");
            panel.setId("UniqueId");
            panel.setHeader("panelName");
            panel.setClosable(true);
            dashboard.getChildren().add(panel);
            column1.addWidget(panel.getId());

我想在bean的面板中添加f:facet。我已经从上面代码中显示的bean动态添加了 Primefaces仪表板及其面板。我尝试使用下面的代码添加一个方面,但没有成功。

 HtmlGraphicImage oTabImage= new HtmlGraphicImage();                         
 oTabImage.setValue("/images/tabicon.jpg");                            
 HtmlOutputText oText = new HtmlOutputText();
 oText.setValue("Here is my label");                               
 HtmlPanelGroup oGroup = new HtmlPanelGroup();
 oGroup.getChildren().add(oText);
 oGroup.getChildren().add(oTabImage);   
 panel.getFacets().put("label", oGroup);

1 个答案:

答案 0 :(得分:0)

PrimeFaces面板没有标签构面。所以这将永远不会工作,甚至在xhtml中也没有用(如我所说)。试试header facet,这将起作用