You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Iain Sanderson <sa...@mc.duke.edu> on 2004/01/03 14:15:35 UTC

Re: Howto answer: Validate two input forms (PDA and 1024x768) for same Action

Answered my own question.

<action path="/SchedChoiceActions" type="
com.medtrix.orview.orstat.schedule.SchedChoiceActions" name="
SchedChoiceForm" validate="true" scope="request" parameter="livemethod" 
input="/schedule/schedchoices.jsp" />

and

<action path="/PdaSchedChoiceActions" type="
com.medtrix.orview.orstat.schedule.SchedChoiceActions" name="
SchedChoiceForm" validate="true" scope="request" parameter="livemethod" 
input="/pda/pdaschedchoices.jsp"/>

 ie 2 action paths in struts-config pointing to the same Action type, each 
referring back to different input JSPs. No extra code.

Iain.





Iain Sanderson <sa...@mc.duke.edu>
01/02/2004 09:51 AM
Please respond to "Struts Users Mailing List"
 
        To:     struts-user@jakarta.apache.org
        cc: 
        Subject:        Howto please: Validate two input forms (PDA and 
1024x768) for same Action


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.