RE: MVC Design: property in ActionForm or Bean with property in ActionForm ?

2002-10-31 Thread Andrew Hill
Technically speaking, the ActionForm IS a bean.
It's purpose is to represent the users input (which you can validate and if
necessary redisplay for correction) before transferring in your action the
(validated) values (with appropriate type conversion) to your business
object and vice versa.
Your BO itself may well be a bean too - such as your BookBean perhaps?
The actionForm and the business object will of course have a very similar
(often identical) set of properties, however they serve different purposes -
for example you will note that while your BOs beans would have various
property types (ie: int for pages etc...) you ActionForm will *usually* just
be strings (some folk use bools for checkboxes though) - a result of it
being a place to store the string data submitted in the request or read from
the BO ready for display in the form...

-Original Message-
From: Marcus Biel [mailto:Marcus.Biel;bmw.de]
Sent: Thursday, October 31, 2002 18:20
To: [EMAIL PROTECTED]
Subject: MVC Design: property in ActionForm or Bean with property in
ActionForm ?


What's better:

To have a bean let's say BookBean.java
that has got a String title, author, pages

and an Actionform that uses this BookBean,

or is it better to have an ActionForm
that has a String title, author, pages.

Imho it's much faster and easier to have your properties in your
ActionForm,

but I bet according to the MVC design its recommend to use Beans.


Right ?


thx,

marcus

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


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




RE: MVC Design: property in ActionForm or Bean with property in ActionForm ?

2002-10-31 Thread Xavier Combelle
I have nearly the same think
but I use to create properties as Integer which avoid me
to make a call to Integer.valueOf()

Am I wrong ?


Sincerly
Xavier
 -Message d'origine-
 De : Andrew Hill [mailto:andrew.david.hill;gridnode.com]
 Envoye : jeudi 31 octobre 2002 11:42
 A : Struts Users Mailing List
 Objet : RE: MVC Design: property in ActionForm or Bean with property in
 ActionForm ?


 Technically speaking, the ActionForm IS a bean.
 It's purpose is to represent the users input (which you can
 validate and if
 necessary redisplay for correction) before transferring in your action the
 (validated) values (with appropriate type conversion) to your business
 object and vice versa.
 Your BO itself may well be a bean too - such as your BookBean perhaps?
 The actionForm and the business object will of course have a very similar
 (often identical) set of properties, however they serve different
 purposes -
 for example you will note that while your BOs beans would have various
 property types (ie: int for pages etc...) you ActionForm will
 *usually* just
 be strings (some folk use bools for checkboxes though) - a result of it
 being a place to store the string data submitted in the request
 or read from
 the BO ready for display in the form...

 -Original Message-
 From: Marcus Biel [mailto:Marcus.Biel;bmw.de]
 Sent: Thursday, October 31, 2002 18:20
 To: [EMAIL PROTECTED]
 Subject: MVC Design: property in ActionForm or Bean with property in
 ActionForm ?


 What's better:

 To have a bean let's say BookBean.java
 that has got a String title, author, pages

 and an Actionform that uses this BookBean,

 or is it better to have an ActionForm
 that has a String title, author, pages.

 Imho it's much faster and easier to have your properties in your
 ActionForm,

 but I bet according to the MVC design its recommend to use Beans.


 Right ?


 thx,

 marcus

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


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


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




RE: MVC Design: property in ActionForm or Bean with property in ActionForm ?

2002-10-31 Thread Andrew Hill
Well one problem with actually modelling you ints as ints in the ActionForm
is what happens if your user types in something like forty two instead of
42?

I forget whether this causes an exception in the processPopulate() method of
the RequestProcessor or if it silently converts it to the value 0. If the
former you have a problem catching it and if the later (which I think is
what happens?) how do you know whether that zero is supposed to be zero or
if its because your hairbrained user entered garbage?

Furthermore when you redisplay the page for them to try again its considered
good practice to rub their noses in the mess they left (ie: redisplay forty
two in the field) together with an appropriate error message next to that
field...
(Personally I think the wording of these sort of error messages should be
written by the host of the weakest link tv show ... but alas ... best
practice says they should be 'friendly' ;-)


-Original Message-
From: Xavier Combelle [mailto:xcombelle;kaptech.com]
Sent: Thursday, October 31, 2002 18:52
To: Struts Users Mailing List; [EMAIL PROTECTED]
Subject: RE: MVC Design: property in ActionForm or Bean with property in
ActionForm ?


I have nearly the same think
but I use to create properties as Integer which avoid me
to make a call to Integer.valueOf()

Am I wrong ?


Sincerly
Xavier
 -Message d'origine-
 De : Andrew Hill [mailto:andrew.david.hill;gridnode.com]
 Envoye : jeudi 31 octobre 2002 11:42
 A : Struts Users Mailing List
 Objet : RE: MVC Design: property in ActionForm or Bean with property in
 ActionForm ?


 Technically speaking, the ActionForm IS a bean.
 It's purpose is to represent the users input (which you can
 validate and if
 necessary redisplay for correction) before transferring in your action the
 (validated) values (with appropriate type conversion) to your business
 object and vice versa.
 Your BO itself may well be a bean too - such as your BookBean perhaps?
 The actionForm and the business object will of course have a very similar
 (often identical) set of properties, however they serve different
 purposes -
 for example you will note that while your BOs beans would have various
 property types (ie: int for pages etc...) you ActionForm will
 *usually* just
 be strings (some folk use bools for checkboxes though) - a result of it
 being a place to store the string data submitted in the request
 or read from
 the BO ready for display in the form...

 -Original Message-
 From: Marcus Biel [mailto:Marcus.Biel;bmw.de]
 Sent: Thursday, October 31, 2002 18:20
 To: [EMAIL PROTECTED]
 Subject: MVC Design: property in ActionForm or Bean with property in
 ActionForm ?


 What's better:

 To have a bean let's say BookBean.java
 that has got a String title, author, pages

 and an Actionform that uses this BookBean,

 or is it better to have an ActionForm
 that has a String title, author, pages.

 Imho it's much faster and easier to have your properties in your
 ActionForm,

 but I bet according to the MVC design its recommend to use Beans.


 Right ?


 thx,

 marcus

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


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


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


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




RE: MVC Design: property in ActionForm or Bean with property in ActionForm ?

2002-10-31 Thread Xavier Combelle
So in your point of view, a DynaActionForm should be enougth for
any kind of form ?

Xavier

 -Message d'origine-
 De : Andrew Hill [mailto:andrew.david.hill;gridnode.com]
 Envoye : jeudi 31 octobre 2002 12:00
 A : Struts Users Mailing List
 Objet : RE: MVC Design: property in ActionForm or Bean with property in
 ActionForm ?


 Well one problem with actually modelling you ints as ints in the
 ActionForm
 is what happens if your user types in something like forty two
 instead of
 42?

 I forget whether this causes an exception in the
 processPopulate() method of
 the RequestProcessor or if it silently converts it to the value 0. If the
 former you have a problem catching it and if the later (which I think is
 what happens?) how do you know whether that zero is supposed to be zero or
 if its because your hairbrained user entered garbage?

 Furthermore when you redisplay the page for them to try again its
 considered
 good practice to rub their noses in the mess they left (ie:
 redisplay forty
 two in the field) together with an appropriate error message next to that
 field...
 (Personally I think the wording of these sort of error messages should be
 written by the host of the weakest link tv show ... but alas ... best
 practice says they should be 'friendly' ;-)


 -Original Message-
 From: Xavier Combelle [mailto:xcombelle;kaptech.com]
 Sent: Thursday, October 31, 2002 18:52
 To: Struts Users Mailing List; [EMAIL PROTECTED]
 Subject: RE: MVC Design: property in ActionForm or Bean with property in
 ActionForm ?


 I have nearly the same think
 but I use to create properties as Integer which avoid me
 to make a call to Integer.valueOf()

 Am I wrong ?


 Sincerly
 Xavier
  -Message d'origine-
  De : Andrew Hill [mailto:andrew.david.hill;gridnode.com]
  Envoye : jeudi 31 octobre 2002 11:42
  A : Struts Users Mailing List
  Objet : RE: MVC Design: property in ActionForm or Bean with property in
  ActionForm ?
 
 
  Technically speaking, the ActionForm IS a bean.
  It's purpose is to represent the users input (which you can
  validate and if
  necessary redisplay for correction) before transferring in your
 action the
  (validated) values (with appropriate type conversion) to your business
  object and vice versa.
  Your BO itself may well be a bean too - such as your BookBean perhaps?
  The actionForm and the business object will of course have a
 very similar
  (often identical) set of properties, however they serve different
  purposes -
  for example you will note that while your BOs beans would have various
  property types (ie: int for pages etc...) you ActionForm will
  *usually* just
  be strings (some folk use bools for checkboxes though) - a result of it
  being a place to store the string data submitted in the request
  or read from
  the BO ready for display in the form...
 
  -Original Message-
  From: Marcus Biel [mailto:Marcus.Biel;bmw.de]
  Sent: Thursday, October 31, 2002 18:20
  To: [EMAIL PROTECTED]
  Subject: MVC Design: property in ActionForm or Bean with property in
  ActionForm ?
 
 
  What's better:
 
  To have a bean let's say BookBean.java
  that has got a String title, author, pages
 
  and an Actionform that uses this BookBean,
 
  or is it better to have an ActionForm
  that has a String title, author, pages.
 
  Imho it's much faster and easier to have your properties in your
  ActionForm,
 
  but I bet according to the MVC design its recommend to use Beans.
 
 
  Right ?
 
 
  thx,
 
  marcus
 
  --
  To unsubscribe, e-mail:
  mailto:struts-user-unsubscribe;jakarta.apache.org
  For additional commands, e-mail:
  mailto:struts-user-help;jakarta.apache.org
 
 
  --
  To unsubscribe, e-mail:
 mailto:struts-user-unsubscribe;jakarta.apache.org
 For additional commands, e-mail:
 mailto:struts-user-help;jakarta.apache.org


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


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


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




RE: MVC Design: property in ActionForm or Bean with property in ActionForm ?

2002-10-31 Thread Galbreath, Mark
I've not used them, but I believe the consensus of the list is, once you
have mastered how to use them, why use anything else?

Mark

-Original Message-
From: Xavier Combelle [mailto:xcombelle;kaptech.com]
Sent: Thursday, October 31, 2002 6:12 AM
To: Struts Users Mailing List
Subject: RE: MVC Design: property in ActionForm or Bean with property in
ActionForm ?


So in your point of view, a DynaActionForm should be enougth for
any kind of form ?

Xavier

 -Message d'origine-
 De : Andrew Hill [mailto:andrew.david.hill;gridnode.com]
 Envoye : jeudi 31 octobre 2002 12:00
 A : Struts Users Mailing List
 Objet : RE: MVC Design: property in ActionForm or Bean with property in
 ActionForm ?


 Well one problem with actually modelling you ints as ints in the
 ActionForm
 is what happens if your user types in something like forty two
 instead of
 42?

 I forget whether this causes an exception in the
 processPopulate() method of
 the RequestProcessor or if it silently converts it to the value 0. If the
 former you have a problem catching it and if the later (which I think is
 what happens?) how do you know whether that zero is supposed to be zero or
 if its because your hairbrained user entered garbage?

 Furthermore when you redisplay the page for them to try again its
 considered
 good practice to rub their noses in the mess they left (ie:
 redisplay forty
 two in the field) together with an appropriate error message next to that
 field...
 (Personally I think the wording of these sort of error messages should be
 written by the host of the weakest link tv show ... but alas ... best
 practice says they should be 'friendly' ;-)


 -Original Message-
 From: Xavier Combelle [mailto:xcombelle;kaptech.com]
 Sent: Thursday, October 31, 2002 18:52
 To: Struts Users Mailing List; [EMAIL PROTECTED]
 Subject: RE: MVC Design: property in ActionForm or Bean with property in
 ActionForm ?


 I have nearly the same think
 but I use to create properties as Integer which avoid me
 to make a call to Integer.valueOf()

 Am I wrong ?


 Sincerly
 Xavier
  -Message d'origine-
  De : Andrew Hill [mailto:andrew.david.hill;gridnode.com]
  Envoye : jeudi 31 octobre 2002 11:42
  A : Struts Users Mailing List
  Objet : RE: MVC Design: property in ActionForm or Bean with property in
  ActionForm ?
 
 
  Technically speaking, the ActionForm IS a bean.
  It's purpose is to represent the users input (which you can
  validate and if
  necessary redisplay for correction) before transferring in your
 action the
  (validated) values (with appropriate type conversion) to your business
  object and vice versa.
  Your BO itself may well be a bean too - such as your BookBean perhaps?
  The actionForm and the business object will of course have a
 very similar
  (often identical) set of properties, however they serve different
  purposes -
  for example you will note that while your BOs beans would have various
  property types (ie: int for pages etc...) you ActionForm will
  *usually* just
  be strings (some folk use bools for checkboxes though) - a result of it
  being a place to store the string data submitted in the request
  or read from
  the BO ready for display in the form...
 
  -Original Message-
  From: Marcus Biel [mailto:Marcus.Biel;bmw.de]
  Sent: Thursday, October 31, 2002 18:20
  To: [EMAIL PROTECTED]
  Subject: MVC Design: property in ActionForm or Bean with property in
  ActionForm ?
 
 
  What's better:
 
  To have a bean let's say BookBean.java
  that has got a String title, author, pages
 
  and an Actionform that uses this BookBean,
 
  or is it better to have an ActionForm
  that has a String title, author, pages.
 
  Imho it's much faster and easier to have your properties in your
  ActionForm,
 
  but I bet according to the MVC design its recommend to use Beans.
 
 
  Right ?
 
 
  thx,
 
  marcus
 
  --
  To unsubscribe, e-mail:
  mailto:struts-user-unsubscribe;jakarta.apache.org
  For additional commands, e-mail:
  mailto:struts-user-help;jakarta.apache.org
 
 
  --
  To unsubscribe, e-mail:
 mailto:struts-user-unsubscribe;jakarta.apache.org
 For additional commands, e-mail:
 mailto:struts-user-help;jakarta.apache.org


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


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


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

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




RE: MVC Design: property in ActionForm or Bean with property in ActionForm ?

2002-10-31 Thread Andrew Hill
Haven't actually tried the Dynaforms myself so couldnt make such a
recommendation. One thing Ive noticed though is that as soon as you think
you have something that will be suitable for all your needs along comes
another requirement that what you have cant handle (its a direct result of
murphys law...) :-(

To be honest (looking from the outside) I dont see what all the fuss about
Dynaforms is...
I much prefer having nice solid bean classes that I can compile against...
(And get nice JBuilder tooltips reminding me what properties they have hehe
;-)
(Mind you Im not using JSP (cos its evil) and tend to access my forms as
java objects quite often in my form renderers...)

-Original Message-
From: Xavier Combelle [mailto:xcombelle;kaptech.com]
Sent: Thursday, October 31, 2002 19:12
To: Struts Users Mailing List
Subject: RE: MVC Design: property in ActionForm or Bean with property in
ActionForm ?


So in your point of view, a DynaActionForm should be enougth for
any kind of form ?

Xavier

 -Message d'origine-
 De : Andrew Hill [mailto:andrew.david.hill;gridnode.com]
 Envoye : jeudi 31 octobre 2002 12:00
 A : Struts Users Mailing List
 Objet : RE: MVC Design: property in ActionForm or Bean with property in
 ActionForm ?


 Well one problem with actually modelling you ints as ints in the
 ActionForm
 is what happens if your user types in something like forty two
 instead of
 42?

 I forget whether this causes an exception in the
 processPopulate() method of
 the RequestProcessor or if it silently converts it to the value 0. If the
 former you have a problem catching it and if the later (which I think is
 what happens?) how do you know whether that zero is supposed to be zero or
 if its because your hairbrained user entered garbage?

 Furthermore when you redisplay the page for them to try again its
 considered
 good practice to rub their noses in the mess they left (ie:
 redisplay forty
 two in the field) together with an appropriate error message next to that
 field...
 (Personally I think the wording of these sort of error messages should be
 written by the host of the weakest link tv show ... but alas ... best
 practice says they should be 'friendly' ;-)


 -Original Message-
 From: Xavier Combelle [mailto:xcombelle;kaptech.com]
 Sent: Thursday, October 31, 2002 18:52
 To: Struts Users Mailing List; [EMAIL PROTECTED]
 Subject: RE: MVC Design: property in ActionForm or Bean with property in
 ActionForm ?


 I have nearly the same think
 but I use to create properties as Integer which avoid me
 to make a call to Integer.valueOf()

 Am I wrong ?


 Sincerly
 Xavier
  -Message d'origine-
  De : Andrew Hill [mailto:andrew.david.hill;gridnode.com]
  Envoye : jeudi 31 octobre 2002 11:42
  A : Struts Users Mailing List
  Objet : RE: MVC Design: property in ActionForm or Bean with property in
  ActionForm ?
 
 
  Technically speaking, the ActionForm IS a bean.
  It's purpose is to represent the users input (which you can
  validate and if
  necessary redisplay for correction) before transferring in your
 action the
  (validated) values (with appropriate type conversion) to your business
  object and vice versa.
  Your BO itself may well be a bean too - such as your BookBean perhaps?
  The actionForm and the business object will of course have a
 very similar
  (often identical) set of properties, however they serve different
  purposes -
  for example you will note that while your BOs beans would have various
  property types (ie: int for pages etc...) you ActionForm will
  *usually* just
  be strings (some folk use bools for checkboxes though) - a result of it
  being a place to store the string data submitted in the request
  or read from
  the BO ready for display in the form...
 
  -Original Message-
  From: Marcus Biel [mailto:Marcus.Biel;bmw.de]
  Sent: Thursday, October 31, 2002 18:20
  To: [EMAIL PROTECTED]
  Subject: MVC Design: property in ActionForm or Bean with property in
  ActionForm ?
 
 
  What's better:
 
  To have a bean let's say BookBean.java
  that has got a String title, author, pages
 
  and an Actionform that uses this BookBean,
 
  or is it better to have an ActionForm
  that has a String title, author, pages.
 
  Imho it's much faster and easier to have your properties in your
  ActionForm,
 
  but I bet according to the MVC design its recommend to use Beans.
 
 
  Right ?
 
 
  thx,
 
  marcus
 
  --
  To unsubscribe, e-mail:
  mailto:struts-user-unsubscribe;jakarta.apache.org
  For additional commands, e-mail:
  mailto:struts-user-help;jakarta.apache.org
 
 
  --
  To unsubscribe, e-mail:
 mailto:struts-user-unsubscribe;jakarta.apache.org
 For additional commands, e-mail:
 mailto:struts-user-help;jakarta.apache.org


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


 --
 To unsubscribe, e-mail:
mailto:struts-user-unsubscribe

Re: MVC Design: property in ActionForm or Bean with property in ActionForm ?

2002-10-31 Thread Marcus Biel
btw:
That's just what I am looking for!
How can I check if a user typed in a string instead of a number?

marcus

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




RE: MVC Design: property in ActionForm or Bean with property in ActionForm ?

2002-10-31 Thread Galbreath, Mark
Are you kidding?  Dude, everything typed in an HTML form is a string.  You
have to do some validation.

Mark

-Original Message-
From: Marcus Biel [mailto:Marcus.Biel;bmw.de]
Sent: Thursday, October 31, 2002 6:40 AM

btw:
That's just what I am looking for!
How can I check if a user typed in a string instead of a number?

marcus

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




RE: MVC Design: property in ActionForm or Bean with property in ActionForm ?

2002-10-31 Thread Craig R. McClanahan


On Thu, 31 Oct 2002, Andrew Hill wrote:

 Date: Thu, 31 Oct 2002 20:16:34 +0800
 From: Andrew Hill [EMAIL PROTECTED]
 Reply-To: Struts Users Mailing List [EMAIL PROTECTED],
  [EMAIL PROTECTED]
 To: Struts Users Mailing List [EMAIL PROTECTED]
 Subject: RE: MVC Design: property in ActionForm or Bean with property in
 A ctionForm ?

 What is a 'good-practice' method of validating a numeric string?
 Ive been lazy and am doing a Integer.parseInt() in a try catch but its
 probably far from the best way...

Nothing wrong with that (in the validate() method, for example), given
that you're ultimately going to need to convert to an integer to use in
your model tier.  From a performance perspective, you might consider
keeping the converted value and making it available (to your Action) under
a different property name in order to avoid doing the conversion again.

 (Have been meaning to check out the java.text.NumberFormat stuff but always
 had more interes... uh... important things to do first and havent had time
 yet...)

But necessary if you want to allow your user to stick commas and decimal
points (or the reverse for countries that do it backwards :-) in a
Locale-sensitive manner.

Craig


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