Skip to main content
Level 9
fev. 16, 2016 4:56 PM UTC
Respondido

Fetch Data into dropdown field via servlet and display on page.

Hi All,

Details as below :

1] The repository structure is as below 

/etc
  /x
    /y
      /First
            /sfghfh
            /fhfghf and so on.
      /Second 
            /sgngg
            /dfgoe and so on.
      /Third
           /egkeg
           /sddgg and so on.

2] I need to retrieve nodes at the level , where[First,Second, Third] are present and return these in a drop down on the page.

3] Trying to make use of a servlet here.

Any thoughts/pointers on this will be helpful.

Este tópico foi fechado para respostas.
Lokesh_Shivalingaiah
Level 10
fev. 16, 2016 7:45 PM UTC

Use Resource API instead of Node API to get the child nodes only.

9 Respostas

edubey
Level 10
fev. 16, 2016 5:05 PM UTC

In simple terms form JSON data in servlet and return it to your widget

here are article showing this:

https://helpx.adobe.com/experience-manager/using/dialog_fields_servlets.html

http://www.tothenew.com/blog/aem-ways-to-populate-a-selection-widget/

Traduzir
edubey
Level 10
fev. 16, 2016 5:07 PM UTC
askdctmAutor
Level 9
fev. 16, 2016 6:07 PM UTC

Hi All,

I tried using the below :

Resource resource = request.getResourceResolver().getResource("/etc/x/y/");
            Node node = resource.adaptTo(Node.class);
            NodeIterator nodeIterator = node.getNodes();
            while(nodeIterator.hasNext()){
                List.add(nodeIterator.toString());
            }

1] Looks like node.getNodes() is getting me the entire nodes udner /etc and not just nodes at level where "First", "Second", "Third".

2] "node" is getting me "/etc/x/y/"

3] Any thoughts on how to get nodes at this level , will be helpful.

Traduzir
edubey
Level 10
fev. 16, 2016 6:14 PM UTC

are  "First", "Second", "Third" the only child node of 'y' ?

Traduzir
askdctmAutor
Level 9
fev. 16, 2016 6:21 PM UTC

Hi Praveen,

Currently, there are only three. But it might increase/decrease by couple of numbers. Basically, they are dynamic and not fixed.

Traduzir
edubey
Level 10
fev. 16, 2016 6:30 PM UTC

okay

are you saying even though you are giving "/etc/x/y/" path in line 1

its giving you entire nodes under /etc?

Traduzir
askdctmAutor
Level 9
fev. 16, 2016 6:36 PM UTC

Hi Praveen,

Sorry, probably I was not very clear.

1] I mean looks like it is reading all nodes under /etc/x/y/ and not just "FIrst","Second","Third" which are direct children of /etc/x/y.

Traduzir
askdctmAutor
Level 9
fev. 16, 2016 6:59 PM UTC

Hi All,

https://saraindia.wordpress.com/2014/06/04/list-pages-and-properties-in-cq5/ seems to be giving the requried results. Will post back after further testing.

Traduzir
Lokesh_Shivalingaiah
Level 10
fev. 16, 2016 7:45 PM UTC

Use Resource API instead of Node API to get the child nodes only.

Traduzir