struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Li Ying <liying.cn.2...@gmail.com>
Subject Re: Reg: Issue with Struts 2 Data Binding
Date Wed, 27 Oct 2010 08:47:32 GMT
Your data is declared as HashMap<String,Object>
So Struts2 don't know what data type the parameter should be converted to.

My suggestion:

Change your Action class likes:
Public Class ActionClass{
private *HashMap<String, Date>* userPropsAsDate;

private *HashMap<String, Integer>* userPropsAsInt;

private *HashMap<String, String>* userPropsAsStr;

// Setter and Getter
}

And use the appropriate map for particular data type.

BTW, I didn't test it.
You can try it and see if it works.



2010/10/27 Sathish Kumar <sathishkumar.thiyagarajan@gmail.com>:
> Hi Group,
>
>
>
> I have a below issue with Data Binding. Consider we have below code
>
>
>
> //Model Class
>
> Public Class User {
>
>                Private *Date* dateOfBirth;
>
> // Setter and Getter
>
> }
>
>
>
> // Action Class
>
> Public Class MyActionClass{
>
> Private *User* user ;
>
> // Setter and Getter
>
> }
>
>
>
> In My HTML I use a Date Picker component as  below ….
>
>
>
> [@sj.datepicker name="*user. dateOfBirth* " label="Date Of Birth" /]
>
>
>
> Everything works fine !!!  and I see *dateOfBirth populated with
> java.util.Date*
>
>
>
> But …. In some cases , My Action Class is  generic .. so I have to use a
> HashMap to store the values ..
>
>
>
> // Action Class
>
> Public Class MyProblematicActionClass{
>
> Private *HashMap<String,Object>* userAsMap ;
>
> // Setter and Getter
>
> }
>
>
>
> And HTML as,
>
>
>
> [@sj.datepicker name=" *userAsMap. dateOfBirth* " label="Date Of Birth" /]
>
>
>
> But this time, userAsMap. *dateOfBirth is populated as String value rather
> than Date* value …..
>
>
>
> Is this problem solvable ? if yes, how do we do that ?
>
>
>
> Any help here will be  great …..
>
>
>
> Thanks & Regards,
>
> Sathish Kumar T
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message