[英]JSF / Primefaces composite component with nested composite component
[英]Nested JSF composite components not fully compatible with Primefaces
我正在嘗試創建一個包含在Primefaces Accordion控件中的嵌套JSF復合控件。 但是,當選項卡組件放置在嵌套組件中時,它們根本不會呈現。
outerComponent.xhtml
<composite:interface/>
<composite:implementation>
<p:accordionPanel>
<composite:insertChildren/>
</p:accordionPanel>
</composite:implementation>
innerComponent.xhtml
<composite:interface>
<composite:attribute name="title" type="java.lang.String"/>
</composite:interface>
<composite:implementation>
<p:tab id="#{cc.attrs.title}" title="#{cc.attrs.title}">
Some content
</p:tab>
</composite:implementation>
testPage.xhtml
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:w="http://java.sun.com/jsf/composite/wizard"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<w:outerComponent>
<w:innerComponent title="tab1"/>
</w:outerComponent>
</h:body>
</html>
HTML輸出:
<html xmlns="http://www.w3.org/1999/xhtml"><head><link type="text/css"
rel="stylesheet" href="/iip/javax.faces.resource/theme.css.xhtml?ln=primefaces-
aristo-custom" /><link type="text/css" rel="stylesheet" href="/iip/
javax.faces.resource/primefaces.css.xhtml?ln=primefaces" /><script type="text/
javascript" src="/iip/javax.faces.resource/jquery/jquery.js.xhtml?
ln=primefaces"></script><script type="text/javascript" src="/iip/
javax.faces.resource/primefaces.js.xhtml?ln=primefaces"></script></head>
<body>
<div id="j_idt7:j_idt10" class="ui-accordion ui-widget ui-helper-reset ui-hidden-
container" role="tablist"><input type="hidden" id="j_idt7:j_idt10_active"
name="j_idt7:j_idt10_active" value="0" /></div>
<script id="j_idt7:j_idt10_s" type="text/
javascript">PrimeFaces.cw('AccordionPanel','widget_j_idt7_j_idt10',
{id:'j_idt7:j_idt10'});</script>
</body</html>
當它運行時沒有錯誤,並且在渲染Accordion div時,選項卡不會。 但是,如果我將<p:tab>
標記移動到outerComponent.xhtml
文件中,那么它們將被正確呈現,但這不是我需要的。
有什么建議么?
迭代<p:dataTable>
, <p:tabView>
, <p:accordionPanel>
等組件不能將復合作為直接子項。 它們應該具有完整的<p:column>
或<p:tab>
組件作為直接子項。 在視圖渲染時間內進行迭代時,它們會循環遍歷子instanceof UIColumn
並在渲染之前執行instanceof UIColumn
或instanceof Tab
檢查。 如果它失敗(復合是NamingContainer
),那么它將被忽略。 這是“按設計”。
最好的辦法是使用標記文件而不是復合組件作為迭代組件的子項。
請注意,這對PrimeFaces來說並不明確。 標准<h:dataTable>
具有完全相同的問題。
您是否嘗試在沒有復合的情況下執行此操作 - 我的意思是將它們放在testPage.xhtml中。 我沒有嘗試過這個特定的組合,但是我和tab和accordion一起遇到了其他組件的問題。 檢查問題是否存在於復合材料或組件的組合中。
似乎有一些javascript彼此“不兼容”。
如果仍有問題,可以嘗試封裝選項卡。 我嘗試了不同的組合,似乎有些工作取決於導致問題的組件。 我首先嘗試在選項卡周圍使用<div id="tabContainer">
,如果它不起作用,最終會轉到p:panel
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.