--- Ted Husted <[EMAIL PROTECTED]> wrote:
> Yes, ideally the Action should be able to focus on
> the top-level
> outcome of the business logic. Did the request
> success or fail? Was
> there a recoverable error? A fatal exception?

...  and struts2 action being xwork action does just 
this - no more or less. it performed business logic
and determined outcome as string result name. 


> Then, the Action returns a code that indicates
> logical outcome. In
> practice, the result code maps to a result that
> encapsulates a path.

it maps to some kind of result - it just happens that
there are results now (mostly) which encapsulate a 
path. 


> But, what if there are flavors of success or
> failure?. 

... they are kind of different results.

>As Don points
> out, we might want to present different pages based
> on the browser.

What action got to do with it? 

> Or, we might want to present different pages based
> on locale? 
... not an action business. result shall take care of
this ( like rewrite rules in httpd - call it
LocalAwareResult which pulls locale and , say, adds 
proper suffix )
> Or based on security role?
...  again result could take this over.  or even
template itself. 

> Do we want to cram all this into a single result
> code?

yep. with proper results and maybe kind of 
interceptors

> Of course, we _could_. One alternative would be to
> have codes like
> 
> <action name="ViewFoo" class="mypackage.ViewFoo">
> 
>     <result
> name=""success.modern-browser">ViewFoo.jsp</result>
>     <result
>
name="success.netscape4">ViewFoo-netscape4.jsp</result>
> 
>     <result
>
name="failure.modern-browser">ViewFoo-failure.jsp</result>
>     <result
>
name="failure.netscape4">ViewFoo-netscape4-failure.jsp</result>
> 
>  <action>
> 
> And, the selection logic would be delegated to a
> helper method that
> generated the token
> 
>     return findResult("success");


Congratulation.  You are describing ( somehow )
situation of struts-1 - action has to be aware of
servlet environment  and take decisions based on it. 
And how are you going to sumulate this in tests? 

> But, in practice, this has proven to be a very
> common use case.
> There's the browser-agent case, the ajax-case, the
> localization-case,
> the security-roles case, to name a few. We often
> want to select a
> specialized result for the same general outcome
> ("success", "failure",
> "error", "exception", "login") .

Why do it in action? 

regards,

----[ Konstantin Pribluda http://www.pribluda.de ]----------------
Still using XDoclet 1.x?  XDoclet 2 is released and of production quality.
check it out: http://xdoclet.codehaus.org


 
____________________________________________________________________________________
Low, Low, Low Rates! Check out Yahoo! Messenger's cheap PC-to-Phone call rates 
(http://voice.yahoo.com)


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

Reply via email to