1

在我的項目中,我以編程方式將複合組件添加到primefaces p:面板,如下所述:How to programmatically or dynamically create a composite component in JSF 2回發後以編程方式加載複合消失元素

這是複合材料構件:

<?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:h="http://java.sun.com/jsf/html" 
    xmlns:composite="http://java.sun.com/jsf/composite" 
    xmlns:p="http://primefaces.org/ui"> 

<composite:interface> 

</composite:interface> 

<composite:implementation> 

    <h:panelGroup styleClass="ui-grid ui-grid-responsive" 
    id="myPG" layout="block"> 

     <div class="ui-grid ui-grid-responsive label-777777"> 
     <div class="ui-grid-row"> 
      <div class="ui-grid-col-11-5"> 
       <label>#{msgs['label.content']}</label> 
      </div> 
     </div> 
    </div> 


    <p:commandButton styleClass="myButton blueButton" 
     id="myCompositeButton" value="#{msgs['button.elimina']}" 
     update="@form" 
     actionListener="#{myController.onMyClick}" /> 
    </h:panelGroup> 
</composite:implementation> 
</html> 

當添加到頁面中,顯示細膩,但按鈕,「格」部分的回傳後,消失(它不是發送到瀏覽器)。

如果我實現了div whith h:panelGroup和h:outputlabel,則元素被渲染但是爲空(#{msgs ['label.content']}爲空)。

這裏是onMyClick處理程序(它沒有邏輯):

public void onMyClick() 
{ 
    System.out.println("#########################################CALLBAK"); 
} 

我哪裏錯了?

Primefaces版本爲5.1,在JBoss運行AS 7.1.1

回答

0

正如我是有問題的編程創建目標體系結構的組件(IBM爲8.5,用於MyFaces 2.0和不,我不能改變JSF實現),我改變了方法,使用後臺bean的綁定用戶界面:包括一個H內部:panelGroup中

<h:panelGroup id="myPanel" layout="block" rendered="#{myController.moduleSelected }"> 
    <ui:include src="#{myController.moduleType}"></ui:include> 
</h:panelGroup> 

發佈的答案,幫助其他用戶