我試圖以編程方式修改我的.xhtml文件中的構面。我正在使用Primefaces 6.1。JSF無法修改構面
我有.xhtml
<p:menubar model="#{menu.model}" id="myMenu">
<f:facet name="options">
</f:facet>
</p:menubar>
下面的代碼在我的豆,我有以下的代碼來更新「選項」方面。
@PostConstruct
public void initMenu(){
// getting data is skipped
HtmlPanelGrid mainPanel = new HtmlPanelGrid();
HtmlOutputLabel htmlOutputLabel = new HtmlOutputLabel();
htmlOutputLabel.setValue("Search Template");
mainPanel.getFacets().put("options",htmlOutputLabel);
}
mainPanel.getFacets()返回no facets,因此不能添加標籤。
如何以編程方式訪問和修改構面?我很難過。
爲什麼要新(以錯誤的方式順便說一句)創建** panelgrid **返回非相關菜單欄的方面? – Kukeltje