How do I format a GregorianCalendar when writing a bean to HTML using
Struts taglibs? (1.1 release candidate)
endDate is a GregorianCalendar.
<logic:iterate id="opt" name="optionsForm" property="options">
<TR>
<TD><bean:write name="opt" property='leadTime' /></TD>
<TD><bean:write name="opt" property='increment' /></TD>
<TD><bean:write name="opt" property='endOption' /></TD>
<TD><bean:write name="opt" property='endDate' /></TD>
</TR>
</logic:iterate>
Thanks,
--Amy
The best way to do this (in my previous experience) is within your
Action. Stuts works in this manner.
From your view component, you initiate an Action.
Within your Action you delegate to your business tier (likely passing
and receiving Serializable ValueObjects)
Your ValueObject is something that models your datastore. So within
your Action you should be using Struts (presentation tier specific)
resources to send back to your JSP. So.. instead of worrying about
how the tag operates with values that aren't Strings you should do the
following:
Take your the value object and convert it into an ActionForm
(ActionForms typically take the shape of Strings and possibly
Collections). So, your Date property should be converted to a String
in your Action and passed along to your JSP. In the past, my action
forms were typically always contained String properties and then a
collection or two *(probably something similar to your 'optionsForm')
that were comprised of my value objects. After the headaches of
clearly displaying my data in the JSP when it came to things such as
Dates, I have taken a new approach. Now the collections that reside
in my ActionForm are not comprised of ValueObjects, but are now
comprised of ActionForms. This takes a bit more work in the Action,
but pays off big time in the JSP. I'm sorry if this isn't all too
clear - let me know if I can help more.
Brock
amy_...@hermanmiller.com (Amy Smith) wrote in message news:<6cb3ad10.03061...@posting.google.com>...
Thanks Brock.
Is there anyone who knows how to format a Gregorian Calendar from a
jsp using Struts taglibs?
If it is not possible with a Struts tag, the alternatives, as I see
them are:
1. Format in the Action.
2. Traditional jsp coding
3. JSTL
I'd like to avoid installing JSTL on top of Struts as the only use I
have for it right now is date and number formatting. Our MVC is very
good and there is little need for processing inside the jsp. Of
course, if this is the best way to go...
Argh, something so simple. Whoever designed dates in java should be
lined up against the wall.... Oops, sorry.
bro...@hotmail.com (Brock Heinz) wrote in message news:<8c84c600.03061...@posting.google.com>...
for example:
<bean:write name="opt" property="endDate"
formatKey="display.date.format" />
ApplicationResources.properties
display.date.format=mm/dd/yyyy
I have used this successfully with Date objects, not sure about
GregorianCalendar, but give it a shot.
I ended up coding a custom tag. I added null checking with default
values and date formatting for GregorianCalendar.
Works fine.
Thanks all
Amy Smith.
ebr...@yahoo.com (ebrusse) wrote in message news:<86fd12b8.03063...@posting.google.com>...