2012-04-10 24 views
1

我想在TabView的顯示的一組編輯器。每個編輯器都有一個名爲組件的屬性,用於存儲呈現的編輯器。簡單的編輯器使用HTML標記來呈現編輯器,而複雜的編輯器使用另一個頁面中定義的編輯器。我發現,我不能與UI使用editor.component:包括因爲當樹建值不可用。我該如何解決這個問題?是否有任何替代品:包括沒有這個限制?顯示動態編輯與UI JSF:包括

<ui:composition xmlns="http://www.w3.org/1999/xhtml" 
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.prime.com.tr/ui"> 

<h:panelGroup> 
    <p:tabView value="#{groupsBean.groups}" var="group"> 
     <p:tab title="#{group.name}"> 
      <h:panelGroup> 
       <p:dataTable value="#{group.editors}" var="editor"> 
        <p:column headerText="Key"> 
         <h:outputText value="#{editor.name}" /> 
        </p:column> 
        <p:column headerText="Value"> 
         <h:panelGroup rendered="#{not editor.href}"> 
          <h:outputText value="#{editor.component}" escape="false" /> 
         </h:panelGroup> 
         <h:panelGroup rendered="#{editor.href}"> 
          <ui:include src="#{editor.component}" /> 
         </h:panelGroup> 
        </p:column> 
       </p:dataTable> 
      </h:panelGroup> 
     </p:tab> 
    </p:tabView> 
</h:panelGroup> 

EDIT 1

的web.xml包含這些項:

<context-param> 
    <param-name>javax.faces.FACELETS_LIBRARIES</param-name> 
    <param-value>/WEB-INF/springsecurity.taglib.xml; /WEB-INF/custom.taglib.xml</param-value> 
</context-param> 

custom.taglib.xml是內部WEB-INF文件夾。

<facelet-taglib> 
    <namespace>http://www.custom.ro/</namespace> 
    <tag> 
     <tag-name>dynamic</tag-name> 
     <component> 
      <component-type>ro.custom.DynamicInclude</component-type>     
     </component> 
    </tag> 
</facelet-taglib> 

DynamicInclude標註有@FacesComponent("ro.custom.DynamicInclude")

groups.xhtml我已經添加了命名空間的動態包括 - xmlns:custom="http://www.custom.ro/"

EDIT2

最後我設法使它工作。缺少的是處理程序類(com.corejsf.tag.DynamicIncludeHandler)的條目。我還刪除了DynamicInclude的getSrc方法中用於測試src的行。

回答

1

據我知道有沒有這樣的組件的替代用戶界面:包括。我們使用FaceletContext.includeFacelet api自己實現了這樣的事情。

一個相當簡單的替代方法是用C繪製表:forEach循環 - 無需自行編碼額外的組件。缺點是你會得到每一行的組件,在某些情況下可能會佔用大量資源。

+0

你可以給我一個使用FaceletContext.includeFacelet api實現的小例子嗎? – Seitaridis 2012-04-11 06:17:33

+0

它在這裏http://pastebin.com/5e2dgR15 – mrembisz 2012-04-11 07:54:04

+0

我還沒有創建過自定義組件,這是我第一次。我添加了這兩個類,創建帶有「動態」標記名稱和附加的組件類型(DynamicInclude)的標記庫描述符文件,並將標記庫添加到web.xml中的javax.faces.FACELETS_LIBRARIES。在.xhtml文件中,我使用,但沒有顯示任何內容。我錯過了什麼嗎? – Seitaridis 2012-04-11 10:29:45