The pattern I normally use when rendering data to views is to either use
the view's expression language or a helper class to format the data on
demand.

Some examples with dates :

FreeMarker : native date support

The date you selected is ${dateValue?string("MM/dd/yyyy")}

Velocity : (I don't know if velocity has native date support, so I use a
helper class that I have added to the context}

The date you selected is ${dateHelper.formatDate(dateValue,
"MM/dd/yyyy")}

JSP : (use the JSTL)

The date you selected is <fmt:formatDate value="${dateValue}"
pattern="MM/dd/yyyy"/>

Though for JSTL to access your action properties you need to do one of
either

A) set it into the page context  (someone correct me if this is
incorrect)
<ww:set scope="page" value="dateHelper"/>

or

B) use a filter that wraps the request to resolve
request.getAttribute("dateValue") to valueStack.findValue("dateValue")
Since JSTL searches the request scope automatically



> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of John Patterson
> Sent: Thursday, 2 October 2003 3:25 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [OS-webwork] Type conversion
> 
> 
> This is great.  But what if you need to format a date that is 
> a property of an object in a collection on the action?
> 
> ie On my flight search action I have a collection of 
> FlightJourney objects which contain FlightFare objects which 
> contain FlightLeg objects.
> 
> I want to specify the format for a Date property on a 
> FlightLeg object.
> 
> I think that the only way to do this is to be able to pass 
> some extra info to the Converter code directly from the tag.
> 
> This also covers the common case where the same property 
> needs to be displayed more than once on a page in different 
> formats.  For example, I need to display the "time" portion 
> of my java.util.Date in a seperate place to the "date" 
> portion.  I should only have to have one property which, 
> getFromDate(), which can be formatted as desired in the presentation.
> 
> I think that rather than specifying a different Converter 
> class for every different usage it would be much easier to 
> "parametise" the converters so that they can be passed format 
> information.
> 
> ie <ww:property value="startDate" format="dd MMM yyyy"/>
> 
> IMHO, the standard converters should be made more flexible 
> rather than defining new ones for every case.
> 
> Is there any way around this with the current converter 
> framework?  Can I solve my problem without resorting to 
> making my domain objects contain the text formating code themselves???
> 
> John.
> 
> ----- Original Message ----- 
> From: "Jason Carreira" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, October 01, 2003 4:10 PM
> Subject: RE: [OS-webwork] Type conversion
> 
> 
> Do we have docs on that?
> 
> > -----Original Message-----
> > From: Patrick Lightbody [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, October 01, 2003 11:04 AM
> > To: [EMAIL PROTECTED]
> > Subject: Re: [OS-webwork] Type conversion
> >
> >
> > You can convert to and from string very easily. Just 
> register a type 
> > converter for type Foo and that converter will be called for 
> > conversion from a string and conversion to a string.
> >
> > You can also convert on individual fields:
> >
> > MyAction-conversion.properties:
> > blah=com.blah.BlahConverter
> >
> > That will be used for field blah in the class MyAction.
> >
> > -Pat
> >
> >
> > >From: "John Patterson" <[EMAIL PROTECTED]>
> > >Reply-To: [EMAIL PROTECTED]
> > >To: "Webwork" <[EMAIL PROTECTED]>
> > >Subject: [OS-webwork] Type conversion
> > >Date: Wed, 1 Oct 2003 14:41:58 +0100
> > >
> > >What is happening with the type conversion functionality?  I
> > need to be
> > >able to override the conversion both to and from string easily. 
> > >xwork-conversion.properties only allows me to specify one way.
> > >
> > >Is there any plans to allow you to configure a converter
> > seperatly for
> > >each
> > >property?  For example, I have several dates which appear on
> > a page in
> > >different formats.  It would be great to be able to specify
> > in xwork.xml
> > >the format to be used for each property.  Or would this be
> > best handled in
> > >a tag lib (to presentation specific)?
> > >
> > >Maybe if the PropertyTag had a format attribute which was somehow 
> > >passed to the TypeConverter...
> > >
> > ><ww:property value="startDate" format="dd MMM yyyy"/>
> > >
> > >...or something like that.
> > >
> > >John.
> >
> > _________________________________________________________________
> > Instant message in style with MSN Messenger 6.0. Download 
> it now FREE!
> > http://msnmessenger-download.com
> >
> >
> >
> > -------------------------------------------------------
> > This sf.net email is sponsored by:ThinkGeek
> > Welcome to geek heaven.
> > http://thinkgeek.com/sf
> > _______________________________________________
> > Opensymphony-webwork mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork
> >
> 
> 
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Opensymphony-webwork mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork
> 
> 
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Opensymphony-webwork mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork
> 




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to