MetlaFan24
MetlaFan24

Reputation: 33

Struts2 jquery datepicker - set past date range by maxDate & minDate

I have a problem to set the S2 jQuery datepicker to a range between 1st of March 2012 and 31st of March 2014. I have an application that searches past data within this date range and cannot use the +/- setting based on the todays date. I tried to pass a Date object from Action class, but I don't know if it's possible to access it inside the tag. I would appreciate your help!

<sj:datepicker value="Start" id="start" 
    name="startDate" 
    changeMonth="false" 
    changeYear="false" 
    showButtonPanel="false"
    displayFormat="dd-mm-yy" 
    buttonImageOnly="true" 
    onfocus="checkByDate()"
    minDate="????"
    maxDate="????"
    showOn="both"
/>

Upvotes: 3

Views: 1220

Answers (1)

Andrea Ligios
Andrea Ligios

Reputation: 50271

In JSP:

<sj:datepicker 
    ....
    minDate="%{minDate}"
    maxDate="%{maxDate}"
/>

In Action class:

public java.util.Date getMinDate(){
    return minDate;
}
public java.util.Date getMaxDate(){
    return maxDate;
}

Upvotes: 1

Related Questions