Re: Making Value Objects Into Form Objects

2003-06-19 Thread florian


hi!

its funny how this thing comes up every two weeks on the list =)

i got to admit that at first the solution of having value objects/dtos
in an actionform sounded great and making things easy in the
action.. no more endless accessor calling..
but after thinking about it for a while and some playing around
with the different possible solutions i figured two things:
1) i misunderstood/misused what actionforms are. it seems like
some kind of hack to expose the vos so far out to the client layer.
2) things get ugly when you want to redisplay invalid input 'foo22'
for an int property for example..
ciao!
florian


On Mittwoch, Juni 18, 2003, at 05:07  Uhr, Weissman, Alan wrote:

Ok so I'm a little new to Struts but not J2EE and I've been noticing 
that my
Value Objects that come out of EJB's in my data layer are the exact 
same
objects as the ActionForms that are used by Strutsand I'm sure I'm 
not
the first to notice this.

So here's my question:  How can I make one class that can serve as 
both an
ActionForm and a ValueObject?

The problems with solutions that I've brainstormed are this:

1) I can't make my Value Objects extend ActionForm for obvious reasons.
2) I would rather not use an interface to get around this issue 
because then
I have two classes to maintain again.

Thanks for any advice!

Alan

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




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


Re: Making Value Objects Into Form Objects

2003-06-18 Thread Sandeep Takhar
This is similar to what we do.

We don't use copyProperties, but toDvo and fromDvo.

Just re-read Ted's book and he was talking about using
the formatting stuff on the Dvo and not the PDvo.

I haven't tried this, but it seems more right for some
reason.  Maybe it is business logic?

Maybe having a DateHolder and having this on the DVO
(or DTO if you call it that) and any other holders,
makes more sense...

I think I will try this next...

sandeep
--- Dave Ladd <[EMAIL PROTECTED]> wrote:
> We are using DynaForms and rather than define the
> attributes within
> struts-config, our approach to this problem was to
> create a PVO
> (presentation view objects) class which is basically
> a mirror of the VO but
> with the attributes defined as Strings.
> 
> The PVO is then defined as a property of a FormBean
> within the
> struts-config.  Population between the VO and PVO is
> done via
> BeanUtils.copyProperties.
> 
> By doing this, the size of the struts-config is
> reduced (probably not a big
> deal) and we gain some flexibility in being able to
> do any needed formatting
> within the PVO.  In addition, we quite often use
> these PVOs when we are
> building lists that are not part of the form itself.
>  We can also "mix and
> match" our PVOs within a FormBean which has proven
> helpful in a couple of
> situations.
> 
> The biggest drawback (that we are aware of) is that
> we have to create
> another class for each VO but this isn't much a
> hassle given the IDEs that
> are available.
> 
> 
>
-
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 


__
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

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



RE: Making Value Objects Into Form Objects

2003-06-18 Thread Raible, Matt
You are correct.  UserFormEx is an extension of the generated UserForm.
Reason:  I don't want to put any form-specific stuff in my User object (why
should it care about UI stuff like indexed properties and the reset() and
validate() method).  This allows me to *Ex*tend the form. ;0)

I only need to create an extension form when I have indexed properties,
custom validation (the validate() method) or checkboxes (the reset()
method).

HTH,

Matt

-Original Message-
From: Shane Mingins [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 18, 2003 4:07 PM
To: 'Struts Users Mailing List'
Subject: RE: Making Value Objects Into Form Objects


Hi Matt

I was just browsing thru your source code.  I am not familiar with XDoclet
but have I got this correct...

You have UserForm (generated from User using XDoclet) which extends BaseForm
and then have UserFormEx extending UserForm.

Boy that was a mouthful :-)

Cheers
Shane



>Of course, you can download the entire project (that has these examples in
>it) at http://raibledesigns.com/wiki/Wiki.jsp?page=AppFuse.

>HTH,

>Matt



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

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



RE: Making Value Objects Into Form Objects

2003-06-18 Thread Shane Mingins
Hi Matt

I was just browsing thru your source code.  I am not familiar with XDoclet
but have I got this correct...

You have UserForm (generated from User using XDoclet) which extends BaseForm
and then have UserFormEx extending UserForm.

Boy that was a mouthful :-)

Cheers
Shane



>Of course, you can download the entire project (that has these examples in
>it) at http://raibledesigns.com/wiki/Wiki.jsp?page=AppFuse.

>HTH,

>Matt



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



Re: Making Value Objects Into Form Objects

2003-06-18 Thread Alen Ribic

- Original Message -
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, June 18, 2003 5:59 PM
Subject: RE: Making Value Objects Into Form Objects


>But can i have a beanList inside dynaAction form?Or the properties of the
dynaFOrm need to >be scaler properties?
>Because for me having nested beans is very important to have a proper OO
design.

To my knowledge, ActionForms are mainly used as means of collecting string
base input data from a form.
In which situation may you need nested beans as reference types?

Can you give me a clearer picture as to what you are going to be needing
nested beans for in your ActionForms to stick to proper OO design?

--Alen

>This is the only point holding me back.Any ideas?

-Original Message-
From: Alen Ribic [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 18, 2003 5:15 PM
To: Struts Users Mailing List
Subject: Re: Making Value Objects Into Form Objects



- Original Message -
From: "Weissman, Alan" <[EMAIL PROTECTED]>
To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
Sent: Wednesday, June 18, 2003 5:07 PM
Subject: Making Value Objects Into Form Objects


>
> Ok so I'm a little new to Struts but not J2EE and I've been noticing that
my
> Value Objects that come out of EJB's in my data layer are the exact same
> objects as the ActionForms that are used by Strutsand I'm sure I'm not
> the first to notice this.
>
> So here's my question:  How can I make one class that can serve as both an
> ActionForm and a ValueObject?

use org.apache.struts.action.DynaActionForm (Or one of the Dyna validator
form classes)
and define form-bean in struts config file.

This way you will not need to define a ActionFrom for every form you work
with.

Then you use BeanUtils.copyProperties(...); method to copy bean properties
from one to you value object.

--Alen

>
> The problems with solutions that I've brainstormed are this:
>
> 1) I can't make my Value Objects extend ActionForm for obvious reasons.
> 2) I would rather not use an interface to get around this issue because
then
> I have two classes to maintain again.
>
> Thanks for any advice!
>
> Alan
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


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


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





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



Re: Making Value Objects Into Form Objects

2003-06-18 Thread Dave Ladd
We are using DynaForms and rather than define the attributes within
struts-config, our approach to this problem was to create a PVO
(presentation view objects) class which is basically a mirror of the VO but
with the attributes defined as Strings.

The PVO is then defined as a property of a FormBean within the
struts-config.  Population between the VO and PVO is done via
BeanUtils.copyProperties.

By doing this, the size of the struts-config is reduced (probably not a big
deal) and we gain some flexibility in being able to do any needed formatting
within the PVO.  In addition, we quite often use these PVOs when we are
building lists that are not part of the form itself.  We can also "mix and
match" our PVOs within a FormBean which has proven helpful in a couple of
situations.

The biggest drawback (that we are aware of) is that we have to create
another class for each VO but this isn't much a hassle given the IDEs that
are available.


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



Re: Making Value Objects Into Form Objects

2003-06-18 Thread Erik Price


Adam Hardy wrote:
You think one day HTTP will allow real types like int and date?
Let's hope not!  KISS.
You can use SOAP for something like that.
;)

Erik

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


Re: Making Value Objects Into Form Objects

2003-06-18 Thread Adam Hardy
You think one day HTTP will allow real types like int and date?

Ted Husted wrote:
Unless your value objects are expressly designed to act as 
presentation-layer data transfer objects, you are liable to run into 
problems when you try this in production.

In practice, ActionForms are the missing String buffer for the HTML 
controls. It's the place where you can tuck the incoming Strings until 
you have a chance to look at it and decide whether or not to carry it up 
to the business layer.

If the ActionForm properties look like your value objects, it's because 
the *HTML forms* look like your value objects. Eventually, one or the 
others of these will start to change, and then you will be stuck.

In Struts 1.1, the DynaActionForms severely mitigate the issue of 
maintaining two classes. You only need to maintain a lightweight XML 
description of the HTML controls, and Struts will make that into a 
JavaBean for you. Once you have vetted the Strings, you can then use 
BeanUtil.CopyProperties to transfer and convert the validated input.

Before long, you may also find that you need to transfer the data to 
more than one value object. In that case, you could add properties to 
your DynaActionForm and transfer the properties to whatever value 
objects need to know.

It is possible to use a business class for an ActionForm, if it was 
designed to be used that way from the beginning. But that really only 
works if the beans are being used as a data transfer object on its way 
to a business facade.

If this is how your value objects where designed, then you could 
implement the interface as an ActionForm, and then pass that to the facade.

But if you already have an implementation of the value objects, you 
would probably be better off using the DynaActionForm. The next 
alternative after that is to wrap the value object in an adaptor, but 
that won't save you any maintenance.

A lot of people do feel that the ActionForm should be an interface. 
Since more and more new applications are being designed with MVC in 
mind, this does start to make some sense. But, Craig would veto that as 
a product change, so using an interface for an input form could only be 
done using alternative RequestProcessor or something.

-Ted.

Weissman, Alan wrote:

Ok so I'm a little new to Struts but not J2EE and I've been noticing 
that my
Value Objects that come out of EJB's in my data layer are the exact same
objects as the ActionForms that are used by Strutsand I'm sure I'm 
not
the first to notice this.

So here's my question:  How can I make one class that can serve as 
both an
ActionForm and a ValueObject? 
The problems with solutions that I've brainstormed are this:

1) I can't make my Value Objects extend ActionForm for obvious reasons.
2) I would rather not use an interface to get around this issue 
because then
I have two classes to maintain again.

Thanks for any advice!

Alan

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





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


Re: Making Value Objects Into Form Objects

2003-06-18 Thread Ted Husted
Unless your value objects are expressly designed to act as 
presentation-layer data transfer objects, you are liable to run into 
problems when you try this in production.

In practice, ActionForms are the missing String buffer for the HTML 
controls. It's the place where you can tuck the incoming Strings until 
you have a chance to look at it and decide whether or not to carry it up 
to the business layer.

If the ActionForm properties look like your value objects, it's because 
the *HTML forms* look like your value objects. Eventually, one or the 
others of these will start to change, and then you will be stuck.

In Struts 1.1, the DynaActionForms severely mitigate the issue of 
maintaining two classes. You only need to maintain a lightweight XML 
description of the HTML controls, and Struts will make that into a 
JavaBean for you. Once you have vetted the Strings, you can then use 
BeanUtil.CopyProperties to transfer and convert the validated input.

Before long, you may also find that you need to transfer the data to 
more than one value object. In that case, you could add properties to 
your DynaActionForm and transfer the properties to whatever value 
objects need to know.

It is possible to use a business class for an ActionForm, if it was 
designed to be used that way from the beginning. But that really only 
works if the beans are being used as a data transfer object on its way 
to a business facade.

If this is how your value objects where designed, then you could 
implement the interface as an ActionForm, and then pass that to the facade.

But if you already have an implementation of the value objects, you 
would probably be better off using the DynaActionForm. The next 
alternative after that is to wrap the value object in an adaptor, but 
that won't save you any maintenance.

A lot of people do feel that the ActionForm should be an interface. 
Since more and more new applications are being designed with MVC in 
mind, this does start to make some sense. But, Craig would veto that as 
a product change, so using an interface for an input form could only be 
done using alternative RequestProcessor or something.

-Ted.

Weissman, Alan wrote:
Ok so I'm a little new to Struts but not J2EE and I've been noticing that my
Value Objects that come out of EJB's in my data layer are the exact same
objects as the ActionForms that are used by Strutsand I'm sure I'm not
the first to notice this.
So here's my question:  How can I make one class that can serve as both an
ActionForm and a ValueObject?  

The problems with solutions that I've brainstormed are this:

1) I can't make my Value Objects extend ActionForm for obvious reasons.
2) I would rather not use an interface to get around this issue because then
I have two classes to maintain again.
Thanks for any advice!

Alan

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



--
Ted Husted,
Struts in Action 


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


RE: Making Value Objects Into Form Objects

2003-06-18 Thread Raible, Matt
When I first started developing with Struts (pre 1.0), I'd just have a
simple form with a DTO (VO back then) as a getter/setter on my form.  In the
last year, I've changed to have a DTO and a Form, where the DTO has the true
data types (Long, Date, etc) and the form has only Strings.  After doing it
both ways, it seems like the DTO as a getter/setter is really the better way
to go.  I'm not trying to say it's the *right* way according to the design
patterns, I'm just offering my $.02 from experience. I continue to do it the
BeanUtils.copyProperties() way, but the projects I work on that do it the
other way seem cleaner.

For an example of a DTO -> BeanUtils.copyProperties() -> Form, check out the
following links:

DTO -> User.java (source: http://tinyurl.com/emo7)
Conversion -> UserManagerImpl.java (source: http://tinyurl.com/emof - see
convert() method).  This extends BaseManager (http://tinyurl.com/emok),
which registers custom converters.  No DateConverter in this example, but
I've done it at my day job, so I know it's fairly easy.
Form -> UserForm.java (generated via XDoclet from User.java)

Of course, you can download the entire project (that has these examples in
it) at http://raibledesigns.com/wiki/Wiki.jsp?page=AppFuse.

HTH,

Matt

-Original Message-
From: Blake Whitmore [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 18, 2003 9:55 AM
To: Struts Users Mailing List
Subject: RE: Making Value Objects Into Form Objects


Hey Alan,

It seems to be a pretty popular mechanism out there.
Anyone else have any other ideas? And Alan, dig deeper
into the API - it does more conversions than you think
:)  

For a while I had protected (my form would be in the
same package as my action) 'convienence methods' for
converting between value objects and actionforms. 
Later I went to using another layer of indirection
with a separate class.  But, using the BeanUtils has
made my life easier.  Be careful with 'Date' things
though.  Good luck.

-Blake

--- "Weissman, Alan" <[EMAIL PROTECTED]> wrote:
> Thanks Blake!
> This doesn't seem as comprehensive a tool or design
> pattern as I would have
> liked.  Is this what everyone is using?  It seems
> like a lot of work,
> especially because it doesn't do data type
> conversions for you!
> Alan
> 
> -Original Message-
> From: Blake Whitmore
> [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, June 18, 2003 11:14 AM
> To: Struts Users Mailing List
> Subject: Re: Making Value Objects Into Form Objects
> 
> 
> Alan,
> 
> A good tool for this is the
>
org.apache.commons.beanutils.BeanUtils.copyProperties()
> method.
> 
>
http://jakarta.apache.org/commons/beanutils/api/org/apache/commons/beanutils
> /BeanUtils.html
> 
> 
> 
> 
> --- "Weissman, Alan" <[EMAIL PROTECTED]> wrote:
> > 
> > Ok so I'm a little new to Struts but not J2EE and
> > I've been noticing that my
> > Value Objects that come out of EJB's in my data
> > layer are the exact same
> > objects as the ActionForms that are used by
> > Strutsand I'm sure I'm not
> > the first to notice this.
> > 
> > So here's my question:  How can I make one class
> > that can serve as both an
> > ActionForm and a ValueObject?  
> > 
> > The problems with solutions that I've brainstormed
> > are this:
> > 
> > 1) I can't make my Value Objects extend ActionForm
> > for obvious reasons.
> > 2) I would rather not use an interface to get
> around
> > this issue because then
> > I have two classes to maintain again.
> > 
> > Thanks for any advice!
> > 
> > Alan
> > 
> > 
> >
>
-
> > To unsubscribe, e-mail:
> > [EMAIL PROTECTED]
> > For additional commands, e-mail:
> > [EMAIL PROTECTED]
> > 
> 
> 
> __
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
> http://sbc.yahoo.com
> 
>
-
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 
>
-
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 


__
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

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

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



RE: Making Value Objects Into Form Objects

2003-06-18 Thread Weissman, Alan
I found this:

http://www.mycgiserver.com/~andrej/technical/struts/struts.jsp

are people using this?  cause it looks perfect


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 18, 2003 11:59 AM
To: [EMAIL PROTECTED]
Subject: RE: Making Value Objects Into Form Objects


But can i have a beanList inside dynaAction form?Or the properties of the
dynaFOrm need to be scaler properties?
Because for me having nested beans is very important to have a proper OO
design.

This is the only point holding me back.Any ideas?

-Original Message-
From: Alen Ribic [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 18, 2003 5:15 PM
To: Struts Users Mailing List
Subject: Re: Making Value Objects Into Form Objects



- Original Message -
From: "Weissman, Alan" <[EMAIL PROTECTED]>
To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
Sent: Wednesday, June 18, 2003 5:07 PM
Subject: Making Value Objects Into Form Objects


>
> Ok so I'm a little new to Struts but not J2EE and I've been noticing that
my
> Value Objects that come out of EJB's in my data layer are the exact same
> objects as the ActionForms that are used by Strutsand I'm sure I'm not
> the first to notice this.
>
> So here's my question:  How can I make one class that can serve as both an
> ActionForm and a ValueObject?

use org.apache.struts.action.DynaActionForm (Or one of the Dyna validator
form classes)
and define form-bean in struts config file.

This way you will not need to define a ActionFrom for every form you work
with.

Then you use BeanUtils.copyProperties(...); method to copy bean properties
from one to you value object.

--Alen

>
> The problems with solutions that I've brainstormed are this:
>
> 1) I can't make my Value Objects extend ActionForm for obvious reasons.
> 2) I would rather not use an interface to get around this issue because
then
> I have two classes to maintain again.
>
> Thanks for any advice!
>
> Alan
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


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


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

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



RE: Making Value Objects Into Form Objects

2003-06-18 Thread shirishchandra.sakhare
But can i have a beanList inside dynaAction form?Or the properties of the dynaFOrm 
need to be scaler properties?
Because for me having nested beans is very important to have a proper OO design.

This is the only point holding me back.Any ideas?

-Original Message-
From: Alen Ribic [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 18, 2003 5:15 PM
To: Struts Users Mailing List
Subject: Re: Making Value Objects Into Form Objects



- Original Message -
From: "Weissman, Alan" <[EMAIL PROTECTED]>
To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
Sent: Wednesday, June 18, 2003 5:07 PM
Subject: Making Value Objects Into Form Objects


>
> Ok so I'm a little new to Struts but not J2EE and I've been noticing that
my
> Value Objects that come out of EJB's in my data layer are the exact same
> objects as the ActionForms that are used by Strutsand I'm sure I'm not
> the first to notice this.
>
> So here's my question:  How can I make one class that can serve as both an
> ActionForm and a ValueObject?

use org.apache.struts.action.DynaActionForm (Or one of the Dyna validator
form classes)
and define form-bean in struts config file.

This way you will not need to define a ActionFrom for every form you work
with.

Then you use BeanUtils.copyProperties(...); method to copy bean properties
from one to you value object.

--Alen

>
> The problems with solutions that I've brainstormed are this:
>
> 1) I can't make my Value Objects extend ActionForm for obvious reasons.
> 2) I would rather not use an interface to get around this issue because
then
> I have two classes to maintain again.
>
> Thanks for any advice!
>
> Alan
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


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


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



RE: Making Value Objects Into Form Objects

2003-06-18 Thread Blake Whitmore
Hey Alan,

It seems to be a pretty popular mechanism out there.
Anyone else have any other ideas? And Alan, dig deeper
into the API - it does more conversions than you think
:)  

For a while I had protected (my form would be in the
same package as my action) 'convienence methods' for
converting between value objects and actionforms. 
Later I went to using another layer of indirection
with a separate class.  But, using the BeanUtils has
made my life easier.  Be careful with 'Date' things
though.  Good luck.

-Blake

--- "Weissman, Alan" <[EMAIL PROTECTED]> wrote:
> Thanks Blake!
> This doesn't seem as comprehensive a tool or design
> pattern as I would have
> liked.  Is this what everyone is using?  It seems
> like a lot of work,
> especially because it doesn't do data type
> conversions for you!
> Alan
> 
> -Original Message-
> From: Blake Whitmore
> [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, June 18, 2003 11:14 AM
> To: Struts Users Mailing List
> Subject: Re: Making Value Objects Into Form Objects
> 
> 
> Alan,
> 
> A good tool for this is the
>
org.apache.commons.beanutils.BeanUtils.copyProperties()
> method.
> 
>
http://jakarta.apache.org/commons/beanutils/api/org/apache/commons/beanutils
> /BeanUtils.html
> 
> 
> 
> 
> --- "Weissman, Alan" <[EMAIL PROTECTED]> wrote:
> > 
> > Ok so I'm a little new to Struts but not J2EE and
> > I've been noticing that my
> > Value Objects that come out of EJB's in my data
> > layer are the exact same
> > objects as the ActionForms that are used by
> > Strutsand I'm sure I'm not
> > the first to notice this.
> > 
> > So here's my question:  How can I make one class
> > that can serve as both an
> > ActionForm and a ValueObject?  
> > 
> > The problems with solutions that I've brainstormed
> > are this:
> > 
> > 1) I can't make my Value Objects extend ActionForm
> > for obvious reasons.
> > 2) I would rather not use an interface to get
> around
> > this issue because then
> > I have two classes to maintain again.
> > 
> > Thanks for any advice!
> > 
> > Alan
> > 
> > 
> >
>
-
> > To unsubscribe, e-mail:
> > [EMAIL PROTECTED]
> > For additional commands, e-mail:
> > [EMAIL PROTECTED]
> > 
> 
> 
> __
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
> http://sbc.yahoo.com
> 
>
-
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 
>
-
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 


__
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

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



RE: Making Value Objects Into Form Objects

2003-06-18 Thread Weissman, Alan
Thanks Blake!
This doesn't seem as comprehensive a tool or design pattern as I would have
liked.  Is this what everyone is using?  It seems like a lot of work,
especially because it doesn't do data type conversions for you!
Alan

-Original Message-
From: Blake Whitmore [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 18, 2003 11:14 AM
To: Struts Users Mailing List
Subject: Re: Making Value Objects Into Form Objects


Alan,

A good tool for this is the
org.apache.commons.beanutils.BeanUtils.copyProperties()
method.

http://jakarta.apache.org/commons/beanutils/api/org/apache/commons/beanutils
/BeanUtils.html




--- "Weissman, Alan" <[EMAIL PROTECTED]> wrote:
> 
> Ok so I'm a little new to Struts but not J2EE and
> I've been noticing that my
> Value Objects that come out of EJB's in my data
> layer are the exact same
> objects as the ActionForms that are used by
> Strutsand I'm sure I'm not
> the first to notice this.
> 
> So here's my question:  How can I make one class
> that can serve as both an
> ActionForm and a ValueObject?  
> 
> The problems with solutions that I've brainstormed
> are this:
> 
> 1) I can't make my Value Objects extend ActionForm
> for obvious reasons.
> 2) I would rather not use an interface to get around
> this issue because then
> I have two classes to maintain again.
> 
> Thanks for any advice!
> 
> Alan
> 
> 
>
-
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 


__
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

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

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



RE: Making Value Objects Into Form Objects

2003-06-18 Thread Wendy Smoak
Alan wrote:
> Ok so I'm a little new to Struts but not J2EE and I've been noticing 
> that my Value Objects that come out of EJB's in my data layer are the 
> exact same objects as the ActionForms that are used by Strutsand 
> I'm sure I'm not the first to notice this.

It comes down to still needing two classes, because the minute you say, "ALL
of my forms are EXACTLY like my Value Objects," you'll find one that isn't.
;)

But you can generate the code (Xdoclet?) or use Dynamic Forms (I use
DynaValidatorForm) to keep from having to code all the get/set methods
manually, and then use BeanUtils.copyProperties to pour the data back and
forth.

I wouldn't try to use the same class, it just doesn't seem like a good idea
and is likely to come back to haunt you later.

-- 
Wendy Smoak
Applications Systems Analyst, Sr.
Public Affairs, Information Resources Management
Arizona State University, Tempe AZ 


Re: Making Value Objects Into Form Objects

2003-06-18 Thread Adam Hardy
Hi Alan,
you could place the value bean in the form with a setValueObject() 
method on the form.

In your JSP you could use indexed tags to get to the bean, e.g. for 
property getTitle()



Adam

Weissman, Alan wrote:
Ok so I'm a little new to Struts but not J2EE and I've been noticing that my
Value Objects that come out of EJB's in my data layer are the exact same
objects as the ActionForms that are used by Strutsand I'm sure I'm not
the first to notice this.
So here's my question:  How can I make one class that can serve as both an
ActionForm and a ValueObject?  

The problems with solutions that I've brainstormed are this:

1) I can't make my Value Objects extend ActionForm for obvious reasons.
2) I would rather not use an interface to get around this issue because then
I have two classes to maintain again.
Thanks for any advice!

Alan

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



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


Re: Making Value Objects Into Form Objects

2003-06-18 Thread Alen Ribic
Also check description and known subclasses
http://jakarta.apache.org/struts/api/org/apache/struts/action/DynaActionForm
.html

--Alen


- Original Message -
From: "Alen Ribic" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Wednesday, June 18, 2003 5:15 PM
Subject: Re: Making Value Objects Into Form Objects


>
> - Original Message -
> From: "Weissman, Alan" <[EMAIL PROTECTED]>
> To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
> Sent: Wednesday, June 18, 2003 5:07 PM
> Subject: Making Value Objects Into Form Objects
>
>
> >
> > Ok so I'm a little new to Struts but not J2EE and I've been noticing
that
> my
> > Value Objects that come out of EJB's in my data layer are the exact same
> > objects as the ActionForms that are used by Strutsand I'm sure I'm
not
> > the first to notice this.
> >
> > So here's my question:  How can I make one class that can serve as both
an
> > ActionForm and a ValueObject?
>
> use org.apache.struts.action.DynaActionForm (Or one of the Dyna validator
> form classes)
> and define form-bean in struts config file.
>
> This way you will not need to define a ActionFrom for every form you work
> with.
>
> Then you use BeanUtils.copyProperties(...); method to copy bean properties
> from one to you value object.
>
> --Alen
>
> >
> > The problems with solutions that I've brainstormed are this:
> >
> > 1) I can't make my Value Objects extend ActionForm for obvious reasons.
> > 2) I would rather not use an interface to get around this issue because
> then
> > I have two classes to maintain again.
> >
> > Thanks for any advice!
> >
> > Alan
> >
> >
> > -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


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



Re: Making Value Objects Into Form Objects

2003-06-18 Thread Alen Ribic

- Original Message -
From: "Weissman, Alan" <[EMAIL PROTECTED]>
To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
Sent: Wednesday, June 18, 2003 5:07 PM
Subject: Making Value Objects Into Form Objects


>
> Ok so I'm a little new to Struts but not J2EE and I've been noticing that
my
> Value Objects that come out of EJB's in my data layer are the exact same
> objects as the ActionForms that are used by Strutsand I'm sure I'm not
> the first to notice this.
>
> So here's my question:  How can I make one class that can serve as both an
> ActionForm and a ValueObject?

use org.apache.struts.action.DynaActionForm (Or one of the Dyna validator
form classes)
and define form-bean in struts config file.

This way you will not need to define a ActionFrom for every form you work
with.

Then you use BeanUtils.copyProperties(...); method to copy bean properties
from one to you value object.

--Alen

>
> The problems with solutions that I've brainstormed are this:
>
> 1) I can't make my Value Objects extend ActionForm for obvious reasons.
> 2) I would rather not use an interface to get around this issue because
then
> I have two classes to maintain again.
>
> Thanks for any advice!
>
> Alan
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


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



Re: Making Value Objects Into Form Objects

2003-06-18 Thread Blake Whitmore
Alan,

A good tool for this is the
org.apache.commons.beanutils.BeanUtils.copyProperties()
method.

http://jakarta.apache.org/commons/beanutils/api/org/apache/commons/beanutils/BeanUtils.html




--- "Weissman, Alan" <[EMAIL PROTECTED]> wrote:
> 
> Ok so I'm a little new to Struts but not J2EE and
> I've been noticing that my
> Value Objects that come out of EJB's in my data
> layer are the exact same
> objects as the ActionForms that are used by
> Strutsand I'm sure I'm not
> the first to notice this.
> 
> So here's my question:  How can I make one class
> that can serve as both an
> ActionForm and a ValueObject?  
> 
> The problems with solutions that I've brainstormed
> are this:
> 
> 1) I can't make my Value Objects extend ActionForm
> for obvious reasons.
> 2) I would rather not use an interface to get around
> this issue because then
> I have two classes to maintain again.
> 
> Thanks for any advice!
> 
> Alan
> 
> 
>
-
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 


__
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

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