f:convertDateTime with h:selectOneMenu
843842Dec 7 2004 — edited Dec 5 2007I'm having a strange problem trying to use f:convertDateTime with h:selectOneMenu. I assume it should be possible since h:selectOneMenu does have a converter attribute.
Here's my JSP fragment:
<h:selectOneMenu value="#{searchHandler.startDate}" >
<f:convertDateTime type="date" dateStyle="full"/>
<f:selectItems value="#{searchHandler.allQueryDates}" />
</h:selectOneMenu>
My getAllQueryDates() method returns a list of SelectItem objects created like this:
new SelectItem(date, df.format(date));
I've done this so that each date in the select component is displayed in the appropriate locale. I really don't CARE what the date format is for the actual value of the option...I'm expecting JSF to convert it to a date for me. I have:
public Date getStartDate() {
return startDate;
}
public void setStartDate(Date startDate) {
System.out.println("set start date:" + startDate);
this.startDate = startDate;
}
...but setStartDate() never gets called. I don't get any sort of error, which is frustrating, but it's clearly not doing what I expect.
Am I missing something? Is this simply not supported with h:selectOneMenu?
I'm going to try using longs instead of Dates, which will be fine if it works...but I want to understand why this doesn't work as I'd expect.
Thanks.