ユーザーが好きなようにアイテムを固定および削除できる動的ダッシュボードを使用しています。今、既存の複合コンポーネントをバッキング Bean からビューに追加したいという問題があります。インターネットからこれを行う正しい方法を見つけようとしましたが、これまでのところ成功していません。追加したい単純な複合コンポーネントは次のとおりです。
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:cc="http://java.sun.com/jsf/composite"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:composite="http://java.sun.com/jsf/composite">
<!-- INTERFACE -->
<cc:interface>
</cc:interface>
<!-- IMPLEMENTATION -->
<cc:implementation>
<h:outputText value="TEST"/>
</cc:implementation>
</html>
複合コンポーネントを返すコードは次のとおりです。
public static UIComponent getCompositeComponent(String xhtml, String namespace) {
FacesContext fc = FacesContext.getCurrentInstance();
Application app = fc.getApplication();
Resource componentResource = app.getResourceHandler().createResource(xhtml, namespace);
UIPanel facet = (UIPanel) app.createComponent(UIPanel.COMPONENT_TYPE);
facet.setRendererType("javax.faces.Group");
UIComponent composite = app.createComponent(fc, componentResource);
composite.getFacets().put(UIComponent.COMPOSITE_FACET_NAME, facet);
return composite;
}
そして、これが私が関数を使用している方法です:
Column column = new Column();
UIComponent test = HtmlUtil.getCompositeComponent("test.xhtml", "comp");
column.getChildren().add(test);
ただし、列内には何もレンダリングされません。これを行う方法はありますか?render="#{bean.isThisRendered}" の方法は使用したくありません。これは私のユース ケースに適合しないためです。