Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    DateItem does not accept RestDatasource's response format YYYY-MM-DD

    I am using a DynamicForm which is fed by a RestDatasource.

    The fetch response of the server is:

    <response>
    <data>
    <record>
    <date>2012-07-01</date>
    ...
    </record>
    </data>
    </response>

    The form contains following DateItem:

    final DateItem dateItem = new DateItem("date", "Date");

    When the form is populated after fetching the server's response data, the DateItem shows the current date instead of the received date.
    The date within the response is ignored.

    When I change the Java Code to:

    final DateItem dateItem = new DateItem("date", "Date");
    dateItem.setUseTextField(true);

    The correct value is shown in the text field (2012-07-01), so the link to the response data seems to work.
    If I select the date by using the DatePicker, the text contains following format afterwards: 07/01/2012

    The format YYYY-MM-DD is specified in http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/data/RestDataSource.html:
    "... Date, time and datetime values must be communicated using XML Schema format, as in the following examples:
    <dateField>2007-04-22</dateField> ..."

    When saving the form, SmartGWT is sending the data exactly in that format.

    What can I do that DateItem does accept the input format YYYY-MM-DD too?

    Thank you very much.

    Best Regards

    Uwe

    SmartGWT Version: 3.0, Browser: Firefox 10.0.5, IE9

    #2
    This isn't related to the form, your RestDataSource needs to declare this field as type "date" or it will still be a String by the time the form receives it, resulting in the behavior you're seeing.

    Comment


      #3
      It works :-)

      Hi Isomorphic,

      thank you for the hint. That was the solution.

      Comment

      Working...
      X