Well.. this is how it usually works: - Your jsp posts the data to the mapped Action - The ActionServlet intercepts the request, checks on your struts-config.xml which actionform it needs to use and in which scope it can be found. - If there's no such actionform in the scope then the ActionServlet instantiates a new one, populates it, calles its validate(), and if it returns null then forwardes it to its Action, otherwise forwards the request back to your "input jsp" together with the ActionErrors you eventually created. - If there's already such actionform in the scope, then it retrieves it, *calles its reset() method* and then carries on as above. ActionServlet *ALWAYS* calls the reset() method before using an actionform, so to avoid having stale data in it
I think the better thing for you is just implement your reset() in the proper way (i.e. setting to null all the properties you need to) instead of messing up with strange iterations. Regards Andrea -----Messaggio originale----- Da: Richard Yee [mailto:[EMAIL PROTECTED] Inviato: sabato 15 maggio 2004 0.01 A: Struts Users Mailing List; pls Oggetto: Re: How to set an ActionForm to null pls, You won't get an null ActionForm in your Action, you will just get an empty one. I think because you are testing for null, you are always populating it from the DB. Regards, Richard --- pls <[EMAIL PROTECTED]> wrote: > Hi Richard, > > I thought this one would work for sure.. but no > dice.. the values still > reappear (except for the multiboxes whcih are > cleared in the reset() method) > after > request.getSession().removeAttribute("MBForm"); and > a forward to the > next action. > > > "Richard Yee" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > pls, > > If the form exists in session scope, then you need > to > > remove it from session using the > > request.getSession.removeAttribute(<formName>) > method > > call. Otherwise, when the JSP page is executed, > struts > > will use the form from the session. > > > > Regards, > > > > Richard > > > > --- pls <[EMAIL PROTECTED]> wrote: > > > that won't change the form as it exists in > session > > > scope, only temporarily > > > in the action.. thanks anyways > > > > > > "Kiran Kumar" <[EMAIL PROTECTED]> wrote in > message > > > > > > news:[EMAIL PROTECTED] > > > > just a guess in ur execute method try this > > > > > > > > form = null; > > > > > > > > > > > > > > > > --- pls <[EMAIL PROTECTED]> wrote: > > > > > thanks for the suggestion Amol, but that > returns > > > an > > > > > IllegalStateException.. > > > > > thanks for trying anyways. > > > > > > > > > > > > > > > "Amol Yadwadkar" <[EMAIL PROTECTED]> wrote > in > > > > > message > > > > > > > > > > > > > > > news:[EMAIL PROTECTED] > > > > > > Hi, > > > > > > I havn't tried this but just try this in > the > > > > > execute method :-- > > > > > > public ActionForward execute(ActionMapping > > > > > mapping, ActionForm form, > > > > > > HttpServletRequest req, > HttpServletResponse > > > res) { > > > > > > ........ > > > > > > ... > > > > > > ... > > > > > > mapping.setAttribute(null); > > > > > > > > > > > > } > > > > > > > > > > > > Hope this may help you!!! > > > > > > --Amol > > > > > > > > > > > > -----Original Message----- > > > > > > From: pls [mailto:[EMAIL PROTECTED] > > > > > > Sent: Friday, May 14, 2004 10:03 AM > > > > > > To: [EMAIL PROTECTED] > > > > > > Subject: How to set an ActionForm to null > > > > > > > > > > > > > > > > > > hi there, > > > > > > > > > > > > i am trying to set an actionform to null > after > > > > > inserting it's properties > > > > > > into a DB. > > > > > > then, control is forwarded to a different > > > action > > > > > and the info is read from > > > > > > the DB back into the actionform for > display by > > > a > > > > > JSP. > > > > > > > > > > > > the only part that is giving me trouble is > > > with > > > > > explicitly setting my > > > > > > actionform "MBForm" to null. After > several > > > form > > > > > submissions and a DB > > > > > > update, the first Action attempts to clear > the > > > > > values in MBForm: > > > > > > > > > > > > > > > request.getSession().setAttribute("MBForm", > > > > > null); > > > > > > > > > > > > after this, control is forwarded to the > second > > > > > Action which handles the > > > > > > display. it checks to see if MBForm is > null > > > and, > > > > > if it is, it fills > > > > > MBForm > > > > > > from a DB. in between these two actions, > the > > > > > controller servlet is > > > > > > automatically refilling the MBForm with > the > > > values > > > > > that I just nullified.. > > > > > > the only bean property that stays empty is > > > myHash > > > > > which represents several > > > > > > groups of multiboxes. i believe this is a > > > result > > > > > of the MBForm reset() > > > > > > method which contains the following: > > > > > > > > > > > > myHash.put(multiBoxCategories, new > > > > > Integer[0]); //resets several > > > > > > groups of multiboxes > > > > > > > > > > > > setting other properties to null in the > > > reset() > > > > > method is not the solution > > > > > > as it wipes the value out after every (but > > > somehow > > > > > it doesn't do the same > > > > > > thing to the multiboxes?!?) > > > > > > > > > > > > let me know if this enough background for > you > > > to > > > > > help me diagnose the > > > > > > problem.. any discussion of reset() or is > > > > > welcome.. thanks > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > > 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] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > __________________________________ > > > > Do you Yahoo!? > > > > Yahoo! Movies - Buy advance tickets for 'Shrek > 2' > > > > > > > > > > http://movies.yahoo.com/showtimes/movie?mid=1808405861 > > > > > > > > > > === message truncated === __________________________________ Do you Yahoo!? SBC Yahoo! - Internet access at a great low price. http://promo.yahoo.com/sbc/ --------------------------------------------------------------------- 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]