Clear the fields in struts form
Hi all,
I am using struts, here I have opened a new window using
javascript:openWindow
for adding the contact details of the person into the database. Every thing works fine, but my problem over here is that when I submit the form and if I open again I have the previous entered values.
I tried using javascript:reset() on on submit function, but the problem here is that when I use reset it is resetting the values with out submitting, and if I use document.FormName.submit(); before document.FormName.reset(); it is submitting twice as I am using <html:submit/>
How can I solve this problem. Help me out Thanks in Advance.
[668 byte] By [
Sowja] at [2007-11-27 11:37:45]

# 1
hi,
<body onLoad="javascript:reset()">
whenever your page load, it will reset and display with default values,
or
write a clear cache code in <head> <meta .....></head>
# 2
what is the scope of the FormBean you are using for this contact details page?
If it is session scope, could you make it request scope?
# 3
simply change in struts-config.xml
for ex:
<action path="/register"
type="registrationAction"
name="registerForm"
scope="request"
input="/registration.jsp">
<forward name="success" path="/index.jsp?bodyname=/shownewid.jsp"/>
<forward name="failure" path="/index.jsp?bodyname=/registration.jsp"/>
</action>
# 4
Thank you all for your valuable suggestions. They helped me a lot!!!
I have one more doubt, If I change the scope to request, can I set attributes in the session, and is there any limit on setting them, i.e. does setting more session attributes reduce the performance?
Message was edited by:
Sowj
Sowja at 2007-7-29 17:16:16 >
