I am converting a component from JSP to HTL(Sightly). In the existing jsp file we are getting the req paramater using the following code:
request.getAttribute("urlAttr");
Similarily, I want to access the above url request paramater using sighlty tags. Is there any sightly tag to get the current request object and get the request params from that ?
I dont want to use the JAVA USE API for this one. I just want to do it in the html file itself using sightly tags so that I can avoid the server side code.
Thanks.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi
You can use the following:
${request.requestParameterMap['test'][0].toString}
With http://server:port/resource?test=hello, then the output is ‘hello’
OR by using "Class implementing the Use interface" OR " Class extending WCMUsePojo class" OR "Class adaptable from Resource" OR "ling Models"
Source :- http://blogs.adobe.com/experiencedelivers/experience-management/htl-intro-part-4/
~kautuk
Views
Replies
Total Likes
Hi
You can use the following:
${request.requestParameterMap['test'][0].toString}
With http://server:port/resource?test=hello, then the output is ‘hello’
OR by using "Class implementing the Use interface" OR " Class extending WCMUsePojo class" OR "Class adaptable from Resource" OR "ling Models"
Source :- http://blogs.adobe.com/experiencedelivers/experience-management/htl-intro-part-4/
~kautuk
Views
Replies
Total Likes
In your example you have two different things... request attribute and request parameter.
Which one do you want to access in your code?
Views
Replies
Total Likes
Thanks for the suggestion. I will try that.
I am aware of the second approach i.e. java class but I dont want to use that just to get the req params from request object.
Views
Replies
Total Likes
Using Java - you can do a lot of tasks, Think of using a HTL as a component that divides view and model/controller (MVC). The HTML should be a thin as possible and you can use Java to control the model and controller logic. Having said that - for those reading this and want to know how to create a HTL component that uses WCMUsePojo - see:
http://scottsdigitalcommunity.blogspot.com/2016/07/creating-aem-html-template-language.html
There is a 6.1, 6.2 and video included here.
Views
Replies
Total Likes
+ 1 with Scott,
Java Use-API | JavaScript Use-API | |
Pros |
|
|
Cons |
|
|
Source :- https://docs.adobe.com/docs/en/htl/docs/use-api.html
~kautuk
Views
Replies
Total Likes
Views
Likes
Replies