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

江枫思渺然 提交于 2019-12-10 15:49:17

问题


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.


回答1:


You can have a method in your bean

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

on XHTML

render="#{myBean.dateBigger}"

Update:

As per your comment, if you want to accomplish it through javascript then.

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




回答2:


try

{mbean.cardExpiryDate gt now}



来源:https://stackoverflow.com/questions/5800724/how-can-i-render-a-jsf-component-based-on-if-the-date-is-greater-than-todays-da

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!