How to populate the fields of JSP with the Searched Record
posted 2 years ago
I'm building a project using Struts2 framework, and I'm stuck in a place where I trying to search the record from database, and want that searched record to get populated in the jsp textfield.
http://tinypic.com/view.php?pic=2pqlyu1&s=8#.U49udHI2Lw8. In this image as user enters the primary key and clicks the search button, the desired record should get displayed. Please tell me how should I achieve this.
I'm successfully able to retrieve the record from database using Action Class, but don't know how to transfer that record back to the JSP.
Is reloading the page OK? If so, you'd just populate your action with values for the fields (or a bean for the values) from the database and return a value (usually "success") that corresponds to the action in struts.xml.
If you don't want to reload the page, you would need AJAX to accomplish the same.