Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

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!

date format issue - How to insert date into Database from JSF table

843844Sep 11 2009 — edited Sep 11 2009
I'm developing a relatively simple CRUD application based on JSF 1.2 and would like to allow users input calendar dates into the Database.
I'm encountering problems with date formats and am unable to convert a date inputted manually or by a calendar component into the correct format for MS SQL Server.

TABLE
The page concerned consists of a Woodstock table component : <webuijsf:table ...>

ROWGROUP
That table makes use of a CachedRowSet : <webuijsf:tableRowGroup binding="#{myPage.tableRowGroup1}" id="tableRowGroup1" sourceData="#{myPage.myDataProvider}" sourceVar="currentRow" ...>

COLUMNS
TableColumns hold textfields allowing for user input such as the following
<webuijsf:textField id="textField22" text="#{currentRow.value['Name']}"/>

SAVING BACK TO DB
In order to save data back to the Database there is a submit button committing the transaction : myDataProvider.Commit()
This works fine for any datatypes other than dates.

PROBLEM WITH ENTERING DATES
Trying to use the following text field for a date
<webuijsf:textField id="textField23" text="#{currentRow.value['myDate']}"/>

... and entering a value such as "12/31/09"results in the following error message
'12/31/09' could not be understood as a date and time.

The only compatible date format seems to be "Dec 31, 2009 12:00:00 AM"
I tried using converters (SQLTimestampConverter, SQLDateConverter) but they did not help

TARGET SOLUTION: Calendar component
Eventually I would like to use a popup calendar component such as <webuijsf:calendar> or Tomahawk <t:inputCalendar>

Please advice!
Thanks




*********************
JSF 1.2
MS SQL 2005
The dateformat on MS SQL Server configured as [smalldatetime]
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 9 2009
Added on Sep 11 2009
2 comments
412 views