Rodney, I had similar problems with a DispatchAction. The problem is, when the validation fails, it does not come into your action class; the good news is that you can define an 'input' attribute in your actionmapping (struts-config.xml) which will be used when your validation fails; I had put a reference to a .jsp page, but you can also specify an action.
In my DispatchAction class, I have a method name validateError(...); you then define the input attribute as input="myAction.do?method=validateError" myAction is an action mapping which maps to the same class. in this method you then can initialize what you need. Jan "Rodney Paul" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi All, > > I have a problem redisplaying form fields a user enters within a html form. > > I use the validate method to validate form entry fields through ActionForms. > and validate business logic in LookupDispatchAction classes. > > Has anyone experienced this problem, and is there any solution to this > matter. > > Cheers > Rodney > > > > CODE: > Below the code you see is part of an application I am building. > The problem here lies in the fact that in all cases, > field data does not get redisplayed within the form the user has entered data in. > > eg. if you enter a invalid data within a numeric data field (this instance ACN) > then the ActionForm issues a error message gets issued (works) > but the ACN previously entered does not get redisplayed in the form. > > eg. if you enter a valid ACN or Organisation Name within the fields to do searches, > and no data is applicable to the search criteria entered a error message gets issued (works) > but no ACN/Organisation Name gets redisplayed in the form where the data was entered. > > > > Part 1: Sample Configuration (struts-config.xml) > > <form-bean name="company.OrganisationNameSearchActionForm" > type="net.natdata.application.itf.insolvency.company.OrganisationNameSearchA ctionForm" /> > > <global-forwards> > <forward name="error" > path="/Error.jsp" /> > </global-forwards> > > <action path="/company/OrganisationNameSearch" > type="net.natdata.application.itf.insolvency.company.OrganisationNameSearchA ction" > name="company.OrganisationNameSearchActionForm" > input="/company/OrganisationNameSearch.jsp" > scope="request" > validate="true" > parameter="method"> > <forward name="next" path="/company/OrganisationBrowse.jsp" redirect="false" /> > <forward name="failure" path="/company/OrganisationNameSearch.jsp" redirect="false" /> > </action> > > <action path="/company/OrganisationBrowse" > type="net.natdata.application.itf.insolvency.company.OrganisationBrowseActio n" > name="company.OrganisationBrowseActionForm" > input="/company/OrganisationBrowse.jsp" > scope="request" > validate="true" > parameter="method"> > <forward name="previous" path="/company/OrganisationNameSearch.jsp" redirect="false" /> > <forward name="next" path="/company/OrganisationDetails.jsp" redirect="false" /> > <forward name="bill" path="/BillingAction.do" redirect="false" /> > <forward name="failure" path="/company/OrganisationBrowse.jsp" redirect="false" /> > </action> > > <controller nocache="true" > processorClass="net.natdata.application.itf.framework.NDCRequestProcessor" /> > > <message-resources parameter="resources.application" /> > > > > PART 2: Application form code (validation and reset methods) > > public class OrganisationNameSearchActionForm extends ActionForm { > > // Get and Set methods > .... > > public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { > ActionErrors errors = new ActionErrors(); > > if(method.equals("Next")) { > if((organisationName == null) || (organisationName.trim().equals(""))) { > errors.add("organisationName", new ActionError("error.organisationName.required")); > } > > if((ACN != null) && (!ACN.trim().equals(""))) { > try { > Integer.parseInt(ACN); > } > catch(NumberFormatException e) { > errors.add("ACN", new ActionError("error.ACN.format")); > } > } > } > > return errors; > } > > public void reset(ActionMapping mapping, HttpServletRequest request) { > this.method = null; > this.organisationName = null; > this.ACN = null; > } > } > > Part 3: Action Code (Sample) > > public class OrganisationNameSearchAction extends LookupDispatchAction { > protected java.util.Map getKeyMethodMap() { > Map map = new HashMap(); > map.put("button.next", "next"); > return map; > } > > public ActionForward next(ActionMapping mapping, ActionForm form, > HttpServletRequest request, HttpServletResponse response) > throws IOException, ServletException { > boolean error = false; > boolean failure = false; > String target = "next"; > ActionErrors actionErrors = new ActionErrors(); > > try { > HttpSession session = request.getSession(false); > if(session != null) { > OrganisationNameSearchMessageDTO organisationNameSearchResult = performOrganisationNameSearch(form, session); > if(organisationNameSearchResult == null) { > error = true; > } > else if(organisationNameSearchResult.getRequestRejectionGroup() != null) { > if(organisationNameSearchResult.getRequestRejectionGroup().getRejectionDetai lsSegment() != null) { > failure = true; > } > } > > if(!error && !failure) { > processResults(organisationNameSearchResult, session); > target = "next"; > } > else if(failure) { > String errorMsg = organisationNameSearchResult.getRejectionMessage(); > actionErrors.add(ActionErrors.GLOBAL_ERROR, new ActionError("errorMessage", errorMsg)); > target = "failure"; > } > else { > target = "error"; > } > } > else { > actionErrors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.noSession")); > target = "error"; > } > } > catch(Exception e) { > target = "error"; > } > finally { > // Save errors if needed and forward to the appropriate page to display > if(!actionErrors.isEmpty()) { > saveErrors(request, actionErrors); > } > return (ActionForward)mapping.findForward(target); > } > } > > .... > } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]