我想知道jsf哪个更有效/可读等,有条件地包括或决定包含内是否呈现内容。
e.g。条件包括
<h:panelGroup rendered="#{entitiy.condition}">
<ui:include src="included.xml">
<ui:param name="entity" value="#{entity}" />
</ui:include>
</h:panelGroup>
vs always include
<ui:include src="included.xml" />
<ui:param name="entity" value="#{entity}" />
</ui:include>
然后在included.xml
内:
<h:panelGroup rendered="#{entity.condition}">
<h:outputText value="#{entity.name}" />
</h:panelGroup>
答案 0 :(得分:0)
恕我直言有条件包括感觉更自然:
c:if
我不确定这是否真的更好但是使用h:panelGroup
进行检查,因为这会完全删除代码评估。见JSTL in JSF2 Facelets... makes sense?
"production": {
"compressor": {
"type": "none"
}
}
添加跨度,而c:if是纯渲染逻辑。