how to get the url query string paramters value | Community
Skip to main content
Level 2
Mar 2, 2021 6:23 AM UTC
Solved

how to get the url query string paramters value

Hi team,

 

I have a requirement where in we should not load the launch based on the <xxx> = true parameter value.

 

 we are loading launch as below :

<sly data-sly-call="${headlibRenderer.headlibs @
designPath = page.designPath,
staticDesignPath = page.staticDesignPath,
clientLibCategories = page.clientLibCategories,
clientLibCategoriesJsHead = page.clientLibCategoriesJsHead,
hasCloudconfigSupport = page.hasCloudconfigSupport}"></sly>
 
 
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Anudeep_Garnepudi
Anudeep_GarnepudiAccepted solution
New Participant
Mar 2, 2021 2:02 PM UTC

@niks1  

Below implementation working for me as expected.

Sling Model:

 

 

@Model(adaptables = {Resource.class, SlingHttpServletRequest.class}) public class DemoModel { @SlingObject SlingHttpServletRequest request; private String launchEnabled = "false"; public String getLaunchEnabled() { if (request.getParameter("launchDisabled") == null || request.getParameter("launchDisabled").equalsIgnoreCase("false")) launchEnabled = "true"; return launchEnabled; } }

 

 

HTL:

 

 

<div data-sly-use.demo="com.blogspot.adapttoaem.core.models.DemoModel"> <sly data-sly-test="${demo.launchEnabled == 'true'}"> <p>Launch Enabled</p> </sly> </div>

 

 

 

 

21 replies

niks1Author
Level 2
Mar 3, 2021 1:28 PM UTC
@anudeep_garnepudi - I tried as suggested but it is still working . public boolean getlaunchEnabled() { return !(Boolean.parseBoolean(request.getParameter("launchDisabled"))) ; }//?????
Translate
Employee
Mar 2, 2021 2:19 PM UTC
niks1Author
Level 2
Mar 2, 2021 3:35 PM UTC
@user05162 we are on AEM 6.4 and using PageModel .. got the Parameter value but still in data-sly-test it not working
Translate
Anudeep_Garnepudi
Anudeep_GarnepudiAccepted solution
New Participant
Mar 2, 2021 2:02 PM UTC

@niks1  

Below implementation working for me as expected.

Sling Model:

 

 

@Model(adaptables = {Resource.class, SlingHttpServletRequest.class}) public class DemoModel { @SlingObject SlingHttpServletRequest request; private String launchEnabled = "false"; public String getLaunchEnabled() { if (request.getParameter("launchDisabled") == null || request.getParameter("launchDisabled").equalsIgnoreCase("false")) launchEnabled = "true"; return launchEnabled; } }

 

 

HTL:

 

 

<div data-sly-use.demo="com.blogspot.adapttoaem.core.models.DemoModel"> <sly data-sly-test="${demo.launchEnabled == 'true'}"> <p>Launch Enabled</p> </sly> </div>

 

 

 

 

Translate
niks1Author
Level 2
Mar 2, 2021 2:14 PM UTC

Thanks @12365029_Garenepudi 

Yes we have Page model and i was trying to do this via :


public String getlaunchEnabled() {
 
if((request.getParameter("launchDisabled")).equalsIgnoreCase("true")) {
return launchEnabled;
}
launchEnabled = "true";
return launchEnabled;
}
and in htl 

<sly data-sly.test.launchEnabled="${pageTrail.launchEnabled @context='unsafe'}" data-sly-call="${headlibRenderer.headlibs @
designPath = page.designPath,
staticDesignPath = page.staticDesignPath,
clientLibCategories = page.clientLibCategories,
clientLibCategoriesJsHead = page.clientLibCategoriesJsHead,
hasCloudconfigSupport = page.hasCloudconfigSupport}"></sly>
but some how it's not working
Also , if that value is true we should not load that file else load it . Do we have any ! function in data-sly-test
Translate