Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Unable to set current date for <af:inputDate> component

880439May 11 2012 — edited May 11 2012
Hi All,
I am not able to set current date for <af:inputDate> component.

There are two date components on my JSPX : From Date and To Date.
These attributes are not VO based but page is VO based.

I did bindings for these two components in bean as dtFrom and dtTo

Sample JSPX code,
<af:inputDate label="From Date" id="fromDate" binding="#{myBean.dtFrom}" value="#{myBean.dtFrom}"/>
<af:inputDate label="To Date" id="toDate" binding="#{myBean.dtTo}" value="#{myBean.dtTo}"/>
Sample code from myBean,
public void setDtFrom(RichInputDate dtFrom) {
        this.dtFrom = dtFrom;
        Calendar cal = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("mm/dd/yyyy");
        this.dtFrom.setValue(sdf.format(cal.getTime()));
}
public RichInputDate getDtFrom() {
        return dtFrom;
}
public void setDtTo(RichInputDate dtTo) {
        this.dtTo = dtTo;
        Calendar cal = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("mm/dd/yyyy");
        this.dtTo.setValue(sdf.format(cal.getTime()));
}
public RichInputDate getDtTo() {
        return dtTo;
}
On page load, it is showing current dates but when I click on Submit button to submit the form;it is showing error:

Could not convert instance:Thu May 05 00:00:00 IST 2011 of type:class java.util.Date into type:class oracle.adf.view.rich.component.rich.input.RichInputDate

Is there any way set current date as default date on page load without using code in bean, as I did!!!

Appreciate your help.

Thanks and Regards,
Madhav K.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 8 2012
Added on May 11 2012
7 comments
2,114 views