Results 1 to 6 of 6

Thread: getAsText() is never called; JSP page doesn't get formatted

  1. #1

    Default getAsText() is never called; JSP page doesn't get formatted

    The model has
    Code:
    	private Date issueDate;
    It also has getters and setters.

    I have the customDate editor registered this way in SimpleFormController.
    Code:
    	protected void initBinder(HttpServletRequest request,
    			ServletRequestDataBinder pBinder) {
    
    		SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
    		pBinder.registerCustomEditor(Date.class, new CustomDateEditor(
    				dateFormat, true));
    
    	}
    The jsp page:
    Code:
    			            <spring&#58;bind path="pool.issueDate">
    			              <input type="text" 
    			              	name="<c&#58;out value="$&#123;status.expression&#125;"/>" 
    			              	size="30" maxlength="30" 
    			              	value="<c&#58;out value="$&#123;status.value&#125;"/>">
    			            </spring&#58;bind>

    On the jsp page I get the issuedate unformatted. I noticed that getAsText() is never called. On the submission of the form setAsText(String text) is called.

    How do I display the formatted date on the jsp page?

    Thanks.
    Neeraj Kumar

  2. #2
    Join Date
    Aug 2004
    Posts
    1,905

    Default

    Looks fine to me.

    What gets rendered exactly?

  3. #3

    Default

    It was printing to string of date with timestampt and everything.

    I solved the problem by following code. Still clueless about why get method is not being called.

    Code:
    <fmt&#58;formatDate value="$&#123;status.value&#125;" pattern="MM/dd/yyyy">
    Neeraj Kumar

  4. #4
    Join Date
    Aug 2004
    Posts
    1,905

    Default

    Hmmm, I thought PropertyEditors were used for both rendering and binding. Anyone else?

  5. #5

    Default

    The solution I posted is straight from the 'Java development with the spring framework' book by interface21 team. FYI.
    Neeraj Kumar

  6. #6
    Join Date
    Aug 2004
    Posts
    1,905

    Default

    Yeah, I am being a plonker PropertyEditors will not be called when rendering the object When rendering your object, you get back the actual object.

Similar Threads

  1. Replies: 17
    Last Post: Jan 2nd, 2007, 01:43 PM
  2. Pageable data list with Hibernate
    By robmorgan in forum Data
    Replies: 23
    Last Post: Jul 24th, 2006, 06:12 PM
  3. Replies: 6
    Last Post: Mar 1st, 2006, 11:45 AM
  4. Replies: 0
    Last Post: Jun 10th, 2005, 08:22 AM
  5. getAsText not called
    By falaserioaih in forum Web
    Replies: 4
    Last Post: Apr 14th, 2005, 01:56 PM

Posting Permissions

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