Results 1 to 4 of 4

Thread: Error with HTML5 Date tag in Spring ROO

  1. #1
    Join Date
    Feb 2011
    Location
    Bangalore
    Posts
    19

    Question Error with HTML5 Date tag in Spring ROO

    Hi,
    I have completely changed the view layer in spring roo application.
    I am trying to use HTML5 tags instead of jspx.

    When I try to get date using html5 date tag, the date is not getting inserted into the database.

    Code:
    <input type="date" id="birthday" name="dateofbirth" size="20"  />
    Have a look at the controller that handles the request.

    Code:
        @RequestMapping(method = RequestMethod.POST)
        public String create(@Valid Myclass myclass, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) {
            if (bindingResult.hasErrors()) {
            	System.out.println("Value of date: +myclass.getDateofbirth());
                 uiModel.addAttribute("myclass", myclass);
                return "/WEB-INF/JSP/create.jsp";
            }

    The output i am getting here is;

    Code:
    Value of date: null


    Can anybody help?


    Thanks in advance
    Privin Thomas

  2. #2
    Join Date
    Feb 2011
    Location
    Bangalore
    Posts
    19

    Default

    Anybody tried it?
    Any advice from spring team?

  3. #3

    Default

    I haven't tried it, but I'd start by looking at what the browser is actually sending. Is it correctly including dateofbirth=xyz in the post data? At the moment, it isn't clear if the problem is in the browser or in roo's handling of the post data. If the field is correctly being inserted into the post data, it seems unlikely that spring wouldn't handle it correctly on the server. Use some client-side tools to capture what the browser is sending and I suspect you'll find your problem.

  4. #4
    Join Date
    Feb 2011
    Location
    Bangalore
    Posts
    19

    Default

    ideasculptor,

    The data was properly retrieved from the form but but it was not maching the type of dateofbirth field in the entity layer.

    Just changed the variable declaration to;
    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(iso = ISO.DATE)
    private Calendar dateofbirth;
    It worked.

    Anyway thanks a lot for replying.

    Regards
    Privin Thomas

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •