Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-3184

Type conversion & s:select



    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.1.6
    • Fix Version/s: 2.5.x
    • Component/s: Core Actions
    • Labels:
    • Environment:

      Struts 2.1.6



      So I'm trying to understand a little bit better the way type conversion is supposed to work in struts 2/Xwork 2 and I really don't get it. The part I am missing is when is that conversion applied, and on what basis?

      My use case is an action that must present a select box containing dates. So hoping to have struts 2 do all the heavy lifting, I create my action with a field

      private List<Date> theDates;

      fills it with the right date and render it on the JSP :

      <s:select list="theDates" name="theDate" />

      I have a field on my action to receive this date parameter :

      private Date theDate;

      The problem is that the generated HTML content is :

      <select name="theDate" id="index_theDate">
      <option value="Mon Jul 13 15:01:21 EDT 2009">7/13/09</option>
      <option value="Sun Jul 12 15:01:21 EDT 2009">7/12/09</option>

      What I don't get is that the body of the option has been correctly converted, while the value is not at all converted (that looks like a simple toString to me). So of course, the conversion from the toString version of the date to a date object is failing.

      Now I don't get what I did wrong there, and how this is supposed to work. Definitely this looks wrong to me, cause the value is the most important thing in the option. But I couldn't find a way of getting that converted.

      Any advise?

      Thanks for any help.


        1. test-struts2-dates.zip
          6 kB
          Denis Cabasson

          Issue Links



              • Assignee:
                lukaszlenart Lukasz Lenart
                dcabasson Denis Cabasson
              • Votes:
                0 Vote for this issue
                0 Start watching this issue


                • Created: