我需要編寫一個放置在<h:outputLink>...</h:outputLink>
標記內的複合組件,並輸出<f:param ... />
標記。生成的<f:param />
標記的源是由過濾器設置的請求屬性,其中包含提供屬性值name
和value
的值的對象列表。<f:param>複合組件中用於圍繞<h:outputLink>和奇怪行爲的標記<c:forEach>
現在有兩個問題:
- 的
<f:param />
標記不會影響受周圍<h:outputLink>
<c:forEach>
產生了從請求屬性檢索列表中不重複的URL。
通常,整個組件的行爲有點奇怪,因爲我可以訪問列表中的特定元素並輸出其值。但是,一旦涉及到<c:forEach>
循環不會輸出任何內容。
該組件目前看起來如下:我爲什麼可以訪問特定列表
- :
<f:view xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:cc="http://xmlns.jcp.org/jsf/composite" xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:c="http://xmlns.jcp.org/jsp/jstl/core" xmlns:h="http://xmlns.jcp.org/jsf/html"> <!-- INTERFACE --> <cc:interface> </cc:interface> <!-- IMPLEMENTATION --> <cc:implementation> <!-- works, outputs e.g. 'confirmationData' --> #{activeContentThreadList[0].name} <!-- does not work, link URL is unaffected --> <f:param name="#{activeContentThreadList[0].displayName}" value="#{activeContentThreadList[0].token}" /> <!-- works, outputs e.g. '[[email protected]]' --> <h:outputText value="#{activeContentThreadList}" /> <!-- does not work, nothing is outputted --> <c:forEach items="#{activeContentThreadList}" var="asd"> <h:outputText value="#{asd.name}" /> <h:outputText value="test in loop" /> </c:forEach> </cc:implementation> </f:view>
組件的使用步驟如下:
<h:outputLink value="#{request.contextPath}/confirmation/fields/ordersearch.xhtml" styleClass="ext"> <cst:activeThreads /> </h:outputLink>
我的問題項目,但
<c:forEach>
什麼都不做? - 爲什麼鏈接網址不會受到至少一個
<f:param>
標記的影響? - 甚至有可能將
<f:param>
標籤從內部複合組件輸出到周圍鏈路?
嘿marius,希望你得到了描述problemhandled。如果是這樣,請確認下面的答案。 :-) –
當然,我會回到辦公室。我試過'',它沒有改變任何東西。所以不可能生成影響周圍鏈接的''標籤。我最終只使用了一個帶有靜態參數名稱的''。 –