4
我可以用JSF做條件邏輯,沒有JSTL標籤嗎?有條件的JSF
例如,我做了一個複合組件,並且想要說明,如果'id'屬性被指定,那麼定義'id'屬性,但是如果沒有指定'id'屬性,那麼,不指定'id'屬性。
現在我不得不使用呈現的屬性,但在那裏有很多重複,只有指定id或沒有稍微區別。
<composite:interface>
<composite:attribute name="id" />
...
</composite:interface>
<composite:implementation>
<!-- render this when id is specified, id attribute is defined -->
<h:selectOneMenu
id="#{cc.attrs.id}"
label="#{cc.attrs.label}"
value="#{cc.attrs.value}"
rendered="#{cc.attrs.id != null}" ...>
...
</h:selectOneMenu>
<!-- render this when id is not specified, id attribute is NOT defined -->
<h:selectOneMenu
label="#{cc.attrs.label}"
value="#{cc.attrs.value}"
rendered="#{cc.attrs.id == null}" ...>
...
</h:selectOneMenu>
</composite:implementation>
任何想法,以避免這種重複,更容易做有條件的東西?
謝謝!