我想更新ui:param值或在ui中使用類似的東西:帶條件的重複循環。這個想法是什麼如下(只是一個aprox的,沒有最終落實,但我想是可以理解的):jsf set ui:param或使用一個在ui中動態變化的值:重複
<ui:param name="marginLeftNode" value="#{myBean.initialMarginValue}" />
<ui:repeat value="#{myBean.viewWrapper.linkMap.entrySet().toArray()}" var="map">
<ui:repeat var="link" value="#{map.value}" varStatus="status">
<li style="margin-left: #{marginLeftNode}%" class="ico-#{link.getStyleCss()}-ayuda">
<a href="#{link.getUrlLink()}">#{link.getTitle()}</a>
</li>
<!-- Code conditions that doesn't works in any way as I've readed in the links after code -->
<c:if test="#{marginLeftNode gt 4}">
<ui:param name="marginLeftNode" value="#{myBean.viewWrapper.nodeList.get(status.index).depth}" />
</c:if>
<ui:fragment rendered="#{marginLeftNode gt 4}">
<ui:param name="marginLeftNode" value="#{myBean.viewWrapper.nodeList.get(status.index).depth}" />
</ui:fragment>
<!-- End code conditions: these are the two solutions c:if and ui:fragmen I tried -->
</ui:repeat>
</ui:repeat>
我不能使用C:如果裏面的UI:重複,因爲沒有工作(Specify conditional rendering of element inside <ui:repeat>? The <c:if> does not seem to work)和我不能使用ui:片段與ui:param,因爲它不工作太(Conditional variable definition in JSF)
那麼,任何想法如何解決呢?
如何/在哪裏連接的答案說你不應該使用JSTL? – kolossus 2014-11-23 03:26:49
對不起,也許正確的詞是「避免」而不是「不使用」(我改變了我的答案)。 JSF和JSTL在不同的步驟中執行,你可以使用JSTL,但你必須考慮到它。 例如,JSF有替代JSTL的替代,而不是「c:if」我們可以使用「rendered」屬性。我認爲,如果你不能使用JSF,你只能使用JSTL,但這只是個人觀點。 此外,對於以前版本的JSF 2.2,存在與JSTL相關的錯誤,如果使用JSTL標記,則將支持bean的範圍更改爲「請求範圍」。 https://java.net/jira/browse/JAVASERVERFACES-1492 – Corus 2014-11-23 16:51:10