0
votes

I have a search component with searchable fields and result table. It is developed in sightly and used WCMUsePojo class that has search logic. On load of the page,all data has to be displayed and on click of search button - data corresponding to search criteria has to be displayed. I added form element to my sightly html page and action="get". So on click of search button, page is refreshed and data corresponding to search criteria is displayed. However,search criteria input parameters are added as query strings to the URL which looks like bad design.(long url having querystring params in it) I also tried to create a servlet to just redirect to same page, but this is also not working. Getting null pointer exception at dispatcher.forward. Could you please suggest an approach to solve this problem.

Thanks in advance

1
This has nothing to do with Sightly, since Sightly is a templating language only. if you are doing a GET how do you get search parameters other than in the url as parameters? I think you should use a POST with data in your payload, but from the description it is hard to suggest a solution...Maybe if you have a servlet that does the search and return a JSON object and then have some JS taking care of the results and display them in the page? How does this approach sound? - Bambara

1 Answers

1
votes

However,search criteria input parameters are added as query strings to the URL which looks like bad design.(long url having querystring params in it)

This isn't bad design, it's how GET requests work.

To properly help you, you'd have to share the code within your servlet. I don't know the constraints you're working with but I'd suggest you perform the search via AJAX. Here's a sample search implementation (it's only a demo, not production ready!)

Search form component: https://github.com/mickleroy/aem-ajax-search/blob/master/content/src/main/content/jcr_root/apps/ajax-search/components/search/search.jsp

Javascript handling the search submission: https://github.com/mickleroy/aem-ajax-search/blob/master/content/src/main/content/jcr_root/apps/ajax-search/components/search/clientlibs/ajaxSearch.js

Servlet serving the results: https://github.com/mickleroy/aem-ajax-search/blob/master/bundle/src/main/java/com/github/mickleroy/servlets/AbstractSearchServlet.java

Hope this helps