Display data from preloaded list (Spring+JSP)
In a jsp, I have generated a table consisting of records from the database
- trivially, using
<c:forEach var="activity" items="activities" varStatus="loopCounter">
...<td><c:out...
</c:forEach>
This is shown in a modal. When the user selects one from the items and
clicks 'OK', I want the selected item to load it's details in the
description div on the same page.
<dl>
<dt>Title</dt>
<dd>{Title of selected item here}</dd>
....
</dl>
An approach I think of is to get the selected item's id and load it from
the database, then display - although it'll be superfluous, since the
record is already loaded. I am using Spring to return the list.
@RequestMapping(method = RequestMethod.GET)
public String index(Model model){
List<Activity> activities = activityService.listActivities();
model.addAttribute("activities", activities);
return "index";
}
Not all columns are displayed in the modal table, so using javascript to
"set text" from modal to desc div is not a solution (I think).
Any ideas on how can I display the details from the list without
requesting it again from the database?
Or more importantly, is there a better approach in achieving my requirement?
No comments:
Post a Comment