Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

How Can I retrieve request parameter in sightly

Avatar

Level 3

User enter search parameter on the web page. I want to pass on that request parameter to back end java class.

How can I do that?

Example:

test-sightly.html?q=market&maxrows=25

Java class SearchHelper

 

Can someone give example?

Thanks

Venkat

1 Accepted Solution

Avatar

Correct answer by
Level 10

For those reading this thread and wanting to know more about Sightly - there are 2 good community articles on Sighty - here is one that shows how to use Sightly with Java in back end:

https://helpx.adobe.com/experience-manager/using/creating-sightly-component.html

See this new AEM Community article that uses Java, Slighty and Sling Models to build a component that is able to parse a DOM. 

https://helpx.adobe.com/experience-manager/using/domparser.html

In this example - values that an author enters into a component dialog are passed to the Java back end - such as the URL of the web page to parse. 

In addition to these articles - we have this really good web presentation by Feike: 

https://www.youtube.com/watch?v=QfvFWSQQ_0M

If you want to pass values from a web page (as opposed to a component dialog that an author enters during design time on the Author instance) - I would look at using AJAX to post values to a servlet. Most Sightly components - the values passed to Java are entered into a component dialog. 

View solution in original post

2 Replies

Avatar

Employee Advisor

 I believe your java class extends WCMUse class and you can call getRequest() method to get the request object - https://docs.adobe.com/docs/en/aem/6-0/develop/ref/javadoc/com/adobe/cq/sightly/WCMUse.html#getReque...()

Avatar

Correct answer by
Level 10

For those reading this thread and wanting to know more about Sightly - there are 2 good community articles on Sighty - here is one that shows how to use Sightly with Java in back end:

https://helpx.adobe.com/experience-manager/using/creating-sightly-component.html

See this new AEM Community article that uses Java, Slighty and Sling Models to build a component that is able to parse a DOM. 

https://helpx.adobe.com/experience-manager/using/domparser.html

In this example - values that an author enters into a component dialog are passed to the Java back end - such as the URL of the web page to parse. 

In addition to these articles - we have this really good web presentation by Feike: 

https://www.youtube.com/watch?v=QfvFWSQQ_0M

If you want to pass values from a web page (as opposed to a component dialog that an author enters during design time on the Author instance) - I would look at using AJAX to post values to a servlet. Most Sightly components - the values passed to Java are entered into a component dialog.