RE: wizard form and checkboxes that won't turn off
That's definitely one solution. The other is to have an onsubmit method on the form with javascript to iterate over all the input elements in the form, find unchecked check-boxes, and create a hidden input with the same name and a value of "false". - Dan > -Original Message- > From: James Mitchell [mailto:[EMAIL PROTECTED] > Sent: Thursday, February 03, 2005 8:07 PM > To: Struts Users Mailing List > Subject: Re: wizard form and checkboxes that won't turn off > > The problem is that the browser submits a value of "on", when > you check a > checkbox and submit the form. However, if you uncheck the > checkbox and > submit the form, the browser does _not_ submit "off" or > "false" or anything. > So, with your form sitting in session, how will it know that > you want it > "off"? > > Here's how: you need to implement reset() method on your > form. In that > method you need to set the field that is backing the checkbox > to "false" or > "off". When Struts processes the request, it will call reset, then > repopulate based on requesteffectively giving the > _appearance_ that the > browser sent "off". > > ----- Original Message - > From: "Janice" <[EMAIL PROTECTED]> > To: > Sent: Thursday, February 03, 2005 6:32 PM > Subject: wizard form and checkboxes that won't turn off > > > Could somebody please refer me to a solution to this? > > I have a form bean (session-scoped) that is displayed over 3 > pages. There > are "back" and "next" buttons. Once a checkbox is selected > and the user has > moved to another page, it can't be cleared again. I have > read that this is > because the checkbox item is now in the session and simply > unchecking it > does not remove it from the session. What I haven't found is > a solution or > workaround. > > I am using struts 1.1. > > Thanks very much in advance, > J - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: wizard form and checkboxes that won't turn off
Thanks James, now all the other stuff that I read about reset makes sense. I had been assuming that since I don't have a reset function for my form that I didn't need it. Now I'm having issues with my nested forms. Does anyone have a recommendation on how to deal with them? This is what I've done: <... snip from reset method ...> if (thePage == 2) { if (map.containsKey("dfcAPInd")) map.put("dfcAPInd", Boolean.FALSE); subformReset("projectTypes", map, actionMapping, httpServletRequest); <... end snip from reset method ...> <... snip subformReset method ...> private void subformReset(String key, Map map, ActionMapping actionMapping, javax.servlet.http.HttpServletRequest httpServletRequest) { if (map.containsKey(key)) { ArrayList list = (ArrayList)map.get(key); Iterator it = list.iterator(); DynaValidatorSimpleXrefForm widgetFormBean; while (it.hasNext()) { widgetFormBean = (DynaValidatorSimpleXrefForm)it.next(); widgetFormBean.reset(actionMapping, httpServletRequest); } } } <... end snip subformReset method ...> The reset method in the nested form only resets a couple of checkboxes. But now I get validation errors. The validation on the nested forms is as follows: <... snip validation ...> field[0] comments fieldTest[0] NOTNULL field[1] BMGS fieldTest[1] NOTNULL field[2] ADDL fieldTest[2] NOTNULL fieldJoin OR <... end snip validation ...> It is like all the nested forms throw an error if they haven't been filled out at all. So if I have 10 projectTypes and I check off 3 of them, I get 7 errors. Any ideas? Thanks in advance, J --- In [EMAIL PROTECTED], "James Mitchell" <[EMAIL PROTECTED]> wrote: > The problem is that the browser submits a value of "on", when you check a > checkbox and submit the form. However, if you uncheck the checkbox and > submit the form, the browser does _not_ submit "off" or "false" or anything. > So, with your form sitting in session, how will it know that you want it > "off"? > > Here's how: you need to implement reset() method on your form. In that > method you need to set the field that is backing the checkbox to "false" or > "off". When Struts processes the request, it will call reset, then > repopulate based on requesteffectively giving the _appearance_ that the > browser sent "off". > > > -- > James Mitchell > Software Engineer / Open Source Evangelist > EdgeTech, Inc. > 678.910.8017 > AIM: jmitchtx > > - Original Message - > From: "Janice" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Thursday, February 03, 2005 6:32 PM > Subject: wizard form and checkboxes that won't turn off > > > Could somebody please refer me to a solution to this? > > I have a form bean (session-scoped) that is displayed over 3 pages. There > are "back" and "next" buttons. Once a checkbox is selected and the user has > moved to another page, it can't be cleared again. I have read that this is > because the checkbox item is now in the session and simply unchecking it > does not remove it from the session. What I haven't found is a solution or > workaround. > > I am using struts 1.1. > > Thanks very much in advance, > J > > > > - > 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]
Re: wizard form and checkboxes that won't turn off
The problem is that the browser submits a value of "on", when you check a checkbox and submit the form. However, if you uncheck the checkbox and submit the form, the browser does _not_ submit "off" or "false" or anything. So, with your form sitting in session, how will it know that you want it "off"? Here's how: you need to implement reset() method on your form. In that method you need to set the field that is backing the checkbox to "false" or "off". When Struts processes the request, it will call reset, then repopulate based on requesteffectively giving the _appearance_ that the browser sent "off". -- James Mitchell Software Engineer / Open Source Evangelist EdgeTech, Inc. 678.910.8017 AIM: jmitchtx - Original Message - From: "Janice" <[EMAIL PROTECTED]> To: Sent: Thursday, February 03, 2005 6:32 PM Subject: wizard form and checkboxes that won't turn off Could somebody please refer me to a solution to this? I have a form bean (session-scoped) that is displayed over 3 pages. There are "back" and "next" buttons. Once a checkbox is selected and the user has moved to another page, it can't be cleared again. I have read that this is because the checkbox item is now in the session and simply unchecking it does not remove it from the session. What I haven't found is a solution or workaround. I am using struts 1.1. Thanks very much in advance, J - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: wizard form and checkboxes that won't turn off
Thanks Eric, I wasn't sure exactly where you meant me to put that, so I tried it here: <..snip..> public ActionForward nextForm(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { DynaValidatorForm dvf = (DynaValidatorForm)form; int pageNumber = ((Integer)dvf.get("page")).intValue(); ActionErrors errors = submissionFormValidate(mapping, form, request, pageNumber); if (!errors.isEmpty()) { saveErrors(request, errors); return mapping.findForward("form" + String.valueOf(pageNumber)); } pageNumber = pageNumber + 1; String target = "form" + String.valueOf(pageNumber); dvf.set("page", new Integer(pageNumber)); //return (mapping.findForward(target)); ActionForward cleanDisplay = mapping.findForward(target); cleanDisplay.setRedirect(true); return cleanDisplay; } <..end of snip..> But all I get is a 500 error: java.lang.IllegalStateException: Configuration is frozen Was there somewhere else I should put it? J --- In [EMAIL PROTECTED], "Eric Lemle" <[EMAIL PROTECTED]> wrote: > this might help, in your action not sure if this is in 1.1 either. > > ActionForward cleanDisplay= new ActionForward("add your code here"); > cleanDisplay.setRedirect(true); > return cleanDisplay; > > Eric D. Lemle > Senior Programmer / Analyst > Intermountain Health Care > 36 South State Street, Suite 1100 > Salt Lake City, Utah 84111 > United States of America (USA) > (801) 442-3688 -- e-mail: [EMAIL PROTECTED] > > > >>> [EMAIL PROTECTED] 2/3/2005 4:32:14 PM >>> > Could somebody please refer me to a solution to this? > > I have a form bean (session-scoped) that is displayed over 3 pages. > There > are "back" and "next" buttons. Once a checkbox is selected and the > user has > moved to another page, it can't be cleared again. I have read that > this is > because the checkbox item is now in the session and simply unchecking > it > does not remove it from the session. What I haven't found is a > solution or > workaround. > > I am using struts 1.1. > > Thanks very much in advance, > J > > - > 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]
Re: wizard form and checkboxes that won't turn off
this might help, in your action not sure if this is in 1.1 either. ActionForward cleanDisplay= new ActionForward("add your code here"); cleanDisplay.setRedirect(true); return cleanDisplay; Eric D. Lemle Senior Programmer / Analyst Intermountain Health Care 36 South State Street, Suite 1100 Salt Lake City, Utah 84111 United States of America (USA) (801) 442-3688 -- e-mail: [EMAIL PROTECTED] >>> [EMAIL PROTECTED] 2/3/2005 4:32:14 PM >>> Could somebody please refer me to a solution to this? I have a form bean (session-scoped) that is displayed over 3 pages. There are "back" and "next" buttons. Once a checkbox is selected and the user has moved to another page, it can't be cleared again. I have read that this is because the checkbox item is now in the session and simply unchecking it does not remove it from the session. What I haven't found is a solution or workaround. I am using struts 1.1. Thanks very much in advance, J - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
wizard form and checkboxes that won't turn off
Could somebody please refer me to a solution to this? I have a form bean (session-scoped) that is displayed over 3 pages. There are "back" and "next" buttons. Once a checkbox is selected and the user has moved to another page, it can't be cleared again. I have read that this is because the checkbox item is now in the session and simply unchecking it does not remove it from the session. What I haven't found is a solution or workaround. I am using struts 1.1. Thanks very much in advance, J