Hi All
I am trying to create a basic search component.
It is meant to take a text input from the user and on button click submit that input. It then will display the results returned.
The component as it stands looks like this:
<p>General Search Component - Mach 12</p> <div> <form> Search: <input type="search" id="searchText" name="searchText" value="THIS IS THE SEARCH TERM"><button id="searchButton">Search</button> </form> </div> <div data-sly-use.searchResults ="${'someclasspath.core.search.SearchComponent' @ searchInput= 'I NEED THE SEARCH TERM HERE' }" data-sly-unwrap> <div class="container-fluid"> <div data-sly-list.rows = "${searchResults.searchResults}" data-sly-unwrap> <div data-sly-list.cols = "${rows}" data-sly-unwrap> <div class="col-md-3"> <div class="result"> <div>${cols.resultDate}</div> <a href="${cols.linkUrl}">${cols.title}</a> <div>${cols.description}</div> </div> </div> </div> </div> </div> </div>
How do I get the value from the input box passed to the Java Class?
Solved! Go to Solution.
Views
Replies
Total Likes
Use Sightly and JavaScript to perform AJAX call. We do not have this exact use case yet (we may write it) - however - we have Sightly and JavaScript. You would need to use JavaScript AJAX call to pass the form input to a Sling Servlet that can process the input and return a result set. Here is the SIghtly and JavaScipt.
https://helpx.adobe.com/experience-manager/using/htl_js.html
it would be similar to this - but instead of a JSP - you use Sightly front end.
http://scottsdigitalcommunity.blogspot.ca/2013/06/posting-form-data-to-adobe-cq-using.html
PS - new name for Sightly is HTL.
Views
Replies
Total Likes
Hi Mahen,
You tell your form where to submit input to via the action attribute in the form element.
In Java you create a Servlet that listens on the action and reads your input.
Regards,
Peter
Views
Replies
Total Likes
Thanks Peter!
Is there a tutorial or example you can point me to that would take me through the process?
Regards
Mahen
Views
Replies
Total Likes
Use Sightly and JavaScript to perform AJAX call. We do not have this exact use case yet (we may write it) - however - we have Sightly and JavaScript. You would need to use JavaScript AJAX call to pass the form input to a Sling Servlet that can process the input and return a result set. Here is the SIghtly and JavaScipt.
https://helpx.adobe.com/experience-manager/using/htl_js.html
it would be similar to this - but instead of a JSP - you use Sightly front end.
http://scottsdigitalcommunity.blogspot.ca/2013/06/posting-form-data-to-adobe-cq-using.html
PS - new name for Sightly is HTL.
Views
Replies
Total Likes
Thanks Scott :)
I will try these today, thanks for pointing me in the right direction.
Mahen
Views
Replies
Total Likes
Views
Likes
Replies