You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by lewy87 <le...@gmail.com> on 2009/04/11 21:04:22 UTC
Struts 2.1.6 conversion problem with java.util.Date
Hello everybody,
i'm new here and I'm looking for help concerning my Struts2 conversion
problem.
Quick explanation:
I have "LectureAction" which implements ModelDriven<Lecture> interface and
has method to create particular lectures. in my bean Lecture I have fields
such like that:
@Id
@GeneratedValue
private Integer id;
private String title;
private Date dateCreated; //created automatically in setter by assigning
new Date();
private Date dateAvailable;
@Lob
private String content;
private File file;
The problem I have is related to field "dateAvailable". I have
jquery.ui.datepicker on my JSP which show calendar and inserts into
s:textfield date in some format.
Unfortunetely, Java says:
ognl.MethodFailedException: Method "setDateAvailable" failed for object
edu.pjwstk.struts2.models.Lecture@1f920cf [java.lang.NoSuchMethodException:
edu.pjwstk.struts2.models.Lecture.setDateAvailable([Ljava.lang.String;)]
So I wrote converter which converts String to Date and created properties
file.
But even with that, my conversion fails.
I tries to place field "Date dateAvailable" in my Action straight forward
but it also didn't help me :(
I dunno what's wrong.
Maybe someone had this problem?
--
View this message in context: http://www.nabble.com/Struts-2.1.6-conversion-problem-with-java.util.Date-tp23004386p23004386.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Struts 2.1.6 conversion problem with java.util.Date
Posted by Stefano Tranquillini <st...@gmail.com>.
U have to specify the tipe, if your field is a timestamp have to set
the annotation in this way:
@Temporal(TemporalType.TIMESTAMP)
private Date datetime;
and then u can simply assign the value in this way:
setDatetime(new Date());
cheers
On Sun, Apr 12, 2009 at 15:27, lewy87 <le...@gmail.com> wrote:
>
> For anyone looking for help related to this problem:
>
> Date must be in format "dd.mm.yyyy" and you don't even need additional field
> in action as well as converter class. Everything is mapped straight forward
> onto bean model.
>
> I don't know why, but it's compulsory in Struts2 framework.
> Quite weird, isn't it ?
>
>
>
> lewy87 wrote:
>>
>> Hello everybody,
>>
>> i'm new here and I'm looking for help concerning my Struts2 conversion
>> problem.
>>
>> Quick explanation:
>>
>> I have "LectureAction" which implements ModelDriven<Lecture> interface and
>> has method to create particular lectures. in my bean Lecture I have fields
>> such like that:
>>
>> @Id
>> @GeneratedValue
>> private Integer id;
>> private String title;
>> private Date dateCreated; //created automatically in setter by assigning
>> new Date();
>> private Date dateAvailable;
>> @Lob
>> private String content;
>> private File file;
>>
>> The problem I have is related to field "dateAvailable". I have
>> jquery.ui.datepicker on my JSP which show calendar and inserts into
>> s:textfield date in some format.
>> Unfortunetely, Java says:
>>
>> ognl.MethodFailedException: Method "setDateAvailable" failed for object
>> edu.pjwstk.struts2.models.Lecture@1f920cf
>> [java.lang.NoSuchMethodException:
>> edu.pjwstk.struts2.models.Lecture.setDateAvailable([Ljava.lang.String;)]
>>
>> So I wrote converter which converts String to Date and created properties
>> file.
>>
>> But even with that, my conversion fails.
>>
>> I tries to place field "Date dateAvailable" in my Action straight forward
>> but it also didn't help me :(
>>
>> I dunno what's wrong.
>>
>> Maybe someone had this problem?
>>
>
> --
> View this message in context: http://www.nabble.com/Struts-2.1.6-conversion-problem-with-java.util.Date-tp23004386p23011063.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
Stefano
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Struts 2.1.6 conversion problem with java.util.Date
Posted by lewy87 <le...@gmail.com>.
For anyone looking for help related to this problem:
Date must be in format "dd.mm.yyyy" and you don't even need additional field
in action as well as converter class. Everything is mapped straight forward
onto bean model.
I don't know why, but it's compulsory in Struts2 framework.
Quite weird, isn't it ?
lewy87 wrote:
>
> Hello everybody,
>
> i'm new here and I'm looking for help concerning my Struts2 conversion
> problem.
>
> Quick explanation:
>
> I have "LectureAction" which implements ModelDriven<Lecture> interface and
> has method to create particular lectures. in my bean Lecture I have fields
> such like that:
>
> @Id
> @GeneratedValue
> private Integer id;
> private String title;
> private Date dateCreated; //created automatically in setter by assigning
> new Date();
> private Date dateAvailable;
> @Lob
> private String content;
> private File file;
>
> The problem I have is related to field "dateAvailable". I have
> jquery.ui.datepicker on my JSP which show calendar and inserts into
> s:textfield date in some format.
> Unfortunetely, Java says:
>
> ognl.MethodFailedException: Method "setDateAvailable" failed for object
> edu.pjwstk.struts2.models.Lecture@1f920cf
> [java.lang.NoSuchMethodException:
> edu.pjwstk.struts2.models.Lecture.setDateAvailable([Ljava.lang.String;)]
>
> So I wrote converter which converts String to Date and created properties
> file.
>
> But even with that, my conversion fails.
>
> I tries to place field "Date dateAvailable" in my Action straight forward
> but it also didn't help me :(
>
> I dunno what's wrong.
>
> Maybe someone had this problem?
>
--
View this message in context: http://www.nabble.com/Struts-2.1.6-conversion-problem-with-java.util.Date-tp23004386p23011063.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org