Wednesday, October 22, 2014

How to set max date and min date in <p:calendar />

The maxdate and mindate attribute is extremely useful for setting available date range for user selection.

e.g.
-Expiry date of an item should not be less than today.
-Date of birth should not be future date.

So how to set maxdate and mindate in PrimeFaces calendar component?

1. create the java.util.date object in backingBean
private Date currentDate = new Date();

public Date getCurrentDate() {

    return currentDate;
}

2. set the java.util.date object as mindate or maxdate
<p:calendar value="#{bean.expiryDate}" mindate="#{bean.currentDate}" />
 

<p:calendar value="#{bean.birthDate}" maxdate="#{bean.currentDate}" />


Done!!

4 comments:

  1. Replies
    1. Big data is a term that describes the large volume of data – both structured and unstructured – that inundates a business on a day-to-day basis. big data projects for students But it’s not the amount of data that’s important.Project Center in Chennai

      Spring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Corporate TRaining Spring Framework the authors explore the idea of using Java in Big Data platforms.

      Spring Training in Chennai

      The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

      Delete
  2. Here is the list of best free and paid Windows 10 apps that you should definitely use,
    especially if you are using Windows 10 laptop or Apps for PC.

    ReplyDelete

LinkWithin

Related Posts Plugin for WordPress, Blogger...