I have a search form with following fields
price, status, owner
When user fill all the fields, the request will be sent to the back-end to show a list of categories that have products with the specified price, status and owner. User is able to click on each category to see the list of its products.
To implement it, I have following method to retrieve the categories, and put the search fields (price,status,owner) into session to be available in next page of the search ( when a category is selected).
The value of the parameters might be so long, and I prefer to have them as GET to be easy to bookmark the results.
public String retrieveCategories(){
//... here I retrieve categories which their products are matched
//with the search fields
Map session = ActionContext.getContext().getSession();
session.put("Items", this.items);
return "SUCCESS";
}
Once all categories are shown user is able to click on each to see their products. The name of category will be send to backend, so I will retrieve the values from session to search for products with the same specifications for the selected category.
public String retrieveProductsOfSelectedCategory(){
Map session = ActionContext.getContext().getSession();
this.items = (Items) session.get("Items");
//... here I retrieve products of the selected category based on values retrieved
// from session
}
I am wondering if it is a good practice to implement it if not whats your suggestion?