I'm working on a web app making use of Struts 1.1 and JSTL 1.0. One of my tasks is to implement a search form that will display search results. A search result is basically a file stored in a database. These search results have to offer two additional user actions each: a link for downloading the specific file (the search results contain the files DB id) and a user-specific link to delete the file. The search and display logic is more or less done (the search results are put in request in search action). I do have a problem with something I'd call standard behavior at search pages: if a user chooses to delete a file (I intend to offer an action for this) I think it is standard to show the result list afterwards again. This means that I have to re-run the search again and I need access to the search form search values. Right now I do something like this:
This snippet is inside the search form tags, by the way. The problem is that the only value I can access in the appropriate "DeleteAction" is the protocolId, not the search form's values, so I can't re-run the search. The basic problem is the very same if the user hits the download link leading to a download action: when the download action is done the search results are gone. I am very grateful if you can give me tips and hints for this.
By the way, are there special Struts/JSTL tags for downloads?
PS: couldn't check the FAQ because it's under maintenance
[ October 12, 2007: Message edited by: Mike Himstead ]
[ October 12, 2007: Message edited by: Mike Himstead ] [ October 12, 2007: Message edited by: Mike Himstead ]
I have typically stored the form that has the search criteria values in the session. Then when you need to refresh the search page you can pull the form out of the session and rerun the same query. This help out with basic edit flow as well so you can rebuild the search results page after the user edits an item.
posted 12 years ago
thank you very much for your answers. Please allow to let me make additional comments:
- Ajax is no option because of lack of time, my own experience (the lack thereof) and project requirements.
- When you store the search results in the session the page will display search results when the user leaves the page and returns later on. The search form containing the search parameters is stored in request only and outside of the form, so the page would display results without parameters. A solution could be to put the search results inside the form and store the form in the session. So far I hesitated to populate the session with too much data, but I can't name specific reasons apart from a obscure fear of a possible performance bottleneck.
I experimented with three different actions (and Action classes) for searching, deleting and downloading, each class populating the same form. Could it be that one gets a new form instance for every action? After searching the form is completely empty when entering the downloading action.
Any more comments are welcome. [ October 12, 2007: Message edited by: Mike Himstead ]