RE: java.util.Dates and Struts

2002-12-23 Thread Jim Krygowski
Hi Rick-

In the real world case, my form bean is merely a container for collections
of ValueObjects.  It doesn't have any properties outside of getters and
setters for collections.  The value objects within the collections have
java.util.Date properties which I'm interested in rendering to the JSP page.
Nowhere in my application am I storing date information in String objects.

When I sort out how the formatting tags play into this, I'll definitely post
back to the list with the info I discover.  In the mean time, if anyone else
has experience with what we've been discussing (formatting Dates for input
type="text" boxes) please feel free to chime in.

thanks,

jk

> -Original Message-
> From: Rick Reumann [mailto:[EMAIL PROTECTED]]
> Sent: Monday, December 23, 2002 4:54 PM
> To: Struts Users Mailing List
> Subject: Re: java.util.Dates and Struts
>
>
> On Mon, 23 Dec 2002 13:33:59 -0500
> Jim Krygowski <[EMAIL PROTECTED]> wrote:
>
> >
> > As regards the tags, I would like to render an html input type="text".
> >  As
> > far as I know, you can't nest tags so...
> >
> > "/>
> >
> > ...won't work.
>
> I'm almost positive the el tags people mention a lot on this list can do
> this. I'm not sure though since I haven't had the need to do it yet. I
> think the JSTL allows nesting as well but I'm new to them myself so I'm
> not sure. Let me know what you end up using for nesting the format date
> tag in case I end up needing it someday:)
>
> I'm also not sure what business requirements your trying to fill but it
> seems like if you have a "myDate" String property in your form bean it
> probably corresponds to something meaningful across all the value object
> beans as well? In other words I'm having trouble grasping what
> relationship with the form bean and the possible value object doesn't
> match up? Obviously it doesn't or else you could simply use the
> BeanUtils stuff we initially mentioned:)
>
>
> --
> Rick
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: java.util.Dates and Struts

2002-12-23 Thread Rick Reumann
On Mon, 23 Dec 2002 13:33:59 -0500
Jim Krygowski <[EMAIL PROTECTED]> wrote:
 
> 
> As regards the tags, I would like to render an html input type="text".
>  As
> far as I know, you can't nest tags so...
> 
> "/>
> 
> ...won't work.

I'm almost positive the el tags people mention a lot on this list can do
this. I'm not sure though since I haven't had the need to do it yet. I
think the JSTL allows nesting as well but I'm new to them myself so I'm
not sure. Let me know what you end up using for nesting the format date
tag in case I end up needing it someday:)  

I'm also not sure what business requirements your trying to fill but it
seems like if you have a "myDate" String property in your form bean it
probably corresponds to something meaningful across all the value object
beans as well? In other words I'm having trouble grasping what
relationship with the form bean and the possible value object doesn't
match up? Obviously it doesn't or else you could simply use the
BeanUtils stuff we initially mentioned:)


-- 
Rick

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: java.util.Dates and Struts

2002-12-23 Thread Jim Krygowski
Hi Rick-

Yep, you've got it.  I had the formatting tags you suggest in the back of my
mind all along.  But when I saw the converters you created, they looked like
a really elegant solution.  Unfortunately, I sort of forced my own set of
assumptions on them (cognitive dissonance?).  Still, I can use the
String->Date for bringing things back to the JSP which is nice.  Many, many
thanks for that contribution.  Aside from being useful, it pushed me down a
path in the Struts/BeanUtils source code that I had yet to travel.

As regards the tags, I would like to render an html input type="text".  As
far as I know, you can't nest tags so...

"/>

...won't work.

I suppose a Page Context dynamically defined bean might do the trick, but
since I haven't delved into JSTL I'm not sure how to do that.  Are you using
your formatted dates in editable fields.  If so, would you mind sharing how
you're setting up your tags?

thanks.
jk

> -Original Message-
> From: Rick Reumann [mailto:[EMAIL PROTECTED]]
> Sent: Monday, December 23, 2002 3:51 PM
> To: Struts Users Mailing List
> Subject: Re: java.util.Dates and Struts
>
>
> On Mon, 23 Dec 2002 12:32:13 -0500
> Jim Krygowski <[EMAIL PROTECTED]> wrote:
>
> > It seems like the only way things work out properly in the rendering
> > phase is to have a ValueObject that contains the Date properties and
> > an ActionForm that has a String for each Date on the ValueObject.
> > This is what I was originally hoping to avoid.  My ActionForm contains
> > graphs of ValueObjects that I render using the nested tags.  It'd be
> > really painful to come up with a parallel set of ValueObjects that
> > have Strings instead of Dates.
> >
> > Is there any way to get formatted Dates from the  and like
> > tags or am I stuck?
>
> I must be missing something here:) I think I see what you are doing
> now... you are wanting to use the ValueObject in the jsp display. In
> that case why not just use of the tag libraries that display dates in
> whatever format you like. Then you won't even need to bother with the
> converters or BeanUtils. To format Dates in jsp pages I now use the JSTL
> format tags. It's then simply a matter of doing
> 
> I'm sure you could define the pattern globally for the whole page, I
> just was lazy and didn't look into it.
>
> I think that will solve your problem?
>
> --
> Rick
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: java.util.Dates and Struts

2002-12-23 Thread Rick Reumann
On Mon, 23 Dec 2002 12:32:13 -0500
Jim Krygowski <[EMAIL PROTECTED]> wrote:

> It seems like the only way things work out properly in the rendering
> phase is to have a ValueObject that contains the Date properties and
> an ActionForm that has a String for each Date on the ValueObject. 
> This is what I was originally hoping to avoid.  My ActionForm contains
> graphs of ValueObjects that I render using the nested tags.  It'd be
> really painful to come up with a parallel set of ValueObjects that
> have Strings instead of Dates.
> 
> Is there any way to get formatted Dates from the  and like
> tags or am I stuck?

I must be missing something here:) I think I see what you are doing
now... you are wanting to use the ValueObject in the jsp display. In
that case why not just use of the tag libraries that display dates in
whatever format you like. Then you won't even need to bother with the
converters or BeanUtils. To format Dates in jsp pages I now use the JSTL
format tags. It's then simply a matter of doing
 
I'm sure you could define the pattern globally for the whole page, I
just was lazy and didn't look into it.

I think that will solve your problem?

-- 
Rick

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: java.util.Dates and Struts

2002-12-23 Thread Jim Krygowski
It seems like the only way things work out properly in the rendering phase
is to have a ValueObject that contains the Date properties and an ActionForm
that has a String for each Date on the ValueObject.  This is what I was
originally hoping to avoid.  My ActionForm contains graphs of ValueObjects
that I render using the nested tags.  It'd be really painful to come up with
a parallel set of ValueObjects that have Strings instead of Dates.

Is there any way to get formatted Dates from the  and like tags
or am I stuck?



> -Original Message-
> From: Jim Krygowski [mailto:[EMAIL PROTECTED]]
> Sent: Monday, December 23, 2002 12:24 PM
> To: Struts Users Mailing List
> Subject: RE: java.util.Dates and Struts
>
>
> Hi Rick-
>
> I should have deleted the first block of code.  It's not exactly
> misleading,
> but it unfocuses my point.  I apologise for that.  I'm spread a
> little thin
> so the email quality control is suffering ;-).
>
> The key thing to notice is this:
>
> 1.HashMap values = new HashMap();
> 2.values.put("today", "2002-03-17");
>
> 3.MockForm mockForm = new MockForm();
> 4.BeanUtils.copyProperties(mockForm, values);
> 5.System.out.println(mockForm.getToday());
> 6.Map beanProps = BeanUtils.describe(mockForm);
> 7.System.out.println(beanProps.get("today"));
>
>
> On line 4, the code successfully transforms a String into a Date
> and stores
> it in the form MockForm.  On line 6, I try to get that value out of the
> MockForm (where it is stored as a Date) and into beanProps which
> is a Map of
> the Stringified values of all the getters on MockForm.  The date
> string that
> ends up in beanProps is not formatted.
>
> jk
>
> > -Original Message-
> > From: Rick Reumann [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, December 23, 2002 3:07 PM
> > Cc: [EMAIL PROTECTED]
> > Subject: Re: java.util.Dates and Struts
> >
> >
> > On Mon, 23 Dec 2002 11:49:04 -0500
> > Jim Krygowski <[EMAIL PROTECTED]> wrote:
> >
> > > This is my test:
> > > ...
> > >   String input = null;
> > >
> > >   // check to make sure the datatype is right
> > >   input = "2002-03-17";
> > >   Date dateValue = (Date)ConvertUtils.convert(input, Date.class);
> > >   assertTrue(dateValue instanceof Date);
> >
> > But where is this dateValue being used? You saying it's not converting
> > java.util.Date to a String properly for you yet I don't see this Date
> > being used anywhere to even allow it be converted to the String in the
> > correct format.
> >
> > >
> > >   // try to get a value from a Map
> > >   HashMap values = new HashMap();
> > >   values.put("today", "2002-03-17");
> > >   MockForm mockForm = new MockForm();
> > >   BeanUtils.copyProperties(mockForm, values);
> >
> >
> > Isn't your concern going the other direction that is having you
> > stumped? In other words here you are just doing a String to String
> > conversion. Why don't you create a Bean that has java.util.Date field
> > and then do
> > BeanUtils.copyProperties(mockForm, theObjectThatHasAdateField );
> > Then try
> >
> > >   Map beanProps = BeanUtils.describe(mockForm);
> > >   System.out.println(beanProps.get("today"));
> >
> >
> >
> > --
> > Rick
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> >
> >
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: java.util.Dates and Struts

2002-12-23 Thread Jim Krygowski
Hi Rick-

I should have deleted the first block of code.  It's not exactly misleading,
but it unfocuses my point.  I apologise for that.  I'm spread a little thin
so the email quality control is suffering ;-).

The key thing to notice is this:

1.HashMap values = new HashMap();
2.values.put("today", "2002-03-17");

3.MockForm mockForm = new MockForm();
4.BeanUtils.copyProperties(mockForm, values);
5.System.out.println(mockForm.getToday());
6.Map beanProps = BeanUtils.describe(mockForm);
7.System.out.println(beanProps.get("today"));


On line 4, the code successfully transforms a String into a Date and stores
it in the form MockForm.  On line 6, I try to get that value out of the
MockForm (where it is stored as a Date) and into beanProps which is a Map of
the Stringified values of all the getters on MockForm.  The date string that
ends up in beanProps is not formatted.

jk

> -Original Message-
> From: Rick Reumann [mailto:[EMAIL PROTECTED]]
> Sent: Monday, December 23, 2002 3:07 PM
> Cc: [EMAIL PROTECTED]
> Subject: Re: java.util.Dates and Struts
>
>
> On Mon, 23 Dec 2002 11:49:04 -0500
> Jim Krygowski <[EMAIL PROTECTED]> wrote:
>
> > This is my test:
> > ...
> > String input = null;
> >
> >   // check to make sure the datatype is right
> >   input = "2002-03-17";
> >   Date dateValue = (Date)ConvertUtils.convert(input, Date.class);
> >   assertTrue(dateValue instanceof Date);
>
> But where is this dateValue being used? You saying it's not converting
> java.util.Date to a String properly for you yet I don't see this Date
> being used anywhere to even allow it be converted to the String in the
> correct format.
>
> >
> >   // try to get a value from a Map
> > HashMap values = new HashMap();
> >   values.put("today", "2002-03-17");
> >   MockForm mockForm = new MockForm();
> >   BeanUtils.copyProperties(mockForm, values);
>
>
> Isn't your concern going the other direction that is having you
> stumped? In other words here you are just doing a String to String
> conversion. Why don't you create a Bean that has java.util.Date field
> and then do
> BeanUtils.copyProperties(mockForm, theObjectThatHasAdateField );
> Then try
>
> >   Map beanProps = BeanUtils.describe(mockForm);
> >   System.out.println(beanProps.get("today"));
>
>
>
> --
> Rick
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: java.util.Dates and Struts

2002-12-23 Thread Rick Reumann
On Mon, 23 Dec 2002 11:49:04 -0500
Jim Krygowski <[EMAIL PROTECTED]> wrote:
 
> This is my test:
> ...
>   String input = null;
> 
>   // check to make sure the datatype is right
>   input = "2002-03-17";
>   Date dateValue = (Date)ConvertUtils.convert(input, Date.class);
>   assertTrue(dateValue instanceof Date);

But where is this dateValue being used? You saying it's not converting
java.util.Date to a String properly for you yet I don't see this Date
being used anywhere to even allow it be converted to the String in the
correct format.

> 
>   // try to get a value from a Map
>   HashMap values = new HashMap();
>   values.put("today", "2002-03-17");
>   MockForm mockForm = new MockForm();
>   BeanUtils.copyProperties(mockForm, values);


Isn't your concern going the other direction that is having you
stumped? In other words here you are just doing a String to String
conversion. Why don't you create a Bean that has java.util.Date field
and then do 
BeanUtils.copyProperties(mockForm, theObjectThatHasAdateField ); 
Then try 

>   Map beanProps = BeanUtils.describe(mockForm);
>   System.out.println(beanProps.get("today"));

 

-- 
Rick

--
To unsubscribe, e-mail:   
For additional commands, e-mail: