简体   繁体   English

如何根据日期是否大于今天的日期来呈现 JSF 组件?

[英]How can I render a JSF component based on if the date is greater than today's date?

i get a date from server side and how do I compare this in my xhtml code, so that if it is less than today's date, I'll render the panel, otherwise not.我从服务器端得到一个日期,如何在我的 xhtml 代码中进行比较,这样如果它小于今天的日期,我将渲染面板,否则不会。

You can have a method in your bean你可以在你的 bean 中有一个方法

class MyBean{    
  public boolean isDateBigger(){
   //date comparissoin and return result
  }
}

on XHTML在 XHTML 上

render="#{myBean.dateBigger}"

Update:更新:

As per your comment, if you want to accomplish it through javascript then.根据您的评论,如果您想通过 javascript 来完成它。

take two hidden parameter.取两个隐藏参数。 One current millis and another representing your date's millis一个当前毫秒,另一个代表您日期的毫秒

compare them using javascript and apply DIV's style visibility:hidden to hide使用 javascript 比较它们并应用 DIV 的样式visibility:hidden隐藏

try尝试

{mbean.cardExpiryDate gt now} {mbean.cardExpiryDate gt 现在}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM