【问题标题】:How to programmaticallty create a <f:facet name="header"> for HtmlPanelGrid如何以编程方式为 HtmlPanelGrid 创建一个 <f:facet name="header">
【发布时间】:2013-09-29 16:55:20
【问题描述】:

我正在为 bean 中的 &lt;h:panelgrid&gt; 创建标头。 现在这是 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");

【问题讨论】:

    标签: jsf jsf-1.2


    【解决方案1】:

    UIComponent 超类有一个getFacets() 方法。猜猜它的作用:)

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

    与具体问题无关HtmlOutputLabel 代表&lt;h:outputLabel&gt;,这是错误的工具。使用HtmlOutputText 代替它代表&lt;h:outputText&gt;

    【讨论】:

      猜你喜欢
      • 2014-01-09
      • 2011-09-01
      • 1970-01-01
      • 2015-05-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多