Announcement Announcement Module
Collapse
No announcement yet.
c:out and property editors Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

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

    Comment


    • #3
      Thanks,

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

      Comment


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

        Comment


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

          Comment


          • #6
            You could use the transform tag :

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

            Comment


            • #7
              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!

              Comment

              Working...
              X