I am looking for solution where I can include search bar component of AEM and call my custom search API. How can I pass the value entered in search bar to the API?
Is there a property that holds the value entered can be passed on? The API results will be shown on another component say main component. So, there are two components search and main in one page. Is this doable?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
you can create a sling servlet. When user click on button sling servlet will be called and you get can pass property as a selector or query string to servlet and call your API from servlet and once get result parse and send it back to UI.
Views
Replies
Total Likes
Have you attempted to create a custom Search component in AEM?
Views
Replies
Total Likes
Yes I have tried creating custom search component, now I want to pass the value entered in the search bar to my API.
On another note by following Creating an Adobe Experience Manager 6.4 HTL Component that displays data from a Restful Web Service I have created a page which consist of a property named "Search Property", this is basically a node any value entered in this property calls the API and gets the result, on similar lines I don't want to configure a property but instead a search bar component which calls the API with the text entered and brings the result back.
In my code I have used
Node currentNode = getResource().adaptTo(Node.class);
String searchParameter = currentNode.getProperty("searchquery").getString();
searchParameter contains current value that is entered in the search property and is passed on to the API.
And back on component I have to create a node and map the name property of the node with the attribute of the object. So is there a way to get the property of the search textbox and on submit will call the custom API.
Views
Replies
Total Likes
Hi,
when you want to call your custome API when dialog is submit or when user enter text in search text box and click on submit on your publish site.
what you want to map with search field? You want to keep search parameter content managable and getting from dialog.
Could you please explain more, it is confusing for me?
Thanks
Arun
Views
Replies
Total Likes
I need to call my API when user enter text in text box and click on submit button.
In the previous example, the below code is in my java class and it fetches the text from the dialog box and stores in 'searchParameter' which I pass in my API.
Node currentNode = getResource().adaptTo(Node.class);
String searchParameter = currentNode.getProperty("searchquery").getString();
Similarly, I need to a handle for the search text box to include in my java class.
Let me know if more explanation is required.
Views
Replies
Total Likes
Hi,
you can create a sling servlet. When user click on button sling servlet will be called and you get can pass property as a selector or query string to servlet and call your API from servlet and once get result parse and send it back to UI.
Views
Replies
Total Likes
Thanks arunp99088702 I will try to create a sling servlet and will post my findings after I develop the same.
Views
Replies
Total Likes
YEs - in our Rest/HTL example - we set the input values from a dialog - that is passed to the Java and the Java invokes a Google Service using HTTP call. The results are displayed in the HTL.
Now if you want to invoke a HTTP Restful service from a component - Arun is correct- you need to invoke a Sling Servlet and pass parameter values.
Views
Replies
Total Likes
Thanks Arun and smacdonald2008, the POC I was working on is completed.
Created a sling servlet and called the APIs from there and sent back the response to the UI.
Views
Replies
Total Likes
Views
Likes
Replies