aspose file tools*
The moose likes Struts and the fly likes Regarding struts buttons Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Regarding struts buttons" Watch "Regarding struts buttons" New topic
Author

Regarding struts buttons

LV Reddy
Greenhorn

Joined: Mar 20, 2006
Posts: 13
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.
Oscar Gonzalez
Ranch Hand

Joined: Mar 28, 2006
Posts: 63
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.


Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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


Merrill
Consultant, Sima Solutions
LV Reddy
Greenhorn

Joined: Mar 20, 2006
Posts: 13
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

Joined: Mar 20, 2006
Posts: 13
Hai Merril,
Thank you very much. I got the contents populated into the required fields.
Regards,
Venkatesh.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regarding struts buttons