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
BedrockMission!

Learn more

View all

Sign in to view all badges

aem 6.2 SlingRequestPathInfo suffix

marioni26732008
Level 2
Level 2

Hello, when i create a page, i create a select (datasource) in the properties. in my datasource, i want recover the path of the page. for example : http://localhost:4502/mnt/overlay/wcm/core/content/sites/createpagewizard.html/content/geometrixx/fr, i want recover  /content/geometrixx/fr.

 

with aem 6.1 , with this code "slingRequest.getRequestPathInfo().getSuffix()", it's ok, but with aem 6.2, it don't ok. i recover le template path :/apps/geometrixx/templates/homepage.

 

how to get the right path, please?

9 Replies
smacdonald2008
Level 10
Level 10

Are you getting an error or exception? 

marioni26732008
Level 2
Level 2

i recover some think with ""slingRequest.getRequestPathInfo().getSuffix()"" but not the good.

i should recover /content/geometrixx/fr. and i recover /apps/geometrixx/templates/homepage

antoniom5495929
Level 7
Level 7

Could you provide us the example code you are using? 

It's an OSGi component? 

marioni26732008
Level 2
Level 2

no, not a OSGI component. just, a property when i create a page

the problem is only the page creation.

Here the property : 

<searchLogic jcr:primaryType="nt:unstructured"          sling:resourceType="granite/ui/components/foundation/form/select"          cq:showOnCreate="{Boolean}true"             renderReadOnly="{Boolean}true"          fieldLabel="page.search.searchLogic"          name="./searchLogic">    <datasource            jcr:primaryType="nt:unstructured"            sling:resourceType="global/components/content/datasource/datasourceSearchLogic"/></searchLogic>

and the begin of the code in datasource is : 

if(StringUtils.isNotEmpty(slingRequest.getRequestPathInfo().getSuffix())){ path = slingRequest.getRequestPathInfo().getSuffix(); }else{ path = slingRequest.getRequestParameter("item").getString() ; }
antoniom5495929
Level 7
Level 7

Try to check this line:

String contentPath = (String) request.getAttribute("granite.ui.form.contentpath");

Let me know what is the output.

marioni26732008
Level 2
Level 2

this is code of the datasource. However, the issue is related to the slingRequest.getRequestPathInfo().getSuffix() which does not return the correct value.

<% %><%@include file="/libs/granite/ui/global.jsp"%><% %><%@page session="false"          import="java.util.Arrays,                java.util.List,com.day.cq.wcm.api.Page, java.util.ArrayList,org.apache.commons.lang.StringUtils, java.util.Locale, java.util.HashMap, java.util.Map, java.util.Collections, org.apache.commons.collections.Transformer, org.apache.commons.collections.iterators.IteratorChain, com.day.cq.search.PredicateGroup, com.day.cq.search.Query, com.day.cq.search.QueryBuilder, org.apache.commons.collections.iterators.TransformIterator, org.apache.sling.api.resource.ResourceMetadata, org.apache.sling.api.resource.ResourceResolver, org.apache.sling.api.wrappers.ValueMapDecorator, com.adobe.granite.ui.components.Config, com.adobe.granite.ui.components.ds.DataSource, com.adobe.granite.ui.components.ds.SimpleDataSource, com.adobe.granite.ui.components.ds.ValueMapResource, com.day.cq.tagging.Tag, javax.jcr.Node, com.day.cq.search.result.Hit, javax.jcr.Session, com.google.common.collect.Lists, java.util.Iterator, com.day.cq.wcm.api.PageManager, lu.etat.ctie.services.search.*, com.day.cq.tagging.TagManager"%><%String path =""; if(StringUtils.isNotEmpty(slingRequest.getRequestPathInfo().getSuffix())){ path = slingRequest.getRequestPathInfo().getSuffix(); }else{ path = slingRequest.getRequestParameter("item").getString() ; } Resource siteConfigResource = resourceResolver.resolve(path); PageManager pageManager = resourceResolver.adaptTo(PageManager.class); String pathPage = pageManager.getContainingPage(siteConfigResource).getPath(); SearchLogicConfigurationService search = (SearchLogicConfigurationService)sling.getService(SearchLogicConfigurationService.class); List<SearchLogicConfigurationFactory> listSearchLogic = search.getListConfigurationFactoryForPath(pathPage); final ResourceResolver resolver = resourceResolver; @SuppressWarnings("unchecked") DataSource ds = new SimpleDataSource(new TransformIterator(listSearchLogic.iterator(), new Transformer() { public Object transform(Object o) { ValueMap vm = new ValueMapDecorator(new HashMap<String, Object>()); try{ SearchLogicConfigurationFactory searchLogic = (SearchLogicConfigurationFactory)o; vm.put("value", searchLogic.getSearchLogic()); vm.put("text", searchLogic.getSearchLogic()); } catch (Exception e) { System.out.println(e.getMessage() ); } return new ValueMapResource(resolver, new ResourceMetadata(), "nt:unstructured", vm); } })); request.setAttribute(DataSource.class.getName(), ds); %>
marioni26732008
Level 2
Level 2

no, in a page. for example :  /apps/geometrixx-outdoors/components/page, in the cq:dialog

antoniom5495929
Level 7
Level 7

I send you a private message in order to have more details.