> -----Original Message----- > From: Donie Kelly [mailto:[EMAIL PROTECTED] > Sent: Wednesday, December 08, 2004 10:35 AM > To: Struts Users Mailing List > Subject: RE: Form validation > > > Hi Jim > > Tried that but I have Javascript validation turned on for the > page. It's > kicking in before the submit. Is there a way to disable the javascript > validation when the cancel button is pressed.
Well... sure... change the way the javascript fires. The javascript is probably being fired by the sumit event, change it so that it only fires when the right button is pressed. That should be part of the jap page, and not a configuration issue/action issue at all. > > Thanks > Donie > > > -----Original Message----- > From: Jim Barrows [mailto:[EMAIL PROTECTED] > Sent: 08 December 2004 17:36 > To: Struts Users Mailing List > Subject: RE: Form validation > > > > > -----Original Message----- > > From: Donie Kelly [mailto:[EMAIL PROTECTED] > > Sent: Wednesday, December 08, 2004 10:22 AM > > To: Struts Users Mailing List > > Subject: RE: Form validation > > > > > > Thanks Jim, that works for the initial validation. Thank you. > > > > However, if you look at my code below you'll see I have a > > reset button on > > the page. When I press this I want the form to repopulate > > like it does on > > initial entry. However, the validation is kicking in. > > > > If I have bad values on the form I cannot reset the page. > > > > What can I do in this case? > > Oh... in that case the reset button should go to the action > that displays > the page in the first place, which will have the > validation=false on it. > This is a good place for one of the dispatch actions. > > > > Thanks > > Donie > > > > > > -----Original Message----- > > From: Jim Barrows [mailto:[EMAIL PROTECTED] > > Sent: 08 December 2004 17:28 > > To: Struts Users Mailing List > > Subject: RE: Form validation > > > > > > > > > -----Original Message----- > > > From: Donie Kelly [mailto:[EMAIL PROTECTED] > > > Sent: Wednesday, December 08, 2004 10:14 AM > > > To: Struts Users Mailing List > > > Subject: Form validation > > > > > > > > > Hi all > > > > > > > > > > > > I have a form that uses the standard form validation based on the > > > validation.xml file. It all works fine except for when I'm > > > pre-populating > > > the form on first showing. The validation is kicking in > > > before the data is > > > retrieved from the database. > > > > It's not the action class... it's in the struts-config file. > > validation="false" I believe is what you want for the > > pre-population to work > > without validation. > > > > > > > > > > > > > > > > Can anybody show me how to initialise the form correctly. > > > Here is my Action > > > class > > > > > > > > > > > > Thanks > > > > > > Donie > > > > > > > > > > > > > > > > > > import java.util.Locale; > > > > > > import javax.servlet.http.HttpServletRequest; > > > > > > import javax.servlet.http.HttpServletResponse; > > > > > > import javax.servlet.http.HttpSession; > > > > > > import org.apache.log4j.Category; > > > > > > import org.apache.struts.action.Action; > > > > > > import org.apache.struts.action.ActionForm; > > > > > > import org.apache.struts.action.ActionForward; > > > > > > import org.apache.struts.action.ActionMapping; > > > > > > import org.apache.struts.util.MessageResources; > > > > > > import org.apache.commons.beanutils.BeanUtils; > > > > > > > > > > > > import com.tecnomen.mms.sm.backend.*; > > > > > > > > > > > > public final class ContentAdaptationFormMainAction extends Action > > > > > > { > > > > > > static Category log = > > > > > > Category.getInstance(ContentAdaptationFormMainAction.class.getName()); > > > > > > public ActionForward execute(ActionMapping > > > mapping,ActionForm form, > > > HttpServletRequest request,HttpServletResponse response) > > > throws Exception > > > > > > { > > > > > > Locale locale = > > > getLocale(request); > > > > > > MessageResources > > > messages = > > > getResources(request); > > > > > > HttpSession session = > > > request.getSession(); > > > > > > ActionForward > forward = > > > mapping.findForward("success"); //default > > > > > > > > > > > > // Get the data for > > > oSystemContentAdaptation > > > > > > > > > ContentAdaptationService service > > > = new ContentAdaptationService(); > > > > > > > > > ContentAdaptationForm theForm = > > > (ContentAdaptationForm) form; > > > > > > > > > ContentAdaptationDTO caDTO; > > > > > > > > > > > > > > > > > > > > > int buttonSelect = > > > theForm.getSelected(); > > > > > > > > > > > > switch(buttonSelect) > > > > > > { > > > > > > > > case > > > ContentAdaptationForm.SUBMIT_BUTTON: > > > > > > > > > log.info("Submit CA form"); > > > > > > > > > > > > > > > // Create new data object for this form > > > > > > > > > caDTO = new ContentAdaptationDTO(); > > > > > > > > > BeanUtils.copyProperties(caDTO, theForm ); > > > > > > > > > service.setContentAdaptation(caDTO); > > > > > > > > > forward = new ActionForward(mapping.findForward("submit")); > > > > > > > > > break; > > > > > > > > > > > > > > case > > > ContentAdaptationForm.CANCEL_BUTTON: > > > > > > > > > log.info("Cancel CA form"); > > > > > > > > > forward = new ActionForward(mapping.findForward("cancel")); > > > > > > > > > break; > > > > > > > > case > > > ContentAdaptationForm.RESET_BUTTON: > > > > > > > > > log.info("Reset CA form"); > > > > > > > > > default: > > > > > > > > > // Populate the form > > > > > > > > > caDTO = new ContentAdaptationDTO(); > > > > > > > > > caDTO = service.getContentAdaptation(); > > > > > > > > > BeanUtils.copyProperties( theForm, caDTO ); > > > > > > > > > break; > > > > > > } > > > > > > return forward; > > > > > > } > > > > > > } > > > > > > > > > > > --------------------------------------------------------------------- > > 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] > > > > > > --------------------------------------------------------------------- > 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] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]