Emulating requestScope Variables In Sightly For AEM

For one of our clients, that we are doing an AEM implementation for, we have certain pages that we get from a feed and stick in the jcr under each page. The pages have a bunch of components inside.

-page
-jcr:content
-course-data
-authors
-some-guy
[name = Some Guy]
[etc]
-someone-else
[name = ]
[etc]

We need to prep some of the data by putting it into collections that are easy to spin through and hold them in a bean. But we have to pass that data to components on the page. We don’t want to make the bean a bunch of times.

In JSTL you can easily change the scope of variables:

which is good for passing stuff between JSPS.
Sightly does not have an easy way to do this, so I made one.

Course.java – Use API class that sets up the bean:

course-page.html – top level call to the bean Use API

author-component.html – some sub component on the page

RequestUtil.java – util to get attrbutes out of the request

Here are some additional resources from Stack Overflow if you are interested.
http://stackoverflow.com/questions/25404863/aem-6-0-additional-parameters-when-using-data-sly-resource/28177204#28177204
http://stackoverflow.com/questions/25430981/are-there-requestscope-variables-in-sightly