I am trying to modify a facet in my .xhtml file programatically. I am using Primefaces 6.1.
I have the following code in .xhtml
<p:menubar model="#{menu.model}" id="myMenu">
<f:facet name="options">
</f:facet>
</p:menubar>
In my bean I have the following code to update "options" facet.
@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() returns no facets hence can't add the label.
How can I programmatically access and modify the facet? I am stumped.