You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Nic Werner <we...@sonoma.edu> on 2005/03/10 04:40:53 UTC
Page flow with some business logic
Hi,
Big picture, I have a form that gives you the ability to 'move' an
object. I'd like to check to see if the destination location already
exists so nothing would be overwritten. If something does exist, I'd
like to output what object (and its values) is there, and do a
confirmation screen. Can someone help on how I would do this type of
logic with Struts?
Would it work if I had a business function called CanMove() that
returned the object at that destination and null if the destination was
empty? If null, I would just call my Update() function? If not empty,
have Struts forward to a confirmation screen? Is this the proper convention?
I apologize that this isn't totally Struts related, but this forum has
been great at ensuring I don't re-invent the wheel.
- Nic.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Page flow with some business logic
Posted by Erik Weber <er...@mindspring.com>.
Yes, having methods along the lines of "ensureXXXX" and "doXXXX" that
are paired makes sense and I have seen the strategy work well. The
challenge is that you often want these two methods to be invoked within
a single transaction context. For example, you don't want to return true
from ensureXXXX, then something happens which would cause ensureXXXX to
return false before you invoke doXXXX. (But of course you still want to
account for the case in which that does happen.) You probably don't want
your Struts Action to have to worry about managing transactions; so
probably your Struts Action invokes some delegate method
(moveIfPossible?) that either returns a success code/value or throws an
Exception. The delegate encapsulates transactional behavior (or hides
the fact that atomicity isn't ensured yet ;) ) and interacts with some
manager layer component on behalf of your Actions. I'm not saying "this
is how you do it", more just giving you food for thought.
Take a look at "Core J2EE Patterns" (awesome book) and/or the Sun J2EE
blueprints site for some patterns and idioms.
Erik
Nic Werner wrote:
> Hi,
> Big picture, I have a form that gives you the ability to 'move' an
> object. I'd like to check to see if the destination location already
> exists so nothing would be overwritten. If something does exist, I'd
> like to output what object (and its values) is there, and do a
> confirmation screen. Can someone help on how I would do this type of
> logic with Struts?
>
> Would it work if I had a business function called CanMove() that
> returned the object at that destination and null if the destination
> was empty? If null, I would just call my Update() function? If not
> empty, have Struts forward to a confirmation screen? Is this the
> proper convention?
>
> I apologize that this isn't totally Struts related, but this forum has
> been great at ensuring I don't re-invent the wheel.
>
> - Nic.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org