I'm evolving a large STRUTS medical application to place some of it's functionality on 802.11b-enabled Pocket PC devices using Mobile IE, reformatting views to the 240x320 pixel resolution for these devices. My method is to test the request header for this resolution and Forward the response on to smaller (240x320) output JSPs, leaving all the underlying Action and business logic unchanged. It works very well, maintaining nice MVC principles. The challenge is that I would like to do the same with input forms, but cut down the input view for the PDA version, maintain validation for the PDA version, and return control to the PDA version if a validation error occurs.
This is the Action code that directs the ActionForward to two outputs, one regular, one PDA. public class SchedChoiceActions extends DispatchAction { // some more ActionForwards here /* *The "liveOff" Action is invoked if the "liveOff" request parameter has the value "off" * */ public ActionForward liveOff(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // more stuff // Forward control to the specified success URI if(request.getHeader("user-agent").indexOf("240x320")>0) {return (mapping.findForward("outputPdaVersion")); } else{ return (mapping.findForward("output"));} } } Here's the problem on the INPUT side. If a validation error ocurs in the PDA version of an input form, I only have one option of returning control to the input form, and in my current app, it returns control via struts-config to a regularly sized JSP. I can't differentially send a PDA validation error back to the PDA input JSP, sharing the Action with a regular set of input forms. Is there an elegant solution for this? Areas I'm exploring 1) Chaining an action for the PDA version input form to call the 'regular' action, which can then test for output resolution as above ( ugh!).2) Can Strut's Validator do this? (currently validating only in ActionForms). Thanks, Iain Sanderson.