Conditional rendering of f:param in JSF

给你一囗甜甜゛ 提交于 2019-11-30 13:08:02
BalusC

The <f:param> has a disable (not disabled!) attribute for the purpose.

<f:param name="cid" value="#{cid}" disable="#{empty cid}" />
<f:param name="sid" value="#{sid}" disable="#{empty sid}" />

Note that this has a bug in Mojarra versions older than 2.1.15, because they typo'ed the actual UIParameter property to be disble instead of disable. See also issue 2312.

As to the <c:if> approach, that would only work if the #{cid} and #{sid} is available during view build time. In other words, it would fail if they are only available during view render time, e.g. when they depend on var of a repeater component. See also JSTL in JSF2 Facelets... makes sense?

See also:

Don't you like this kind of a solution?

<f:param name="#{cid == null ? '' : 'cid'}" value="#{cid}"/>
<f:param name="#{sid == null ? '' : 'sid'}" value="#{sid}"/>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!