Announcement Announcement Module
Collapse
No announcement yet.
getAsText() is never called; JSP page doesn't get formatted Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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.

  • #2
    Looks fine to me.

    What gets rendered exactly?

    Comment


    • #3
      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">

      Comment


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

        Comment


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

          Comment


          • #6
            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.

            Comment

            Working...
            X