You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Nick Broadhurst <ho...@gmail.com> on 2011/01/29 05:28:44 UTC

Another Date Time Format

Hi,

I am displaying two date-time fields from my demographics object which
populates from the DB:

<s:date name="demographics.creationDate"/>
<s:date name="demographics.lastModificationDate"/>

Both fields show the full date and time. Perfect.
I need the creation date to go back in unchanged on form submit. Tried this:

<s:hidden name="demographics.creationDate"/>

But only populates the date into hidden field and when it goes back into DB,
the time is 00:00:00. No Good.
Is there a version of this:

<s:hidden name="demographics.creationDate"
value="%{demographics.creationDate}"/>

that I can use a date-time function also to get the hidden field to use full
date-time? I haven't messed formatting the the field
in my action first because it is already in that format as shown by the
s:date displayed values.

Or is there a better way to do it?

Thanks,

Nick

Re: Another Date Time Format

Posted by Nick Broadhurst <ho...@gmail.com>.
Thanks for the suggestion. This is what I ended figuring out after I figured
out what date/time format my property of type java.util.Date would accept:

<code>

<input type="hidden" name="demographics.creationDate" value="<s:date
name="demographics.creationDate" format="MM/dd/yyyy hh:mm:ss a"/>"/>

</code>

A ugly hack in order nest <s:date/> in the hidden field. If anyone know how
to do this properly just using

<s:hidden name="demographics.creationDate" value="?????????"/>

I would appreciate it.

Nick

On Sat, Jan 29, 2011 at 12:12 AM, Maurizio Cucchiara <
maurizio.cucchiara@gmail.com> wrote:

> As far as I can remember you could use var parameter in order to
> reference a date variable from the value stack. Try something like
> this:
>
> <s:date name="demographics.creationDate" format="dd/MM/yyyy hh:mm ***"
> var="creationDate"/>
>  <s:hidden name="demographics.creationDate" value="#creationDate"/>
>
> *** I'm not fully sure that this format works.
>
> On 29 January 2011 05:54, Brajesh Patel <br...@gmail.com> wrote:
> > I think it is possible with transient
> >
> > if you don't want to change field in the data base then use variable as
> > transient.
> >
> >
> >
> > On Sat, Jan 29, 2011 at 9:58 AM, Nick Broadhurst <ho...@gmail.com>
> wrote:
> >
> >> Hi,
> >>
> >> I am displaying two date-time fields from my demographics object which
> >> populates from the DB:
> >>
> >> <s:date name="demographics.creationDate"/>
> >> <s:date name="demographics.lastModificationDate"/>
> >>
> >> Both fields show the full date and time. Perfect.
> >> I need the creation date to go back in unchanged on form submit. Tried
> >> this:
> >>
> >> <s:hidden name="demographics.creationDate"/>
> >>
> >> But only populates the date into hidden field and when it goes back into
> >> DB,
> >> the time is 00:00:00. No Good.
> >> Is there a version of this:
> >>
> >> <s:hidden name="demographics.creationDate"
> >> value="%{demographics.creationDate}"/>
> >>
> >> that I can use a date-time function also to get the hidden field to use
> >> full
> >> date-time? I haven't messed formatting the the field
> >> in my action first because it is already in that format as shown by the
> >> s:date displayed values.
> >>
> >> Or is there a better way to do it?
> >>
> >> Thanks,
> >>
> >> Nick
> >>
> >
> >
> >
> > --
> > Thanks
> > Brajesh Patel
> >
> > HotWax Media
> > http://www.hotwaxmedia.com
> >
>
>
>
> --
> Maurizio Cucchiara
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Another Date Time Format

Posted by Maurizio Cucchiara <ma...@gmail.com>.
As far as I can remember you could use var parameter in order to
reference a date variable from the value stack. Try something like
this:

<s:date name="demographics.creationDate" format="dd/MM/yyyy hh:mm ***"
var="creationDate"/>
 <s:hidden name="demographics.creationDate" value="#creationDate"/>

*** I'm not fully sure that this format works.

On 29 January 2011 05:54, Brajesh Patel <br...@gmail.com> wrote:
> I think it is possible with transient
>
> if you don't want to change field in the data base then use variable as
> transient.
>
>
>
> On Sat, Jan 29, 2011 at 9:58 AM, Nick Broadhurst <ho...@gmail.com> wrote:
>
>> Hi,
>>
>> I am displaying two date-time fields from my demographics object which
>> populates from the DB:
>>
>> <s:date name="demographics.creationDate"/>
>> <s:date name="demographics.lastModificationDate"/>
>>
>> Both fields show the full date and time. Perfect.
>> I need the creation date to go back in unchanged on form submit. Tried
>> this:
>>
>> <s:hidden name="demographics.creationDate"/>
>>
>> But only populates the date into hidden field and when it goes back into
>> DB,
>> the time is 00:00:00. No Good.
>> Is there a version of this:
>>
>> <s:hidden name="demographics.creationDate"
>> value="%{demographics.creationDate}"/>
>>
>> that I can use a date-time function also to get the hidden field to use
>> full
>> date-time? I haven't messed formatting the the field
>> in my action first because it is already in that format as shown by the
>> s:date displayed values.
>>
>> Or is there a better way to do it?
>>
>> Thanks,
>>
>> Nick
>>
>
>
>
> --
> Thanks
> Brajesh Patel
>
> HotWax Media
> http://www.hotwaxmedia.com
>



-- 
Maurizio Cucchiara

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


Re: Another Date Time Format

Posted by Brajesh Patel <br...@gmail.com>.
I think it is possible with transient

if you don't want to change field in the data base then use variable as
transient.



On Sat, Jan 29, 2011 at 9:58 AM, Nick Broadhurst <ho...@gmail.com> wrote:

> Hi,
>
> I am displaying two date-time fields from my demographics object which
> populates from the DB:
>
> <s:date name="demographics.creationDate"/>
> <s:date name="demographics.lastModificationDate"/>
>
> Both fields show the full date and time. Perfect.
> I need the creation date to go back in unchanged on form submit. Tried
> this:
>
> <s:hidden name="demographics.creationDate"/>
>
> But only populates the date into hidden field and when it goes back into
> DB,
> the time is 00:00:00. No Good.
> Is there a version of this:
>
> <s:hidden name="demographics.creationDate"
> value="%{demographics.creationDate}"/>
>
> that I can use a date-time function also to get the hidden field to use
> full
> date-time? I haven't messed formatting the the field
> in my action first because it is already in that format as shown by the
> s:date displayed values.
>
> Or is there a better way to do it?
>
> Thanks,
>
> Nick
>



-- 
Thanks
Brajesh Patel

HotWax Media
http://www.hotwaxmedia.com