我正在使用JDK1.7,JSF2和Primefaces。查找具有ID屬性的每個組件的父ID
我有一個.xhtml
如下。我想列出Parent and the Child Relations
如如圖所示Expected Output
XHTML以下<Component Id Tree Structure> | <Id> | <Child of Id- Parent>
:
<h:form id="rootParentForm">
<p:treeTable id="singleTreeTble" value="#{ttSelectionView.root1}" var="document" selectionMode="single" selection="#{ttSelectionView.selectedNode}" style="margin-top:0">
<f:facet name="header">
Single
</f:facet>
<p:column headerText="Name">
<h:outputText value="#{document.name}" />
</p:column>
<p:column headerText="Size">
<h:outputText value="#{document.size}" />
</p:column>
<p:column headerText="Type">
<h:outputText value="#{document.type}" />
</p:column>
</p:treeTable>
<p:commandButton id="singleCmdBtn" value="Display" update="msgs" icon="ui-icon-newwin"
actionListener="#{ttSelectionView.displaySelectedSingle}"/>
<h3 style="margin-top:0">Basic</h3>
<p:accordionPanel id="basicAP">
<p:tab id="basicTab1" title="Godfather Part I">
<h:panelGrid columns="2" cellpadding="10">
<p:graphicImage name="demo/images/godfather/godfather1.jpg" />
<h:outputText
value="The story begins as Don Vito Corleone..." />
</h:panelGrid>
</p:tab>
<p:tab id="basicTab2" title="Godfather Part II">
<h:panelGrid columns="2" cellpadding="10">
<p:graphicImage name="demo/images/godfather/godfather2.jpg" />
<h:outputText value="Francis Ford Coppola's legendary..." />
</h:panelGrid>
</p:tab>
<p:tab id="basicTab3" title="Godfather Part III">
<h:panelGrid columns="2" cellpadding="10">
<p:graphicImage name="demo/images/godfather/godfather3.jpg" />
<h:outputText value="After a break of more than 15 years..." />
</h:panelGrid>
</p:tab>
</p:accordionPanel>
<h3>Multiple Selection</h3>
<p:accordionPanel id="multipleAP" multiple="true">
<p:tab id="multipleTab1" title="Godfather Part I">
<h:panelGrid columns="2" cellpadding="10">
<p:graphicImage name="demo/images/godfather/godfather1.jpg" />
<h:outputText
value="The story begins as Don Vito Corleone..." />
</h:panelGrid>
</p:tab>
<p:tab id="multipleTab2" title="Godfather Part II">
<h:panelGrid columns="2" cellpadding="10">
<p:graphicImage name="demo/images/godfather/godfather2.jpg" />
<h:outputText value="Francis Ford Coppola's legendary..." />
</h:panelGrid>
</p:tab>
<p:tab id="multipleTab3" title="Godfather Part III">
<h:panelGrid columns="2" cellpadding="10">
<p:graphicImage name="demo/images/godfather/godfather3.jpg" />
<h:outputText value="After a break of more than 15 years...." />
</h:panelGrid>
</p:tab>
</p:accordionPanel>
</h:form>
預期輸出:
什麼是做到這一點的最好辦法?所以,所有的父母和子女關係都將按預期列出。
我會上傳xhtml頁面,然後我想找到&顯示父子關係。
這是什麼意思:「我會上傳xhtml頁面,然後我想找到並顯示父子關係」?你想在上傳一些Facelets文件之後構建和分析組件樹,而無需重新部署應用程序?這個上傳的xhtml應該與正在運行的應用程序相關還是與真空中的任何「球形Facelets文件」相關? – iTollu 2015-03-02 12:30:37
@iTollu我的意思是有一個FileUpload頁,因爲它在[ShowCase](http://www.primefaces.org/showcase/ui/file/upload/basic.xhtml)中,並且一旦上傳成功,我想顯示父子關係到文件中 – 09Q71AO534 2015-03-02 13:33:31
然後,您可以將上傳的文件視爲現有上下文的一部分(所有表達式都將被解析)或完全獨立的代碼。你的情況哪一個是真的? – iTollu 2015-03-02 13:46:34