• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How do I do this, input field retains value

 
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have one jsp page with 2 text fields, I am using
DynaValidatorForm,
I have an action form where in i call an program to
update the database with these vaues.
and reloads the same jsp
Now the problem is
1> I have defined the 2 text fields as following
<html:text property="input1" size="15" maxlength="8"
/>
<html:text property="input2" size="15" maxlength="8"
/>
When there is some error, i get the error message and
also the retain the values entered by the user in
these fields.
But the values are also retained even if those are
updated in data base??
so how can i avoid reloading of these values when
there is no error
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ashish,
In your action class after performing your business logic, you can add the following code to make the fields on the form empty.
if(form instanceof DynaForm)
{
DynaForm f=(DynaForm)form;
f.setInput1("");
f.setInput2("");
}
setInput1 and setInput2 methods reflects the variable and methods defined in actionform class.
I hope you find this info useful.
Loke.
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I think following code might be helpfull to you.
// Remove the obsolete form bean
if (mapping.getAttribute() != null) {
if ("request".equals(mapping.getScope()))
request.removeAttribute(mapping.getAttribute());
else
session.removeAttribute(mapping.getAttribute());
}
this is the code used to invalidate/reset the form-bean. complete code is avalibale in struts-exampls Action.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic