You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Josh McDonald <jo...@workcoverqld.com.au> on 2006/01/18 01:19:11 UTC

Best practices questions

Hi all,
 
First of all, is there a site full of patterns and best practices for
tomcat?
 
Second, here's my specific enquiry: Let's say we've a page where you
select an item from a list, and then you can perform one of 5 actions on
it. 
 
One is 5 forms with different ".do" destinations, and javascript to
copy information from the "master form" into these forms and then submit
them. 
 
This doesn't really strike me as elegant. 
 
However the other solution that immediatly springs to mind is some form
of token (or god forbid an url or class name) describing what action to
call embedded in the form, and set with javascript. 
 
The problem with this, is it moves the "which class file to call to do
an action" decision is moved out of the struts-config.xml, into either
the jsp (in the case of the url/class name), or into some "wrapper"
servlet in the case of the token.
 
Now although ungainly, it seems to me that the first solution would be
preferrable as it would be the easiest to maintain in the future, but I
could be miles off I suppose :)
 
Any comments? Is there a third solution perhaps utilising some feature
in the action mapping or <html:form> of which I am unawares? It seems
like many people would have come up against this problem in the past.
 
Cheers,
-Josh
 
-- 
 
"His comrades fought beside him, Van Owen and the rest...
       But of all the thompson gunners- Roland was the best."
 
Josh McDonald
Analyst Programmer
Information Technology
Ph: 61 7 3006 6460
Email: josh.mcdonald@workcoverqld.com.au




***************************************************************************
Messages included in this e-mail and any of its attachments are those
of the author unless specifically stated to represent WorkCover Queensland. The contents of this message are to be used for the intended purpose only and are to be kept confidential at all times.
This message may contain privileged information directed only to the intended addressee/s. Accidental receipt of this information should be deleted promptly and the sender notified.
This e-mail has been scanned by Sophos for known viruses.
However, no warranty nor liability is implied in this respect.
****************************************************************************


Re: Best practices questions

Posted by Michael Jouravlev <jm...@gmail.com>.
On 1/17/06, Josh McDonald <jo...@workcoverqld.com.au> wrote:
> Hi all,
>
> First of all, is there a site full of patterns and best practices for
> [Struts]?

Common practices - yes, best - not sure about that ;-)))

> Second, here's my specific enquiry: Let's say we've a page where you
> select an item from a list, and then you can perform one of 5 actions on
> it.
>
> One is 5 forms with different ".do" destinations, and javascript to
> copy information from the "master form" into these forms and then submit
> them.

Does it look something like this:
http://www.superinterface.com/strutsdialog/crudactionlite.do

Why would not you just load relevant data from the server when you
display each of these pages?

> However the other solution that immediatly springs to mind is some form
> of token (or god forbid an url or class name) describing what action to
> call embedded in the form, and set with javascript.

What about dispatching-style action?

Michael.

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


Re: Best practices questions

Posted by Rick Reumann <ri...@gmail.com>.
Josh McDonald wrote:

> First of all, is there a site full of patterns and best practices for
> tomcat?

For Tomcat specifically? Not sure.

>  
> Second, here's my specific enquiry: Let's say we've a page where you
> select an item from a list, and then you can perform one of 5 actions on
> it. 
>  
> One is 5 forms with different ".do" destinations, and javascript to
> copy information from the "master form" into these forms and then submit
> them. 
>  
> This doesn't really strike me as elegant.

Nah, don't do that. You are correct, not elegant.

>  
> However the other solution that immediatly springs to mind is some form
> of token (or god forbid an url or class name) describing what action to
> call embedded in the form, and set with javascript.

Well, I like to use Dispatch actions to keep my related types of 
functionality in one Action class. To use a Dispatch action you simply 
pass a parameter to your Action (as defined in your action-mapping) 
which tells the Action which actual method to call.

> The problem with this, is it moves the "which class file to call to do
> an action" decision is moved out of the struts-config.xml, into either
> the jsp (in the case of the url/class name), or into some "wrapper"
> servlet in the case of the token.

Not really sure what you mean there since you can simply have different 
mappings which 'where they actually go to' is defined in the 
struts-config. I think you need to clarify a bit if we are talking about 
form submissions with a form tag or clicking on URL. Either way, I still 
use a DispatchAction to hold related functionality in one Action class.

You might want to take a look at a full example that mimics CRUD 
functionality (create,update,delete) and uses a Dispatch action.
http://www.learntechnology.net/struts-crud.do Some functionality in that 
example is called from an URL others from a form submit.

-- 
Rick

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