RE: action and form contract

2002-03-05 Thread Carter, Steve

Thanks. That's clear. However -- not to nit-pick, but -- in the first paragraph you 
have "contact" and it appears you mean "contract".

Steve

Steve Carter
Sr. Software Engineer
Swift Rivers
[EMAIL PROTECTED]


-Original Message-
From: Ted Husted [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 22, 2002 5:10 AM
To: Struts Users Mailing List
Subject: Re: action and form contract


How about this:

Do not blindly check for null ActionForm beans in all your Actions

If an Action expects an ActionForm bean, then its API contact with the
ActionMappings should require that a particular ActionForm bean, or
subclass thereof, be named in the ActionMapping. The Action's contract
with the controller is that it will always instantiate the bean before
the Action is called. If either contract is broken, the application
should expose a null pointer exception so that the programming error is
fixed and the misunderstanding resolved. Whether an Action expects an
ActionForm bean should be specified in its Javadoc.

Alternatively, the perform method should provide a general check of all
its preconditions, including, but not limited to, the existance of an
ActionForm bean. 

Do check for essential preconditions in your Actions

The perform method in the Action is a key hotspot in the framework, and
may be realizing several different API contracts. To be sure all the
contracts are being met, provide a general error catching routine for
your Actions. This can look for any number of preconditions including
whether there is a form bean when one is expected, and whether it is of
the requesite class, and provide the appropriate error messages. 

See the SuperAction class in the Scaffolding package for a working
example. Scaffolding can be found in the Contrib folder of the nightly
build.

-- Ted Husted, Husted dot Com, Fairport NY US
-- Developing Java Web Applications with Struts
-- Tel: +1 585 737-3463
-- Web: http://husted.com/about/services


"Carter, Steve" wrote:
> 
> On husted.com, Ted Husted wrote:
> Do not check for null ActionForm beans in your Actions
> If an Action expects an ActionForm bean, then its API contact with the 
>ActionMappings should require that this bean, or a subclass, be named in the 
>ActionMapping. The Actions contact wit the controller is that it will always 
>instantiate the bean before the Action is called. If either contact is broken, the 
>application should expose a null pointer exception so that the problem is fixed and 
>the misunderstanding resolved. Whether an Action expects an ActionForm bean should be 
>specified in its Javadoc.
> 
> Now I'm wondering if 'contact' was a type and what he meant was 'contract', that is, 
>in the sense of an API contract or implied constrain, pre-condition.
> 
> (You out there Ted?)
> 
> Anyway, this seems like a good idea. I'm always complaining that exceptions are 
>often overused or misused in Java, and this seems like a good use: let the exception 
>raise havoc, in order to inform you of a really exceptional condition, and one that 
>should be exposed if it exists.
> 
> Steve Carter
> Sr. Software Engineer
> Swift Rivers
> [EMAIL PROTECTED]
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

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


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




action and form contract

2002-02-20 Thread Carter, Steve

On husted.com, Ted Husted wrote:
Do not check for null ActionForm beans in your Actions
If an Action expects an ActionForm bean, then its API contact with the ActionMappings 
should require that this bean, or a subclass, be named in the ActionMapping. The 
Actions contact wit the controller is that it will always instantiate the bean before 
the Action is called. If either contact is broken, the application should expose a 
null pointer exception so that the problem is fixed and the misunderstanding resolved. 
Whether an Action expects an ActionForm bean should be specified in its Javadoc.

Now I'm wondering if 'contact' was a type and what he meant was 'contract', that is, 
in the sense of an API contract or implied constrain, pre-condition.

(You out there Ted?)

Anyway, this seems like a good idea. I'm always complaining that exceptions are often 
overused or misused in Java, and this seems like a good use: let the exception raise 
havoc, in order to inform you of a really exceptional condition, and one that should 
be exposed if it exists.



Steve Carter
Sr. Software Engineer
Swift Rivers
[EMAIL PROTECTED]


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




RE: bug with the select tag value attribute? - Solved somewhat

2002-01-31 Thread Carter, Steve

I think that 
I think the problem is with the dot notation. I found that something like the 
following works:

 

This assumes OrganizationForm has a field parentOrgId of type String.

Is PARENT_ORG_ID a Constant in your form?


Steve Carter
Sr. Software Engineer
Swift Rivers
[EMAIL PROTECTED]


-Original Message-
From: Maturo, Larry [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 31, 2002 3:17 PM
To: 'Struts Users Mailing List'
Subject: bug with the select tag value attribute? - Solved somewhat


I finally figured out what was wrong.

The below did not work:




because value expects a constant, not a reference to a field in a form.

My solution was to put the value into the session in my action class,
thusly:
request.getSession().setAttribute(ORG_TYPE,orgType);

Then in the jsp I now have:

   


This works, because the value is a string.  Now, the next question is, can I
do
this with the value stored in my form bean, instead of having to stuff it
into
the session (by the way, stuffing into the request did not work)?

-- Larry Maturo
   [EMAIL PROTECTED]




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


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




RE: scpritlet and iterate

2002-01-29 Thread Carter, Steve

Since you want to referenct the object listeArticlesCategorie in the iterate tag, you 
must have such an object in scope, so <%=listeArticlesCategorie.size()%> should work. 
It would, in this case, write the value on each iteraration, I think. I've done 
something similar when debugging, to see if the array was populated (but I did it 
before the iterate).

Steve Carter
Sr. Software Engineer
Swift Rivers
[EMAIL PROTECTED]


-Original Message-
From: Philippe Hodapp / 1genia [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 29, 2002 1:13 PM
To: Struts Users Mailing List
Subject: scpritlet and iterate


Can somebody tell me if it is possible to use a scriptlet with the variable
from the iterate tag
For example iw ould like this :


<%=listeArticlesCategorie.size()%>
  




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


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