我正在为 <h:panelgrid>
创建 header 来自 bean 。
现在这是 jsf 所需的代码(如果我在 jsf 页面中编写代码)。
<f:facet name="header">
<h:outputText value="Search Template ">
</h:outputText>
</f:facet>
我的问题是如何使用以下代码将其添加到 bean 文件中。
HtmlPanelGrid mainPanel = new HtmlPanelGrid();
mainPanel.setColumns(1);
mainPanel.setStyleClass("searchtabtemplate");
HtmlOutputLabel htmlOutputLabelObj = new HtmlOutputLabel();
htmlOutputLabelObj.setValue(ApplicationConstants.NO_RECORD_FOUND);
mainPanel.getChildren().add(htmlOutputLabelObj);
我已经尝试使用此代码,但我必须使用 facetTag
我不明白。
FacetTag facetTag = new FacetTag();
facetTag.setName("header");
HtmlOutputLabel htmlOutputLabel = new HtmlOutputLabel();
htmlOutputLabel.setValue("Search Template");
最佳答案
UIComponent
父类(super class)有一个 getFacets()
方法。猜猜它是做什么的:)
mainPanel.getFacets().put("header", htmlOutputLabel);
与具体问题无关,HtmlOutputLabel
代表<h:outputLabel>
这是达不到目的的错误工具。使用HtmlOutputText
相反,它代表 <h:outputText>
.
关于jsf - 如何以编程方式创建 <f :facet name ="header"> for HtmlPanelGrid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18982218/