struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Denis Cabasson (JIRA)" <j...@apache.org>
Subject [jira] Updated: (WW-3184) Type conversion & s:select
Date Mon, 13 Jul 2009 19:21:01 GMT

     [ https://issues.apache.org/struts/browse/WW-3184?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Denis Cabasson updated WW-3184:
-------------------------------

    Description: 
Hi,

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>
</select>


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.

  was:
Hi,

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
{code}
private List<Date> theDates;
{code}
fills it with the right date and render it on the JSP :
{code}
<s:select list="theDates" name="theDate" />
{code}
I have a field on my action to receive this date parameter :
{code}
private Date theDate;
{code}

The problem is that the generated HTML content is :
{code}
<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>
</select>
{code}

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.


> Type conversion & s:select
> --------------------------
>
>                 Key: WW-3184
>                 URL: https://issues.apache.org/struts/browse/WW-3184
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Actions
>    Affects Versions: 2.1.6
>         Environment: Struts 2.1.6
>            Reporter: Denis Cabasson
>
> Hi,
> 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>
> </select>
> 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.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message