[jboss-user] [JBoss Seam] - converting time for selectOneMenu displaying time only
damianharvey
do-not-reply at jboss.com
Wed Nov 7 09:48:02 EST 2007
I have an entity with a field 'openTime' that is a MySQL TIME datatype. Hibernate has converted this into an entity field as such: @Temporal(TemporalType.TIME)
| @Column(name = "OPEN_TIME", length = 0)
| public Date getOpenTime() {
| return this.openTime;
| }
I need to allow a user to enter a time on the page. Instead of allowing free text I am using an h:selectOneMenu and a list of times on the half hour (eg. "00:00", "00:30", etc). I can select a time from the list and it will save it in the database. However when I go to edit the record, the select list is not able to select the value that was already saved (ie. set one of the OPTIONs to selected="true").
I ran this through the debugger and the problem is that the com.sun.facces.renderkit.html_basic.MenuRenderer cannot convert from java.util.Date to java.sql.Time. The error produced (and swallowed on line 537) is: Cannot convert 1/1/70 7:00 AM of type class java.util.Date to class java.sql.Time
What is my best option here? Should I go for a custom converter (I haven't done one yet) rather than s:convertDateTime? Or is there an option I can set on the entity definition (maybe 'columnDefinition' on @Column)?
Any advice is very much appreciated.
Thanks,
Damian.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4102565#4102565
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4102565
More information about the jboss-user
mailing list