• 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

Regarding struts buttons

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using struts. I am getting values from database using bean and displaying it in a table. For each row there is a button named edit.
Below that table there are text areas pertaining to 2 columns of the above table.
If edit button is clicked for any row then I want that row data to appear in the textarea and it should be editable.
Please Can anyone suggest me a solution for doing this.
Regards,
Venkatesh.
 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is how I usually do that:

1. Create a "task" property in your form.
2. Create a <html:hidden property="task" value="idOfTheButton"/>
3. Add this js code to the JSP
function setTask (formName, task)
{
formName.task.value = task;
formName.submit();
}
4.The button should submit the page, then in the Action class, after checking if the task property is null or not, set any property you may need.
5. Use a <logic:notEMpty property="task"> in you jsp to show the textarea.
6. You are done.


 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since all you want to do is move text from one area of the form to another, this could be done entirely with JavaScript without submitting the form. Just write a function called by the on click event that:

* finds the data you need in the current row. (hint: you can get the row of the clicked button with this.parentNode.parentNode)
* put this data in a temporary variable
* set the value of the text box to the value of the temporary variable
 
LV Reddy
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Merril,
Thank you very much for the reply. I got ur point I am very poor in javascript. So please can u tell me how to get the individual elements(td element contents) of the row.
Regards,
Venkatesh.
 
LV Reddy
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai Merril,
Thank you very much. I got the contents populated into the required fields.
Regards,
Venkatesh.
 
reply
    Bookmark Topic Watch Topic
  • New Topic