I have a struts application modelled after the struts-example. It has XForm.java as the form bean, x.jsp to display the form, and EditXAction.java and SaveXAction.java to process the actions.
The Edit and Save actions need to use an XMaintainance class as it provides the knowledge of the business logic. In SaveXAction I've checked to make sure the request wasn't cancelled and checked the transaction token (normal struts stuff). I need to do additional validations when an XForm is being created so I've added a validate() method to XMaintainance. So the SaveXAction code does something like the following: ActionErrors errors = new ActionErrors(); XForm xf = (XForm)form; XMaintainance xm = new XMaintainance(); if ( ! xm.validate(xf) ) { errors.add("error", new ActionError("Xerrors")); } and later check to see if there have been any errors, and if so, saveErrors() and saveToken() are called and we forward back to the mapping.getInput(). That works great! My question is: XForm is considered to be a View component. SaveXAction is considered to be a Controller component. XMaintainance is a Model component. By passing the XForm to XMaintainance haven't I mingled the two components when there was no need? Mingled is the wrong word. Instead, SaveXAction could mediate the interaction between the view and the model by copying values from the view into the controller: xm.setXFormField1( xf.getField1() ); ... if ( ! xm.validate() ) { errors.add("error", new ActionError("Xerrors")); } Performance wise it would be wasteful to copy the values from XForm to XMaintainance. But isn't one of the goal of MVC to separate the Model from the View by way of the Controller? Where do we make the split between the three components? For instance, how do report errors from XMaintainance? I could change the code above to be: ActionErrors errors = new ActionErrors(); XForm xf = (XForm)form; XMaintainance xm = new XMaintainance(); if ( ! xm.validate(xf, errors) ) { errors.add("error", new ActionError("Xerrors")); } But now I've mingled a core Controller element (ActionError) to the Business logic layer. If I don't do this though, I'll have to use something similar to ActionErrors that XMaintainance knows about. SaveXAction would have to copy these errors to the Struts ActionErrors. It seems like a lot of copying is being done in order to separate the components. Does any of this make any sense? I guess I'm looking for advice, on how to split the three MVC components and pass information between the layers. Thanks, K. __________________________________________________ Do You Yahoo!? Yahoo! Finance - Get real-time stock quotes http://finance.yahoo.com _______________________________________________ MVC-Programmers mailing list [EMAIL PROTECTED] http://www.netbean.net/mailman/listinfo/mvc-programmers