• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

FormBean reset issue

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am experiencing a problem which i think is not normal. My FormBean retains the previous value(s) even when i override the reset() in my FormBean.
A temporary hack is to set my FormBean properties to null in my Action class which i am not at home with.
Any help/clues would be appreciated.

Thanks.
wale.
The code is posted here.

page.jsp


struts-config.xml


Action class


FormBean Class
 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Any help/clues would be appreciated.



In action class

return mapping.findForward("view");

this will makes you to remain in page.jsp itself.

This is clue,Now proceed
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When the form is submitted, Struts first calls the reset() method on the form and then it populates the form using the setters you've provided. It should not be surprising, then, that if you redisplay the same page, the fields will be populated. If the page is being redisplayed because of an error, it is generally desirable to redisplay the data entered by the user. If that's not what you want, just do what you're doing and set the fields to blank or null before redisplaying the page.
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi There I am having a similar kinda problem in Struts using the Checkboxes.

<c:forEach items="${facilityInformationBean.dCdMap}" var="mapEntry">
<html:multibox name="facilityInformationBean" property="renFuelTypeCheckBoxes" styleId="facilityInformationBean.activeFacility.renFuelTypeCheckBoxes" value="${mapEntry.key}"/><c: out value="${mapEntry.value}"/> (<c: out value="${mapEntry.key}"/>)
</c:forEach>

When i check atleast one of them it works perfectly fine, but when i uncheck everything and submit , it shows me the previous selection instead of uncheking everything.

So , I searched on google and found that one should overwrite the reset method in the action class.

How do i overwrite the reset method ?
@Override
public void reset(ActionMapping mapping, ServletRequest request) {
// TODO Auto-generated method stub
super.reset(mapping, request);
}



where in I can reset renFuelTypeCheckBoxes[] to empty one.

Can you please help me regarding this.

Thank you for your time

-Vamshi


 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic