0

What is the equivalent of f:facet in Java?

I've created a panel in Java using org.primefaces.component.panel.Panel class like below.

Panel p = new Panel();
        p.setId("panelId");
        p.setClosable(true);
        p.setVisible(true);

Now I have to add a header to this panel which contains a commandButton. In xhtml, we can achieve this simply by using f:facet but in Java I'm unable to find a way to do this.

So basically I'm looking for a Java equivalent of this code:

 <p:panel id="panelId" header="Graph">
            <f:facet name="header" >
                <p:commandButton id="createWO" value="Create Work Order" icon="pi pi-pencil" >
                            </p:commandButton>
                            </f:facet>
        </p:panel>

Any help would be greatly appreciated. Thank you.

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
user3916928
  • 123
  • 2
  • 13
  • So I can use p.getFacets().put("header", commandButton); It works fine but my panel header name get overridden by this button. Any way I can keep both i.e. header name on left & button on right. – user3916928 Feb 06 '23 at 11:46

0 Answers0