2

i am createing header for <h:panelgrid> from bean. now this is jsf required code(if i written code in jsf page).

<f:facet name="header">
                        <h:outputText value="Search Template ">
                        </h:outputText>
                    </f:facet>

My Problem is how to add this in bean file with below code.

HtmlPanelGrid mainPanel = new HtmlPanelGrid();
mainPanel.setColumns(1);
mainPanel.setStyleClass("searchtabtemplate");

HtmlOutputLabel htmlOutputLabelObj = new HtmlOutputLabel();
htmlOutputLabelObj.setValue(ApplicationConstants.NO_RECORD_FOUND);

mainPanel.getChildren().add(htmlOutputLabelObj);

I have tried with this code but where i have to use facetTag i dont get idea .

FacetTag facetTag = new FacetTag();
facetTag.setName("header");
HtmlOutputLabel htmlOutputLabel = new HtmlOutputLabel();
htmlOutputLabel.setValue("Search Template");
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Jubin Patel
  • 1,959
  • 19
  • 38

1 Answers1

4

The UIComponent superclass has a getFacets() method. Guess what it does :)

mainPanel.getFacets().put("header", htmlOutputLabel);

Unrelated to the concrete problem, the HtmlOutputLabel represents the <h:outputLabel> which is the wrong tool for the purpose. Use HtmlOutputText instead which represents <h:outputText>.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555