Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set currentdate as mindate in calendar component of primefaces?

Tags:

jsf-2

I am using calendar component of primefaces. I want to set mindate=currentdate. I want restrict user to select date before current date. I am using JSF2.0.

like image 331
Digma Chauhan Avatar asked Jun 13 '12 09:06

Digma Chauhan


4 Answers

Just bind it as a bean property the usual way.

<p:calendar ... mindate="#{bean.currentDate}" />

By the way, the way how you created the current date is clumsy. Just invoking the Date's own constructor is sufficient. Using the Calendar for this purpose only brings unnecessary overhead along.

private Date currentDate = new Date();

public Date getCurrentDate() {
    return currentDate;
}
like image 81
BalusC Avatar answered Nov 07 '22 19:11

BalusC


<p:calendar mindate="today">
like image 14
Marcel Avatar answered Nov 07 '22 19:11

Marcel


Try this,

 <p:calendar mindate="calwidget.today()" widgetVar="calwidget" value="#{bean.date}">
like image 12
Sanjeevi.V Avatar answered Nov 07 '22 19:11

Sanjeevi.V


If you are using omnifaces, you can do this:

<p:calendar ... mindate="#{now}" />
like image 5
John Alexander Betts Avatar answered Nov 07 '22 19:11

John Alexander Betts