You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by maven apache <ap...@gmail.com> on 2010/12/09 10:37:42 UTC

any option parameter for populating parameters to my bean?

My action:

public class MyAction{
  private MyBean bean;
  //getter setter.....
}

public class MyBean{
  private Date start;
  //setter getter....
}

<s:form....
<s:textfield .... name=bean.start />

If the value of start is '2010-12-12 12:00:00',the parmameter start can be
populated to my bean correctly,however if the format is '2010/12/12
12:00:00',it will show me a error "can not parser the date',so I wonder if
there is any parameter can be set for populating parameter?

Re: any option parameter for populating parameters to my bean?

Posted by maven apache <ap...@gmail.com>.
2010/12/10 Li Ying <li...@gmail.com>

> Can you show us the entire Exception stack?
>
> I guess, this may be a type conversion error.
>
> According to this struts2 documents:
>
> http://struts.apache.org/2.x/docs/type-conversion.html#TypeConversion-BuiltinTypeConversionSupport
>
> "XWork will automatically handle the most common type conversion for
> you. This includes support for converting to and from Strings for each
> of the following: "
>
> "dates - uses the SHORT format for the Locale associated with the
> current request"
>
>
> So, I think the following things should be checked first:
> What the "Locale associated with the current request" is?
> What the short format of this locale is?
> Is your input string "2010/12/12 12:00:00" match this short format?
>
> The default date converter looks like depends on the "Locale
> associated with the current request".
> So, the format it takes will vary.
>


> If you want this, you need *create a new converter* which takes a fixed
> date format.
>

Thanks,This is just what I need.


>
> I did this before, it's not difficult, if you following the document.
>
>
>
> 2010/12/9 maven apache <ap...@gmail.com>:
> > My action:
> >
> > public class MyAction{
> >  private MyBean bean;
> >  //getter setter.....
> > }
> >
> > public class MyBean{
> >  private Date start;
> >  //setter getter....
> > }
> >
> > <s:form....
> > <s:textfield .... name=bean.start />
> >
> > If the value of start is '2010-12-12 12:00:00',the parmameter start can
> be
> > populated to my bean correctly,however if the format is '2010/12/12
> > 12:00:00',it will show me a error "can not parser the date',so I wonder
> if
> > there is any parameter can be set for populating parameter?
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: any option parameter for populating parameters to my bean?

Posted by Li Ying <li...@gmail.com>.
Can you show us the entire Exception stack?

I guess, this may be a type conversion error.

According to this struts2 documents:
http://struts.apache.org/2.x/docs/type-conversion.html#TypeConversion-BuiltinTypeConversionSupport

"XWork will automatically handle the most common type conversion for
you. This includes support for converting to and from Strings for each
of the following: "

"dates - uses the SHORT format for the Locale associated with the
current request"


So, I think the following things should be checked first:
What the "Locale associated with the current request" is?
What the short format of this locale is?
Is your input string "2010/12/12 12:00:00" match this short format?

The default date converter looks like depends on the "Locale
associated with the current request".
So, the format it takes will vary.
If you want this, you need create a new converter which takes a fixed
date format.

I did this before, it's not difficult, if you following the document.



2010/12/9 maven apache <ap...@gmail.com>:
> My action:
>
> public class MyAction{
>  private MyBean bean;
>  //getter setter.....
> }
>
> public class MyBean{
>  private Date start;
>  //setter getter....
> }
>
> <s:form....
> <s:textfield .... name=bean.start />
>
> If the value of start is '2010-12-12 12:00:00',the parmameter start can be
> populated to my bean correctly,however if the format is '2010/12/12
> 12:00:00',it will show me a error "can not parser the date',so I wonder if
> there is any parameter can be set for populating parameter?
>

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


Re: any option parameter for populating parameters to my bean?

Posted by maven apache <ap...@gmail.com>.
2010/12/9 Dave Newton <da...@gmail.com>

> Strange, I believe this question was asked by someone else with no name--



> try
> searching the archives.
>
How? Using the nabble? I can not access  Nabble.com  :(

>
> Dave
>
> On Thu, Dec 9, 2010 at 4:37 AM, maven apache <ap...@gmail.com>
> wrote:
>
> > My action:
> >
> > public class MyAction{
> >  private MyBean bean;
> >  //getter setter.....
> > }
> >
> > public class MyBean{
> >  private Date start;
> >  //setter getter....
> > }
> >
> > <s:form....
> > <s:textfield .... name=bean.start />
> >
> > If the value of start is '2010-12-12 12:00:00',the parmameter start can
> be
> > populated to my bean correctly,however if the format is '2010/12/12
> > 12:00:00',it will show me a error "can not parser the date',so I wonder
> if
> > there is any parameter can be set for populating parameter?
> >
>

Re: any option parameter for populating parameters to my bean?

Posted by Dave Newton <da...@gmail.com>.
Strange, I believe this question was asked by someone else with no name--try
searching the archives.

Dave

On Thu, Dec 9, 2010 at 4:37 AM, maven apache <ap...@gmail.com> wrote:

> My action:
>
> public class MyAction{
>  private MyBean bean;
>  //getter setter.....
> }
>
> public class MyBean{
>  private Date start;
>  //setter getter....
> }
>
> <s:form....
> <s:textfield .... name=bean.start />
>
> If the value of start is '2010-12-12 12:00:00',the parmameter start can be
> populated to my bean correctly,however if the format is '2010/12/12
> 12:00:00',it will show me a error "can not parser the date',so I wonder if
> there is any parameter can be set for populating parameter?
>