You could write your own type converter - see type conversion in the S2 docs 
for a good overview. It handles the conversion of any Java object in your model 
class to a String for use in the view, and converts any String field into a 
Java object in forms/GET parameters.

That way you have total control over how the field appears without needing 
extra "type" getters (which is a bit hacky IMO).

----- Original message -----
> maybe you can write a js function to format it or you rewrite your
> getter method of startDate, in this method you will first format it
> then return it. the latter requires all the other caller of the method
> getStartDate needs the same format.
>
> On Sat, Feb 20, 2010 at 12:09 AM, wild_oscar <mig...@almeida.at> wrote:
> >
> > Aaah, dates!
> >
> > Add an s:date and associate with the textfield, like:
> >
> > <s:date name="train.startDate" id="trainDateId" format="dd-MM-yyyy"/>
> > <s:textfield name="train.startDate" value="%{#trainDateId}" label="Choo choo
> > (dd-MM-yyyy)" />
> >
> > I'm not sure if both tags need the "name" or not - post your findings.
> >
> >
> > fireapple wrote:
> > >
> > > Does that mean I have to create something like:
> > >
> > > public String getStartDateStr()
> > > {
> > > ...........
> > > }
> > >
> > > to do this?
> > >
> > > I don't want to use this because if I use this getter, I have to create a
> > > setter for this since user can edit the date.
> > >
> > > Any other options? Thanks
> > >
> > >
> > >
> > > Brian Thompson-5 wrote:
> > > >
> > > > Just add a getter to your "train" object that translates the startDate
> > > > into
> > > > the format you'd like.  Use a DateFormat object.
> > > >
> > > > -Brian
> > > >
> > > >
> > > >
> > > > On Thu, Feb 18, 2010 at 5:07 PM, fireapple <taizhang1...@gmail.com>
> > > > wrote:
> > > >
> > > > >
> > > > > Dear all, I'm using
> > > > > <s:textfield name="train.startDate" cssClass="datepicker">
> > > > >
> > > > > where startDate is a java.util.Date field of an object train.
> > > > >
> > > > > The output is something like this:
> > > > >
> > > > > http://old.nabble.com/file/p27647328/date.png
> > > > >
> > > > > How can I eliminate the 12:00:00 in the textfield? Thanks!
> > > > > --
> > > > > View this message in context:
> > > > > http://old.nabble.com/how-to-eliminate-time-in-%3Cs%3Atextfield%3E-tp27647328p27647328.html
> > > > > Sent from the Struts - User mailing list archive at Nabble.com.
> > > > >
> > > > >
> > > > > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> > > > > For additional commands, e-mail: user-h...@struts.apache.org
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> > --
> > View this message in context:
> > http://old.nabble.com/how-to-eliminate-time-in-%3Cs%3Atextfield%3E-tp27647328p27655381.html
> > Sent from the Struts - User mailing list archive at Nabble.com.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> > For additional commands, e-mail: user-h...@struts.apache.org
> >
> >
>
>
>
> --
> Life is irrational.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>

Reply via email to