You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Engbers, ir. J.B.O.M." <J....@dlg.agro.nl> on 2003/12/17 15:24:23 UTC
Newbie: java.lang.boolean and DynaActionForm?
Hi,
Both 'Struts in Action' and 'Programming Jakarta Struts' state that
ActionForms and DynaActionForms are nearly equivalent and the main advantage
of using DynaActionForms is that you don't have to declare all the getters
and setters.
In DynaAction Forms each property can be of a (array of a) primitive types.
Thanks to Pedro Salgado and Martin Gainty (see "Retrieving boolean
properties from a DynaActionForm" on december 16), I partially succeeded in
solving the first problem which only confronted me with the next problem :-(
And while looking for a solution to that problem, I found a bugreport
(23355) in which Craig states that
'Adding these (getInteger, getBoolean etc, Ben) would encourage a behavior
that Struts discourages -- using
non-String data types in a form bean.'
Maybe that this explains why I have only found examples that use
String-properties (which lead me to my first question: where can I find
examples that use non_string properties?) but it leaves me with the more
fundamental question:
Why do DynaActionForms offer the possibility to declare non-String
properties without supporting them?
Should I avoid using DynaActionForms at all and use the DynaValidatorForm?
Ben Engbers
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Newbie: java.lang.boolean and DynaActionForm?
Posted by Mark Lowe <ma...@talk21.com>.
DynaActionForms as cool as they are are more trouble than they're worth
unless its a small simple form. For one thing you don't find out what's
wrong until runtime.
I just use strings for dynaaction forms as it works, the problems our
in part caused (i think) by the conversions done by beanutils
(org.apache.commons.beanutils). Validator validates stuff even of type
string.
if/when you use action forms, the typing issues are less of a pain. I
know that its discouraged according to the party line. But then those
aren't the folks paying you are they.
Part of the problem is that action forms are strongly coupled to the
presentation layer, but sometimes its handy to be able to copy the
properties from your model beans to the servlet layer. Often this means
having both groups of beans looking pretty much the same, but some MVC
purists claim this is the devils work as you're not decoupling enough.
While I symathise with this position, its often not pragmatic to go
down this route at an early stage of a project. In fact I've been known
to nest model beans in action forms, and re-factor later to decouple,
while I know this breaks with MVC the folks paying for work don't
really give a toss whether its mvc or not.
I'm not saying break with the world according to these folks who know
better than me, but just that sometimes its important to understand
their focus is different to some of us. While they're laying out road
maps for future technologies, publishing books and suchlike. We're
stuck in an "is and ought" dilemma, between clients/bosses and trying
to craft the best app we can.
So IMO careful what you believe or you might end up trying to find the
holy grail of tech development, while your productivity suffers.
My 2 pence.
On 17 Dec 2003, at 14:24, Engbers, ir. J.B.O.M. wrote:
> Hi,
>
> Both 'Struts in Action' and 'Programming Jakarta Struts' state that
> ActionForms and DynaActionForms are nearly equivalent and the main
> advantage
> of using DynaActionForms is that you don't have to declare all the
> getters
> and setters.
> In DynaAction Forms each property can be of a (array of a) primitive
> types.
>
> Thanks to Pedro Salgado and Martin Gainty (see "Retrieving boolean
> properties from a DynaActionForm" on december 16), I partially
> succeeded in
> solving the first problem which only confronted me with the next
> problem :-(
> And while looking for a solution to that problem, I found a bugreport
> (23355) in which Craig states that
>
> 'Adding these (getInteger, getBoolean etc, Ben) would encourage a
> behavior
> that Struts discourages -- using
> non-String data types in a form bean.'
>
> Maybe that this explains why I have only found examples that use
> String-properties (which lead me to my first question: where can I find
> examples that use non_string properties?) but it leaves me with the
> more
> fundamental question:
> Why do DynaActionForms offer the possibility to declare non-String
> properties without supporting them?
> Should I avoid using DynaActionForms at all and use the
> DynaValidatorForm?
>
> Ben Engbers
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Newbie: java.lang.boolean and DynaActionForm?
Posted by Ed Dowgiallo <ed...@ptdprolog.net>.
Thank you for the translation. ;-)
Ed
----- Original Message -----
From: "Mark Lowe" <ma...@talk21.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, December 17, 2003 11:11 AM
Subject: Re: Newbie: java.lang.boolean and DynaActionForm?
> Hi Ed
>
> I've checked my spellings this time.
>
> On 17 Dec 2003, at 15:49, Ed Dowgiallo wrote:
>
> > Mark,
> >
> > Perhaps I am getting old, but the meaning of your metaphors went
> > over my
> > head. On the other hand, this is an international audience.
> >
> > What is a chocolate fire guard?
>
> A fire guard is like a shield one places in front of a fire to prevent
> any bits of hot ash escaping and setting one's house on fire. These are
> usually made of metal as it is fire proof. A fireguard made of
> chocolate wouldn't be much use, as it would melt and not protect one's
> house from the peril of smoldering ash.
>
> >
> > Do you believe it is harder or easier to use DynaActionForms
> > instead of
> > Strings?
>
> A few months ago it was certainly the case that using strings when
> using dynaaction forms was the only sure way of getting stuff running.
> But robert sounds like he's been using objects in there and sounds good
> to me, I think that beanutils has problems with BigDecimal and perhaps
> other objects but I dont remeber the details. I haven't used dynaforms
> in a while because i dont like the way you have to wait until runtime
> to see whether there's a problem.
>
> >
> > Is taking the piss a bit a good thing or a bad thing?
>
> Its another why of saying, "taking the mickey" , or "making fun of
> something".. It used to be the case in victorian times in england that
> urine would fetch enough money for a decent meal. As urine was used for
> cosmetic and medical purposes by the affluent classes, urine would be
> exchanged by poorer folks for a financial reward. Thus the phrase was
> born "taking the piss" its also where "spending a penny" came from.
>
> Cheers Mark
>
> >
> > Thank you,
> > Ed
> > ----- Original Message -----
> > From: "Mark Lowe" <ma...@talk21.com>
> > To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > Sent: Wednesday, December 17, 2003 10:33 AM
> > Subject: Re: Newbie: java.lang.boolean and DynaActionForm?
> >
> >
> >> No one's suggesting that anyone hangs them selves or that struts isn't
> >> good. But the fact that this list sees a high influx of newbies,
> >> getting battered with high-brow design concepts which while are very
> >> interesting have a certain chocolate fire guard quality to them .
> >>
> >> Easiest thing is to make all the form properties strings, or like has
> >> been suggested, non primitives. It was certainly the case a few months
> >> ago that to use dynaaction forms then it was just less bother to use
> >> strings.
> >>
> >> Sure nesting model objects in action forms does take the piss a bit,
> >> but its nothing that cant be sorted when clients/non tech bosses have
> >> stopped wetting themselves about image swaps..
> >>
> >> Cheers Mark
> >>
> >> On 17 Dec 2003, at 15:27, Robert Taylor wrote:
> >>
> >>> To address the "fundemental" question, it is considered a "best
> >>> practice"
> >>> to only use String or Boolean objects or collections of String and/or
> >>> Boolean objects or collection of
> >>> data structures which contain String and/or Boolean objects in your
> >>> forms.
> >>> This is because it gives you
> >>> more control over validation. This doesn't mean that DynaActionForms
> >>> or
> >>> any DynaXXXXForm for that matter doesn't support non-string types. It
> >>> supports
> >>> any Object because essentially the DynaXXXForms internal data
> >>> structure is a
> >>> Map.
> >>>
> >>> In general the Struts form should be a ValueObject passing immutable
> >>> data
> >>> from the input
> >>> to be processed or passing immutable data to the output to be
> >>> rendered.
> >>>
> >>> The great thing about Struts is that it gives you more than enough
> >>> "rope" to
> >>> use wisely or hang yourself :)
> >>>
> >>> robert
> >>>
> >>>
> >>>
> >>>> -----Original Message-----
> >>>> From: Engbers, ir. J.B.O.M. [mailto:J.B.O.M.Engbers@dlg.agro.nl]
> >>>> Sent: Wednesday, December 17, 2003 9:24 AM
> >>>> To: 'struts-user@jakarta.apache.org'
> >>>> Subject: Newbie: java.lang.boolean and DynaActionForm?
> >>>>
> >>>>
> >>>> Hi,
> >>>>
> >>>> Both 'Struts in Action' and 'Programming Jakarta Struts' state that
> >>>> ActionForms and DynaActionForms are nearly equivalent and the
> >>>> main advantage
> >>>> of using DynaActionForms is that you don't have to declare all the
> >>>> getters
> >>>> and setters.
> >>>> In DynaAction Forms each property can be of a (array of a)
> >>>> primitive types.
> >>>>
> >>>> Thanks to Pedro Salgado and Martin Gainty (see "Retrieving boolean
> >>>> properties from a DynaActionForm" on december 16), I partially
> >>>> succeeded in
> >>>> solving the first problem which only confronted me with the next
> >>>> problem :-(
> >>>> And while looking for a solution to that problem, I found a
> >>>> bugreport
> >>>> (23355) in which Craig states that
> >>>>
> >>>> 'Adding these (getInteger, getBoolean etc, Ben) would encourage a
> >>>> behavior
> >>>> that Struts discourages -- using
> >>>> non-String data types in a form bean.'
> >>>>
> >>>> Maybe that this explains why I have only found examples that use
> >>>> String-properties (which lead me to my first question: where can I
> >>>> find
> >>>> examples that use non_string properties?) but it leaves me with the
> >>>> more
> >>>> fundamental question:
> >>>> Why do DynaActionForms offer the possibility to declare non-String
> >>>> properties without supporting them?
> >>>> Should I avoid using DynaActionForms at all and use the
> >>>> DynaValidatorForm?
> >>>>
> >>>> Ben Engbers
> >>>>
> >>>> --------------------------------------------------------------------
> >>>> -
> >>>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> >>>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >>>>
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> >>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >>>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> >> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Newbie: java.lang.boolean and DynaActionForm?
Posted by Mark Lowe <ma...@talk21.com>.
Hi Ed
I've checked my spellings this time.
On 17 Dec 2003, at 15:49, Ed Dowgiallo wrote:
> Mark,
>
> Perhaps I am getting old, but the meaning of your metaphors went
> over my
> head. On the other hand, this is an international audience.
>
> What is a chocolate fire guard?
A fire guard is like a shield one places in front of a fire to prevent
any bits of hot ash escaping and setting one's house on fire. These are
usually made of metal as it is fire proof. A fireguard made of
chocolate wouldn't be much use, as it would melt and not protect one's
house from the peril of smoldering ash.
>
> Do you believe it is harder or easier to use DynaActionForms
> instead of
> Strings?
A few months ago it was certainly the case that using strings when
using dynaaction forms was the only sure way of getting stuff running.
But robert sounds like he's been using objects in there and sounds good
to me, I think that beanutils has problems with BigDecimal and perhaps
other objects but I dont remeber the details. I haven't used dynaforms
in a while because i dont like the way you have to wait until runtime
to see whether there's a problem.
>
> Is taking the piss a bit a good thing or a bad thing?
Its another why of saying, "taking the mickey" , or "making fun of
something".. It used to be the case in victorian times in england that
urine would fetch enough money for a decent meal. As urine was used for
cosmetic and medical purposes by the affluent classes, urine would be
exchanged by poorer folks for a financial reward. Thus the phrase was
born "taking the piss" its also where "spending a penny" came from.
Cheers Mark
>
> Thank you,
> Ed
> ----- Original Message -----
> From: "Mark Lowe" <ma...@talk21.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Wednesday, December 17, 2003 10:33 AM
> Subject: Re: Newbie: java.lang.boolean and DynaActionForm?
>
>
>> No one's suggesting that anyone hangs them selves or that struts isn't
>> good. But the fact that this list sees a high influx of newbies,
>> getting battered with high-brow design concepts which while are very
>> interesting have a certain chocolate fire guard quality to them .
>>
>> Easiest thing is to make all the form properties strings, or like has
>> been suggested, non primitives. It was certainly the case a few months
>> ago that to use dynaaction forms then it was just less bother to use
>> strings.
>>
>> Sure nesting model objects in action forms does take the piss a bit,
>> but its nothing that cant be sorted when clients/non tech bosses have
>> stopped wetting themselves about image swaps..
>>
>> Cheers Mark
>>
>> On 17 Dec 2003, at 15:27, Robert Taylor wrote:
>>
>>> To address the "fundemental" question, it is considered a "best
>>> practice"
>>> to only use String or Boolean objects or collections of String and/or
>>> Boolean objects or collection of
>>> data structures which contain String and/or Boolean objects in your
>>> forms.
>>> This is because it gives you
>>> more control over validation. This doesn't mean that DynaActionForms
>>> or
>>> any DynaXXXXForm for that matter doesn't support non-string types. It
>>> supports
>>> any Object because essentially the DynaXXXForms internal data
>>> structure is a
>>> Map.
>>>
>>> In general the Struts form should be a ValueObject passing immutable
>>> data
>>> from the input
>>> to be processed or passing immutable data to the output to be
>>> rendered.
>>>
>>> The great thing about Struts is that it gives you more than enough
>>> "rope" to
>>> use wisely or hang yourself :)
>>>
>>> robert
>>>
>>>
>>>
>>>> -----Original Message-----
>>>> From: Engbers, ir. J.B.O.M. [mailto:J.B.O.M.Engbers@dlg.agro.nl]
>>>> Sent: Wednesday, December 17, 2003 9:24 AM
>>>> To: 'struts-user@jakarta.apache.org'
>>>> Subject: Newbie: java.lang.boolean and DynaActionForm?
>>>>
>>>>
>>>> Hi,
>>>>
>>>> Both 'Struts in Action' and 'Programming Jakarta Struts' state that
>>>> ActionForms and DynaActionForms are nearly equivalent and the
>>>> main advantage
>>>> of using DynaActionForms is that you don't have to declare all the
>>>> getters
>>>> and setters.
>>>> In DynaAction Forms each property can be of a (array of a)
>>>> primitive types.
>>>>
>>>> Thanks to Pedro Salgado and Martin Gainty (see "Retrieving boolean
>>>> properties from a DynaActionForm" on december 16), I partially
>>>> succeeded in
>>>> solving the first problem which only confronted me with the next
>>>> problem :-(
>>>> And while looking for a solution to that problem, I found a
>>>> bugreport
>>>> (23355) in which Craig states that
>>>>
>>>> 'Adding these (getInteger, getBoolean etc, Ben) would encourage a
>>>> behavior
>>>> that Struts discourages -- using
>>>> non-String data types in a form bean.'
>>>>
>>>> Maybe that this explains why I have only found examples that use
>>>> String-properties (which lead me to my first question: where can I
>>>> find
>>>> examples that use non_string properties?) but it leaves me with the
>>>> more
>>>> fundamental question:
>>>> Why do DynaActionForms offer the possibility to declare non-String
>>>> properties without supporting them?
>>>> Should I avoid using DynaActionForms at all and use the
>>>> DynaValidatorForm?
>>>>
>>>> Ben Engbers
>>>>
>>>> --------------------------------------------------------------------
>>>> -
>>>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Newbie: java.lang.boolean and DynaActionForm?
Posted by Mark Lowe <ma...@talk21.com>.
Hi Ed
On 17 Dec 2003, at 15:49, Ed Dowgiallo wrote:
> Mark,
>
> Perhaps I am getting old, but the meaning of your metaphors went
> over my
> head. On the other hand, this is an international audience.
>
> What is a chocolate fire guard?
a fire guard is like a shield one places in front of a fire to prevent
any bits of hot ash escaping and setting one's house on fire. These are
usually made of metal as it is fire proof. A fireguard made of
chocolate wouldn't be much use, as it would melt and no protect one's
house from the peril of smoldering ash.
>
> Do you believe it is harder or easier to use DynaActionForms
> instead of
> Strings?
A few months ago it was certainly the case that using strings when
using dynaaction forms was the only sure way of getting stuff running.
But robert sound like he's been using objects in there and sounds good
to me, I thing that beanutils has problems with BigDecimal and perhaps
other objects but I dont remeber the details. I haven't used dynaforms
in a while cos i dont like the way you have to wait until runtime to
see whether there's a problem.
>
> Is taking the piss a bit a good thing or a bad thing?
Its another why of saying, "taking the mickey" , or "making fun of
something".. It used to be the case in victorian times in england that
urine would fetch enough money for a decent meal. As urine was used for
cosmetic and medical purposes by the affluent classes urine would be
exchanged by poorer folks for a financial reward. Thus the phrase was
born "taking the piss" its also where "spending a penny" came from
also.
Cheers Mark
>
> Thank you,
> Ed
> ----- Original Message -----
> From: "Mark Lowe" <ma...@talk21.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Wednesday, December 17, 2003 10:33 AM
> Subject: Re: Newbie: java.lang.boolean and DynaActionForm?
>
>
>> No one's suggesting that anyone hangs them selves or that struts isn't
>> good. But the fact that this list sees a high influx of newbies,
>> getting battered with high-brow design concepts which while are very
>> interesting have a certain chocolate fire guard quality to them .
>>
>> Easiest thing is to make all the form properties strings, or like has
>> been suggested, non primitives. It was certainly the case a few months
>> ago that to use dynaaction forms then it was just less bother to use
>> strings.
>>
>> Sure nesting model objects in action forms does take the piss a bit,
>> but its nothing that cant be sorted when clients/non tech bosses have
>> stopped wetting themselves about image swaps..
>>
>> Cheers Mark
>>
>> On 17 Dec 2003, at 15:27, Robert Taylor wrote:
>>
>>> To address the "fundemental" question, it is considered a "best
>>> practice"
>>> to only use String or Boolean objects or collections of String and/or
>>> Boolean objects or collection of
>>> data structures which contain String and/or Boolean objects in your
>>> forms.
>>> This is because it gives you
>>> more control over validation. This doesn't mean that DynaActionForms
>>> or
>>> any DynaXXXXForm for that matter doesn't support non-string types. It
>>> supports
>>> any Object because essentially the DynaXXXForms internal data
>>> structure is a
>>> Map.
>>>
>>> In general the Struts form should be a ValueObject passing immutable
>>> data
>>> from the input
>>> to be processed or passing immutable data to the output to be
>>> rendered.
>>>
>>> The great thing about Struts is that it gives you more than enough
>>> "rope" to
>>> use wisely or hang yourself :)
>>>
>>> robert
>>>
>>>
>>>
>>>> -----Original Message-----
>>>> From: Engbers, ir. J.B.O.M. [mailto:J.B.O.M.Engbers@dlg.agro.nl]
>>>> Sent: Wednesday, December 17, 2003 9:24 AM
>>>> To: 'struts-user@jakarta.apache.org'
>>>> Subject: Newbie: java.lang.boolean and DynaActionForm?
>>>>
>>>>
>>>> Hi,
>>>>
>>>> Both 'Struts in Action' and 'Programming Jakarta Struts' state that
>>>> ActionForms and DynaActionForms are nearly equivalent and the
>>>> main advantage
>>>> of using DynaActionForms is that you don't have to declare all the
>>>> getters
>>>> and setters.
>>>> In DynaAction Forms each property can be of a (array of a)
>>>> primitive types.
>>>>
>>>> Thanks to Pedro Salgado and Martin Gainty (see "Retrieving boolean
>>>> properties from a DynaActionForm" on december 16), I partially
>>>> succeeded in
>>>> solving the first problem which only confronted me with the next
>>>> problem :-(
>>>> And while looking for a solution to that problem, I found a
>>>> bugreport
>>>> (23355) in which Craig states that
>>>>
>>>> 'Adding these (getInteger, getBoolean etc, Ben) would encourage a
>>>> behavior
>>>> that Struts discourages -- using
>>>> non-String data types in a form bean.'
>>>>
>>>> Maybe that this explains why I have only found examples that use
>>>> String-properties (which lead me to my first question: where can I
>>>> find
>>>> examples that use non_string properties?) but it leaves me with the
>>>> more
>>>> fundamental question:
>>>> Why do DynaActionForms offer the possibility to declare non-String
>>>> properties without supporting them?
>>>> Should I avoid using DynaActionForms at all and use the
>>>> DynaValidatorForm?
>>>>
>>>> Ben Engbers
>>>>
>>>> --------------------------------------------------------------------
>>>> -
>>>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: validation and DynaActionForm / concrete question
Posted by Mark Lowe <ma...@talk21.com>.
Hi marco
well i think the problem your having is because you're using a dispatch
action
so the form is mapped to the action and its set to validate. You can
either separte yu dispatch actions into standard actions or hack it by
having a single action that calls your dispatch action much like you
were suggesting doing with jsp.
Cheers Mark
On 17 Dec 2003, at 16:35, Marco Mistroni wrote:
> Hi all,
> After struggling with my application, I have
> One question to ask.
> I have a DispatchAction class that handles my logic, and
> A DynaActionForm associated with it.
> The problem is that the jsp from which the request comes can
> Contain either 1, 2 parameters (out of 13 of DynaActionForm) or
> 13/13 parameters, since the page presents different information
> depending
> on which task I have to perform (either a search or an update or
> delete).
> Now, I keep on getting ValidationException when I have only 2
> parameters
> In my DynaActionForm I have 9 Strings, 2 BigDecimal, 1 Short and 1
> Timestamp.
>
> Am I receiving the exception (listed below) because Struts is trying to
> validate all the input parameters? If that is true, is It worth to use
> DynaActionForm when I don't have all the parameters supplied from jsp?
>
> Or, how do I have to proceed?
>
> Anyone has any suggestions?
>
> Thanx and regards
> Marco
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: validation and DynaActionForm / concrete question
Posted by Marco Mistroni <mm...@waersystems.com>.
Hi all,
After struggling with my application, I have
One question to ask.
I have a DispatchAction class that handles my logic, and
A DynaActionForm associated with it.
The problem is that the jsp from which the request comes can
Contain either 1, 2 parameters (out of 13 of DynaActionForm) or
13/13 parameters, since the page presents different information
depending
on which task I have to perform (either a search or an update or
delete).
Now, I keep on getting ValidationException when I have only 2 parameters
In my DynaActionForm I have 9 Strings, 2 BigDecimal, 1 Short and 1
Timestamp.
Am I receiving the exception (listed below) because Struts is trying to
validate all the input parameters? If that is true, is It worth to use
DynaActionForm when I don't have all the parameters supplied from jsp?
Or, how do I have to proceed?
Anyone has any suggestions?
Thanx and regards
Marco
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: validation and DynaActionForm
Posted by Marco Mistroni <mm...@waersystems.com>.
Hi Mark,
Thanx.. but this
<A href="/myaction.do?methodToCall=foo">..</a>
is exactly what I am doing..
I am assuming that If validator is trying to validate all the
Parameters I have no other choice than redirect straight to the
Jsp...........
Thanx anyway and regards
marco
On 17 Dec 2003, at 16:10, Marco Mistroni wrote:
> Hi all,
> I am experiencing problems with DynaActionForm..
> I have a DynaActionForm that contains 13 properties and
> A DispatchAction used calling different methods depending
> On the value of one parameter (named methodToCall).
>
> Now, when I enter the page for the first time the only request
> Parameter is 'methodToCall' since when I enter the page I need to
> Remove some values that were with session scope.
>
> The problem is that when I enter page for the first time I receive
> Following exception:
>
> 2/03 16:04:21:963 GMT] 51272c9d WebGroup E SRVE0026E: [Servlet
> Error]-[action]: java.lang.NullPointerException
> at org.apache.commons.validator.Validator.validate(Unknown
> Source)
> at
>
org.apache.struts.validator.DynaValidatorForm.validate(DynaValidatorFor
> m
> .java:303)
> at
>
org.apache.struts.action.RequestProcessor.processValidate(RequestProces
> s
> or.java:893)
> at
>
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java
> :
> 247)
> at
>
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1292)
> at
> org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:492)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>
>
> Now, since it is a NullPointerException and it is raised by the
> validate, my assumption is that the DynaValidatorForm is trying to
> validate all the parameters in order to populate the Form, and since
> the
> only parameter in the request is methodToCall, it raises an exception.
>
> But, since I am no expert in DynaActionForm, can anyone help me out in
> Solving my problem?
>
> Thanx in advance and regards
> marco
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: validation and DynaActionForm
Posted by Mark Lowe <ma...@talk21.com>.
Hi Marco
Perhaps try a none strust form element
<input type="hidden" name="methodToCall" value="foo">
rather than
<html:hidden property="methodToCall" value="foo" />
also if possible in your situation
<html:form action="/myaction.do?methodToCall=foo">
Cheers Mark
On 17 Dec 2003, at 16:10, Marco Mistroni wrote:
> Hi all,
> I am experiencing problems with DynaActionForm..
> I have a DynaActionForm that contains 13 properties and
> A DispatchAction used calling different methods depending
> On the value of one parameter (named methodToCall).
>
> Now, when I enter the page for the first time the only request
> Parameter is 'methodToCall' since when I enter the page I need to
> Remove some values that were with session scope.
>
> The problem is that when I enter page for the first time I receive
> Following exception:
>
> 2/03 16:04:21:963 GMT] 51272c9d WebGroup E SRVE0026E: [Servlet
> Error]-[action]: java.lang.NullPointerException
> at org.apache.commons.validator.Validator.validate(Unknown
> Source)
> at
> org.apache.struts.validator.DynaValidatorForm.validate(DynaValidatorFor
> m
> .java:303)
> at
> org.apache.struts.action.RequestProcessor.processValidate(RequestProces
> s
> or.java:893)
> at
> org.apache.struts.action.RequestProcessor.process(RequestProcessor.java
> :
> 247)
> at
> org.apache.struts.action.ActionServlet.process(ActionServlet.java:1292)
> at
> org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:492)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>
>
> Now, since it is a NullPointerException and it is raised by the
> validate, my assumption is that the DynaValidatorForm is trying to
> validate all the parameters in order to populate the Form, and since
> the
> only parameter in the request is methodToCall, it raises an exception.
>
> But, since I am no expert in DynaActionForm, can anyone help me out in
> Solving my problem?
>
> Thanx in advance and regards
> marco
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
validation and DynaActionForm
Posted by Marco Mistroni <mm...@waersystems.com>.
Hi all,
I am experiencing problems with DynaActionForm..
I have a DynaActionForm that contains 13 properties and
A DispatchAction used calling different methods depending
On the value of one parameter (named methodToCall).
Now, when I enter the page for the first time the only request
Parameter is 'methodToCall' since when I enter the page I need to
Remove some values that were with session scope.
The problem is that when I enter page for the first time I receive
Following exception:
2/03 16:04:21:963 GMT] 51272c9d WebGroup E SRVE0026E: [Servlet
Error]-[action]: java.lang.NullPointerException
at org.apache.commons.validator.Validator.validate(Unknown
Source)
at
org.apache.struts.validator.DynaValidatorForm.validate(DynaValidatorForm
.java:303)
at
org.apache.struts.action.RequestProcessor.processValidate(RequestProcess
or.java:893)
at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:
247)
at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1292)
at
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:492)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
Now, since it is a NullPointerException and it is raised by the
validate, my assumption is that the DynaValidatorForm is trying to
validate all the parameters in order to populate the Form, and since the
only parameter in the request is methodToCall, it raises an exception.
But, since I am no expert in DynaActionForm, can anyone help me out in
Solving my problem?
Thanx in advance and regards
marco
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Newbie: java.lang.boolean and DynaActionForm?
Posted by Ed Dowgiallo <ed...@ptdprolog.net>.
Mark,
Perhaps I am getting old, but the meaning of your metaphors went over my
head. On the other hand, this is an international audience.
What is a chocolate fire guard?
Do you believe it is harder or easier to use DynaActionForms instead of
Strings?
Is taking the piss a bit a good thing or a bad thing?
Thank you,
Ed
----- Original Message -----
From: "Mark Lowe" <ma...@talk21.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, December 17, 2003 10:33 AM
Subject: Re: Newbie: java.lang.boolean and DynaActionForm?
> No one's suggesting that anyone hangs them selves or that struts isn't
> good. But the fact that this list sees a high influx of newbies,
> getting battered with high-brow design concepts which while are very
> interesting have a certain chocolate fire guard quality to them .
>
> Easiest thing is to make all the form properties strings, or like has
> been suggested, non primitives. It was certainly the case a few months
> ago that to use dynaaction forms then it was just less bother to use
> strings.
>
> Sure nesting model objects in action forms does take the piss a bit,
> but its nothing that cant be sorted when clients/non tech bosses have
> stopped wetting themselves about image swaps..
>
> Cheers Mark
>
> On 17 Dec 2003, at 15:27, Robert Taylor wrote:
>
> > To address the "fundemental" question, it is considered a "best
> > practice"
> > to only use String or Boolean objects or collections of String and/or
> > Boolean objects or collection of
> > data structures which contain String and/or Boolean objects in your
> > forms.
> > This is because it gives you
> > more control over validation. This doesn't mean that DynaActionForms or
> > any DynaXXXXForm for that matter doesn't support non-string types. It
> > supports
> > any Object because essentially the DynaXXXForms internal data
> > structure is a
> > Map.
> >
> > In general the Struts form should be a ValueObject passing immutable
> > data
> > from the input
> > to be processed or passing immutable data to the output to be rendered.
> >
> > The great thing about Struts is that it gives you more than enough
> > "rope" to
> > use wisely or hang yourself :)
> >
> > robert
> >
> >
> >
> >> -----Original Message-----
> >> From: Engbers, ir. J.B.O.M. [mailto:J.B.O.M.Engbers@dlg.agro.nl]
> >> Sent: Wednesday, December 17, 2003 9:24 AM
> >> To: 'struts-user@jakarta.apache.org'
> >> Subject: Newbie: java.lang.boolean and DynaActionForm?
> >>
> >>
> >> Hi,
> >>
> >> Both 'Struts in Action' and 'Programming Jakarta Struts' state that
> >> ActionForms and DynaActionForms are nearly equivalent and the
> >> main advantage
> >> of using DynaActionForms is that you don't have to declare all the
> >> getters
> >> and setters.
> >> In DynaAction Forms each property can be of a (array of a)
> >> primitive types.
> >>
> >> Thanks to Pedro Salgado and Martin Gainty (see "Retrieving boolean
> >> properties from a DynaActionForm" on december 16), I partially
> >> succeeded in
> >> solving the first problem which only confronted me with the next
> >> problem :-(
> >> And while looking for a solution to that problem, I found a bugreport
> >> (23355) in which Craig states that
> >>
> >> 'Adding these (getInteger, getBoolean etc, Ben) would encourage a
> >> behavior
> >> that Struts discourages -- using
> >> non-String data types in a form bean.'
> >>
> >> Maybe that this explains why I have only found examples that use
> >> String-properties (which lead me to my first question: where can I
> >> find
> >> examples that use non_string properties?) but it leaves me with the
> >> more
> >> fundamental question:
> >> Why do DynaActionForms offer the possibility to declare non-String
> >> properties without supporting them?
> >> Should I avoid using DynaActionForms at all and use the
> >> DynaValidatorForm?
> >>
> >> Ben Engbers
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> >> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Newbie: java.lang.boolean and DynaActionForm?
Posted by Mark Lowe <ma...@talk21.com>.
No one's suggesting that anyone hangs them selves or that struts isn't
good. But the fact that this list sees a high influx of newbies,
getting battered with high-brow design concepts which while are very
interesting have a certain chocolate fire guard quality to them .
Easiest thing is to make all the form properties strings, or like has
been suggested, non primitives. It was certainly the case a few months
ago that to use dynaaction forms then it was just less bother to use
strings.
Sure nesting model objects in action forms does take the piss a bit,
but its nothing that cant be sorted when clients/non tech bosses have
stopped wetting themselves about image swaps..
Cheers Mark
On 17 Dec 2003, at 15:27, Robert Taylor wrote:
> To address the "fundemental" question, it is considered a "best
> practice"
> to only use String or Boolean objects or collections of String and/or
> Boolean objects or collection of
> data structures which contain String and/or Boolean objects in your
> forms.
> This is because it gives you
> more control over validation. This doesn't mean that DynaActionForms or
> any DynaXXXXForm for that matter doesn't support non-string types. It
> supports
> any Object because essentially the DynaXXXForms internal data
> structure is a
> Map.
>
> In general the Struts form should be a ValueObject passing immutable
> data
> from the input
> to be processed or passing immutable data to the output to be rendered.
>
> The great thing about Struts is that it gives you more than enough
> "rope" to
> use wisely or hang yourself :)
>
> robert
>
>
>
>> -----Original Message-----
>> From: Engbers, ir. J.B.O.M. [mailto:J.B.O.M.Engbers@dlg.agro.nl]
>> Sent: Wednesday, December 17, 2003 9:24 AM
>> To: 'struts-user@jakarta.apache.org'
>> Subject: Newbie: java.lang.boolean and DynaActionForm?
>>
>>
>> Hi,
>>
>> Both 'Struts in Action' and 'Programming Jakarta Struts' state that
>> ActionForms and DynaActionForms are nearly equivalent and the
>> main advantage
>> of using DynaActionForms is that you don't have to declare all the
>> getters
>> and setters.
>> In DynaAction Forms each property can be of a (array of a)
>> primitive types.
>>
>> Thanks to Pedro Salgado and Martin Gainty (see "Retrieving boolean
>> properties from a DynaActionForm" on december 16), I partially
>> succeeded in
>> solving the first problem which only confronted me with the next
>> problem :-(
>> And while looking for a solution to that problem, I found a bugreport
>> (23355) in which Craig states that
>>
>> 'Adding these (getInteger, getBoolean etc, Ben) would encourage a
>> behavior
>> that Struts discourages -- using
>> non-String data types in a form bean.'
>>
>> Maybe that this explains why I have only found examples that use
>> String-properties (which lead me to my first question: where can I
>> find
>> examples that use non_string properties?) but it leaves me with the
>> more
>> fundamental question:
>> Why do DynaActionForms offer the possibility to declare non-String
>> properties without supporting them?
>> Should I avoid using DynaActionForms at all and use the
>> DynaValidatorForm?
>>
>> Ben Engbers
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: Newbie: java.lang.boolean and DynaActionForm?
Posted by Robert Taylor <rt...@mulework.com>.
To address the "fundemental" question, it is considered a "best practice"
to only use String or Boolean objects or collections of String and/or
Boolean objects or collection of
data structures which contain String and/or Boolean objects in your forms.
This is because it gives you
more control over validation. This doesn't mean that DynaActionForms or
any DynaXXXXForm for that matter doesn't support non-string types. It
supports
any Object because essentially the DynaXXXForms internal data structure is a
Map.
In general the Struts form should be a ValueObject passing immutable data
from the input
to be processed or passing immutable data to the output to be rendered.
The great thing about Struts is that it gives you more than enough "rope" to
use wisely or hang yourself :)
robert
> -----Original Message-----
> From: Engbers, ir. J.B.O.M. [mailto:J.B.O.M.Engbers@dlg.agro.nl]
> Sent: Wednesday, December 17, 2003 9:24 AM
> To: 'struts-user@jakarta.apache.org'
> Subject: Newbie: java.lang.boolean and DynaActionForm?
>
>
> Hi,
>
> Both 'Struts in Action' and 'Programming Jakarta Struts' state that
> ActionForms and DynaActionForms are nearly equivalent and the
> main advantage
> of using DynaActionForms is that you don't have to declare all the getters
> and setters.
> In DynaAction Forms each property can be of a (array of a)
> primitive types.
>
> Thanks to Pedro Salgado and Martin Gainty (see "Retrieving boolean
> properties from a DynaActionForm" on december 16), I partially
> succeeded in
> solving the first problem which only confronted me with the next
> problem :-(
> And while looking for a solution to that problem, I found a bugreport
> (23355) in which Craig states that
>
> 'Adding these (getInteger, getBoolean etc, Ben) would encourage a behavior
> that Struts discourages -- using
> non-String data types in a form bean.'
>
> Maybe that this explains why I have only found examples that use
> String-properties (which lead me to my first question: where can I find
> examples that use non_string properties?) but it leaves me with the more
> fundamental question:
> Why do DynaActionForms offer the possibility to declare non-String
> properties without supporting them?
> Should I avoid using DynaActionForms at all and use the DynaValidatorForm?
>
> Ben Engbers
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org