Results 1 to 7 of 7

Thread: c:out and property editors

  1. #1
    Join Date
    Dec 2006
    Posts
    311

    Default c:out and property editors

    Hi,

    How do I use my property editors that I registered in my controller on fields that are not bound in form tags?

    For example this works (ie picks up the custom date):

    Code:
    <form:input path="myDate"/>
    but this does not work:

    Code:
    <C:out value="${command.myDate}"/>
    Thanks,

  2. #2
    Join Date
    May 2008
    Location
    Central Florida, U.S.A.
    Posts
    36

    Default

    Behind the scenes a form bind tag uses a BeanWrapper to get the value. A BeanWrapper uses PropertyEditors. So that is why directly accessing the object off the command object will not give you the string you want.

    Since I no very little about JSP, I am not sure how you would use BeanWrapper in JSP to convert the value to a string for output. Perhaps someone else can hep with that.

  3. #3
    Join Date
    Dec 2006
    Posts
    311

    Default

    Thanks,

    There has to be a tag or something for this already built.

  4. #4
    Join Date
    Mar 2006
    Posts
    312

    Default

    Unfortunately, there isn't one that I'm aware of.

    You could use the spring:bind tag to achieve this.
    Code:
    <spring:bind path="command.myDate"><c:out value="${status.value}"/></spring:bind>
    Or you could write a simple taglib to do this for you.

  5. #5
    Join Date
    Dec 2006
    Posts
    311

    Default

    The spring:bind doesnt help thou because I dont want to bind data to a control...I just want to spit it out as text. Thanks for the reply though.

  6. #6
    Join Date
    Aug 2006
    Location
    Brooklyn
    Posts
    556

    Default

    You could use the transform tag :

    Code:
    <spring:bind path="command.date">
    	<spring:transform value="${anyDate}" />
    </spring:bind>
    where "anyDate" is any available attribute.

  7. #7
    Join Date
    Dec 2006
    Posts
    311

    Default

    Quote Originally Posted by Rossen Stoyanchev View Post
    You could use the transform tag :

    Code:
    <spring:bind path="command.date">
    	<spring:transform value="${anyDate}" />
    </spring:bind>
    where "anyDate" is any available attribute.


    Worked like a charm, thank you sir!

Posting Permissions

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