有条不紊地更改日历主要面上的标签

时间:2016-06-23 06:39:58

标签: jsf primefaces

我需要在Primefaces日历上有条件地更改标签。我有以下代码

<p:calendar value="#{requestMBean.requestTO.startDate}"  id="startDate" 
label="#{requestMBean.requestTO.requestType eq 'SINGLEDAY'}?#{msg['wfmt.label.request.fromDate']}:#{msg['wfmt.label.request.visitingDate']}}"
pattern="dd.MM.yyyy"/>

验证失败时,我希望只看到一个标签。但我得到“请输入:true?fromDate:visitingDate”。

如何有条件地只渲染一个标签?

1 个答案:

答案 0 :(得分:1)

#{requestMBean.requestTO.requestType eq 'SINGLEDAY'}?#{msg['wfmt.label.request.fromDate']}:#{msg['wfmt.label.request.visitingDate']}} is wrong.

如果您希望使用()代码可读性,请将其更改为"#{condition ? true statement : false statement}"

<强>被修改

#{requestMBean.requestTO.requestType eq 'SINGLEDAY' ? msg['wfmt.label.request.fromDate'] : msg['wfmt.label.request.visitingDate']}
相关问题