This week's giveaway is in the Testing forum.
We're giving away four copies of TDD for a Shopping Website LiveProject and have Steven Solomon on-line!
See this thread for details.
Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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.
 
Paper beats rock. Scissors beats tiny ad.
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic