• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

To retrieve new value from text box

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Ranchers,
In my jsp, i have a text box which gets a value populated on load of the page from this code:


Now I want to edit this text box in the jsp itself and and on submit of the form it will go the action class from where it will hit the database.

My problem is , i want to retrieve this new edit value in the action class.But when i 'm writing this piece of code in action class:

It is fetching me the old value that is stored in the formbean under the department attribute which again is a bean.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there a reason you aren't using the Struts <html:text> tag for this? If you simply write:

It will work. In case you didn't realize it, Struts does populate the value attribute automatically based on the current contents of the ActionForm bean, so specifying a value attribute is unnecessary.

If you insist on using the plain HTML <input> tag, it will also work if you change the name attribute from textfield2 to department.workchecDepartmentName. Struts uses the name attribute of an input to populate the ActionForm bean.
[ February 21, 2007: Message edited by: Merrill Higginson ]
 
Akshay Singhvi
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Merrill,
Thanks for the advice, But my problem still persist. Can you help me out.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Show us your code including relevant portions of:
  • struts-config.xml
  • The ActionForm bean
  • the JSP including the <html:form> tag and the modified <html:text> tag
  • The portion of your Action class you say isn't working

  • What I'm most interested in knowing is: Is there a department property in your ActionForm with a corresponding getter and setter? Is your Actionform in session scope? If it isn't, put it in session scope and see if it works. If you still want it in request scope, I can show you how to deal with that later.
    [ February 21, 2007: Message edited by: Merrill Higginson ]
     
    reply
      Bookmark Topic Watch Topic
    • New Topic