how to get the url query string paramters value | Community
Skip to main content
Level 2
March 2, 2021
Solved

how to get the url query string paramters value

  • March 2, 2021
  • 3 replies
  • 6558 views

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.
Best answer by Anudeep_Garnepudi

@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>

 

 

 

 

3 replies

Anudeep_Garnepudi
Community Advisor
Anudeep_GarnepudiCommunity AdvisorAccepted solution
Community Advisor
March 2, 2021

@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>

 

 

 

 

niks1Author
Level 2
March 2, 2021

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
Adobe Employee
March 2, 2021
niks1Author
Level 2
March 2, 2021
@user05162 we are on AEM 6.4 and using PageModel .. got the Parameter value but still in data-sly-test it not working
niks1Author
Level 2
March 3, 2021
@anudeep_garnepudi - I tried as suggested but it is still working . public boolean getlaunchEnabled() { return !(Boolean.parseBoolean(request.getParameter("launchDisabled"))) ; }//?????