Rick Reumann wrote:

Nic Werner wrote the following on 3/28/2005 1:06 PM:

I view the unspecified() method as the equivalent to 'index.jsp'. I deliberately put an index.jsp (or html) in the directory to provide the correct output, as opposed to leaving it unhandled - I see Struts and unspecified() as a mirror of this.


I don't really get the index.jsp comparison to unspecified?

You are purposely creating an default handler (index.jsp) for the root of that folder, just as you are purposely creating a method to handle Actions without the method parameter (unspecified)



Regardless, the reason I don't like using unspecified is two-fold:

1) The unspecified method is simply vague. Granted, this is by design, but in reality 'unspecified' will do 'something' so why not make it clear what you are going to do so it's easier for developers to quickly pick up on what the method implementation provides

This is what I'm trying to show with the index.jsp example - but you've learned a long time ago that if you call upon the root of a folder with no filename, index.* will be returned. Granted, this unspecified method is nowhere nearly as ingrained as default index.* calls.


. All unspecified does is save you from having to provide a dispatch parameter on your front end, which to me doesn't save that much coding and instead makes things unclear.

I like this because I have Actions that call other Actions and then need to return to the calling Action. Not having to deal with postpending '&method=display' and saving only the Action name is cleaner for me.



2) It could potentially lead to some unexpected behavior. What if on a page, you happened to forget to provide a dispatch parameter that you really intended to have? Your action would still get called and the unspecified method would be invoked. This could lead to the application working, but not as expected. I'd rather it break right away since it couldn't find the appropriate method name.

You are intentionally writing the unspecified method which is pretty close to intentionally writing a dispatch method. I could argue that what if you called the wrong Dispatch method by mistake? This could also lead to the application working, but not as expected.



Granted, other people like the unspecified method, so it's not that big of a deal and I like that Struts provides the option for those that want to take advantage of it. For me, it's just a matter of coding preference.


You're right, it really is a coding preference. For the majority of these types of issues, I feel that as long as you are consistent across your application, it isn't necessarily wrong or bad.

- Nic.


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



Reply via email to