| Author |
FormBean reset issue
|
adewale shobajo
Greenhorn
Joined: Nov 11, 2005
Posts: 4
|
|
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
|
 |
vidya sagar
Ranch Hand
Joined: Mar 02, 2005
Posts: 580
|
|
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
|
 |
Merrill Higginson
Ranch Hand
Joined: Feb 15, 2005
Posts: 4864
|
|
|
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.
|
Merrill
Consultant, Sima Solutions
|
 |
Vamshi Jampala
Ranch Hand
Joined: Feb 23, 2008
Posts: 40
|
|
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
|
 |
 |
|
|
subject: FormBean reset issue
|
|
|