You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by cellterry <ce...@gmail.com> on 2010/12/06 10:55:38 UTC
submit date in textfield with custom date format
Dear All,
I am using struts textfield tag with a date field with date format
"yyyy-MM-dd."
I have seen the following link which also can display what I want.
http://struts.apache.org/2.x/docs/formatting-dates-and-numbers.html
http://struts.apache.org/2.x/docs/formatting-dates-and-numbers.html
However, when I submit the format, the date in struts action is null.
Without the formatting, the date can be passed and hence I feel no other
bugs except formatting.
My code is as follows:
In Jsp:
:
:
<s:textfield id="dt" key="dt" name="qr.dt"
value="%{getText('format.date',{qr.dt})}"/>
:
:
In resource file:
:
:
format.date={0,date,yyyy-MM-dd}
:
:
Could anyone tell me how to make struts action class to retrieve the date
with custom date format?
Terry.
--
View this message in context: http://old.nabble.com/submit-date-in-textfield-with-custom-date-format-tp30366694p30366694.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: submit date in textfield with custom date format
Posted by Li Ying <li...@gmail.com>.
Read this doc:
http://struts.apache.org/2.2.1/docs/type-conversion.html
From
[# 3 Creating a Type Converter]
to
[# 6 Applying a Type Converter for an application]
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: submit date in textfield with custom date format
Posted by cellterry <ce...@gmail.com>.
Yes, you are right.
After searching online a while, I have the following conversion class:
http://old.nabble.com/file/p30437359/DateTypeConverter.java
DateTypeConverter.java
However, when I convert a date, I get the following error. Note that the
class is found and loaded as "test" in class constructor is printed.
test
>>>>>>>LOG4J<<<<<<< 2 2010-12-12 17:22:00,338 [main] ERROR
com.opensymphony.xwork2.conversion.impl.XWorkConverter -
#com.opensymphony.xwork2.util.logging.commons.CommonsLogger.error(CommonsLogger.java:27)#
- Conversion registration error
java.lang.NullPointerException
at
com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:130)
at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:139)
:
:
li wei-4 wrote:
>
> what is your locale associated with the request?
> if your locale's date format is defferent from "yyyy-MM-dd" ,
> you have to customize the type conversion to make it work.
>
> http://struts.apache.org/2.2.1/docs/type-conversion.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
--
View this message in context: http://old.nabble.com/submit-date-in-textfield-with-custom-date-format-tp30366694p30437359.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: submit date in textfield with custom date format
Posted by li wei <li...@gmail.com>.
what is your locale associated with the request?
if your locale's date format is defferent from "yyyy-MM-dd" ,
you have to customize the type conversion to make it work.
http://struts.apache.org/2.2.1/docs/type-conversion.html
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: submit date in textfield with custom date format
Posted by Maurizio Cucchiara <ma...@gmail.com>.
I'm not sure I understand what you mean, did you get an
ognl.MethodFailedException exception?
2010/12/6 cellterry <ce...@gmail.com>:
>
> Dear All,
>
> I am using struts textfield tag with a date field with date format
> "yyyy-MM-dd."
>
> I have seen the following link which also can display what I want.
>
> http://struts.apache.org/2.x/docs/formatting-dates-and-numbers.html
> http://struts.apache.org/2.x/docs/formatting-dates-and-numbers.html
>
> However, when I submit the format, the date in struts action is null.
>
> Without the formatting, the date can be passed and hence I feel no other
> bugs except formatting.
>
> My code is as follows:
>
> In Jsp:
>
> :
> :
> <s:textfield id="dt" key="dt" name="qr.dt"
> value="%{getText('format.date',{qr.dt})}"/>
> :
> :
>
> In resource file:
>
> :
> :
> format.date={0,date,yyyy-MM-dd}
> :
> :
>
> Could anyone tell me how to make struts action class to retrieve the date
> with custom date format?
>
> Terry.
>
> --
> View this message in context: http://old.nabble.com/submit-date-in-textfield-with-custom-date-format-tp30366694p30366694.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
>
>
--
Maurizio Cucchiara
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org