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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



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



Reply via email to