title: Adobe Experience Manager - How can we get currentPage url into Datasource
body: <p>Below is datasource.jsp for adding dynamic dropdown into my customComponent dialog, I'm using this datasource in my customComponent as below mentioned  field.
  Here my requirement is need to get url values to dropdown when my customComponent used in any page(this page having urls). So here i need that currentPage url where i have used my customComponent.</p>
  
  <p>Please help me to get that page url where i have used my customComponent to this datasource.</p>
  
  <pre><code>&lt;%
  request.setAttribute(DataSource.class.getName(), EmptyDataSource.instance()); 
  ResourceResolver resolver = resource.getResourceResolver();
  //Create an ArrayList to hold data
  List&lt;Resource&gt; fakeResourceList = new ArrayList&lt;Resource&gt;();
  ValueMap vm = null;
  Resource childResource = resourceResolver.getResource(currentPage.getPath()+"/jcr:content/node/path");
  if(childResource!=null){
      Node childNode = childResource.adaptTo(Node.class);
      Node childLinks = childNode.getNode("childnode");
       if(childLinks!=null){    
      NodeIterator childrenNodes = childLinks.getNodes();
            while(childrenNodes.hasNext()) {
               vm = new ValueMapDecorator(new HashMap&lt;String, Object&gt;());
               Node next = childrenNodes.nextNode();
               String label = next.getProperty("label").getValue().getString();
               String path = next.getProperty("url").getValue().getString();
               vm.put("text",label);
               vm.put("value",path.substring(1));       
               fakeResourceList.add(new ValueMapResource(resolver, new ResourceMetadata(), "nt:unstructured", vm)); 
           }
     }
  } else {
      vm = new ValueMapDecorator(new HashMap&lt;String, Object&gt;());
      vm.put("text","NoValue");
      vm.put("value","");
      fakeResourceList.add(new ValueMapResource(resolver, new ResourceMetadata(), "nt:unstructured", vm));
  }
  DataSource ds = new SimpleDataSource(fakeResourceList.iterator());
  request.setAttribute(DataSource.class.getName(), ds);
  %&gt;
  </code></pre>
  
  <p>In my customComponent dialog content.xml which is using above datasource as it's sling:resourceType.</p>
  
  <pre><code>&lt;dataSourceTest
       jcr:primaryType="nt:unstructured"
       sling:resourceType="granite/ui/components/foundation/form/select"
       fieldDescription="Provide ID"
       fieldLabel="Anchor"
       name="./datasourceTest"&gt;
       &lt;datasource
            jcr:primaryType="nt:unstructured"
            sling:resourceType="/apps/mysite/components/page/datasource"/&gt;
  &lt;/dataSourceTest&gt;
  </code></pre>