Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

How to pass hash value from URL to java via sightly?

sundarig9086821
Level 3
Level 3

Hi,

Can we pass hash value from JS (window.location.hash) to model via HTL code.

1 Accepted Solution
Gaurav-Behl
Correct answer by
Community Advisor
Community Advisor

I believe when you adapt the Model from SlingHttpServletRequest, it should be available from your request. If not, then you may retrieve it in js/jquery/any other framework/lib and then pass it to server via ajax/form post/hidden param etc. based on your use case.

View solution in original post

4 Replies
Gaurav-Behl
Correct answer by
Community Advisor
Community Advisor

I believe when you adapt the Model from SlingHttpServletRequest, it should be available from your request. If not, then you may retrieve it in js/jquery/any other framework/lib and then pass it to server via ajax/form post/hidden param etc. based on your use case.

View solution in original post

smacdonald2008
Level 10
Level 10

As Gaurav suggests - try to pass to a Java AEM service using AJAX. TYpically values are passed to HTL Java via component dialogs. However - this value cannot be passed in this manner.

smacdonald2008
Level 10
Level 10

Or a possible solution here is to build a custom sling resource type - which is based on JavaScript anyhow. THen you can get this value via the custom type and pass as part of the component dialog.