trouble accessing child nodes with .getItem | Community
Skip to main content
Level 3
Aug 20, 2018 2:27 PM UTC
Solved

trouble accessing child nodes with .getItem

hi,

as yo can see below i am getting back this data using .getItem().

everything is there but i cant seem to select the child nodes.

20.08 .2018 15: 19: 22.609 * INFO * [0: 0: 0: 0: 0: 0: 0: 1[1534774762547] GET / content / intranet / Hub.html HTTP / 1.1] apps.intranet.components.structure.mega - menu.mega - menu$html karl: com.adobe.granite.confmgr.impl.ConfImpl$ResourceNamedValueMap @192b2fbf: JcrPropertyMap[node = Node[NodeDelegate {

tree = /conf/intranet / settings / megamenu / services / jcr: content: {

jcr: primaryType = cq: PageContent,

jcr: createdBy = admin,

jcr: title = Services,

cq: lastReplicationAction = Activate,

cq: lastReplicatedBy = admin,

jcr: created = 2018 - 05 - 16 T15: 58: 06.629 + 01: 00,

cq: lastReplicated = 2017 - 03 - 01 T09: 33: 23.777 Z,

benefits = { ...

},

jobs - volunterring = { ...

},

business = { ...

},

licensing = { ...

},

your - city - council = { ...

}

}

}], values = {

jcr: primaryType = cq: PageContent,

jcr: createdBy = admin,

jcr: title = Services,

cq: lastReplicationAction = Activate,

cq: lastReplicatedBy = admin,

jcr: created = java.util.GregorianCalendar[time = 1526482686629, areFieldsSet = true, areAllFieldsSet = true, lenient = false, zone = sun.util.calendar.ZoneInfo[id = "GMT+01:00", offset = 3600000, dstSavings = 0, useDaylight = false, transitions = 0, lastRule = null], firstDayOfWeek = 2, minimalDaysInFirstWeek = 4, ERA = 1, YEAR = 2018, MONTH = 4, WEEK_OF_YEAR = 20, WEEK_OF_MONTH = 3, DAY_OF_MONTH = 16, DAY_OF_YEAR = 136, DAY_OF_WEEK = 4, DAY_OF_WEEK_IN_MONTH = 3, AM_PM = 1, HOUR = 3, HOUR_OF_DAY = 15, MINUTE = 58, SECOND = 6, MILLISECOND = 629, ZONE_OFFSET = 3600000, DST_OFFSET = 0],

cq: lastReplicated = java.util.GregorianCalendar[time = 1488360803777, areFieldsSet = true, areAllFieldsSet = true, lenient = false, zone = sun.util.calendar.ZoneInfo[id = "GMT", offset = 0, dstSavings = 0, useDaylight = false, transitions = 0, lastRule = null], firstDayOfWeek = 2, minimalDaysInFirstWeek = 4, ERA = 1, YEAR = 2017, MONTH = 2, WEEK_OF_YEAR = 9, WEEK_OF_MONTH = 1, DAY_OF_MONTH = 1, DAY_OF_YEAR = 60, DAY_OF_WEEK = 4, DAY_OF_WEEK_IN_MONTH = 1, AM_PM = 0, HOUR = 9, HOUR_OF_DAY = 9, MINUTE = 33, SECOND = 23, MILLISECOND = 777, ZONE_OFFSET = 0, DST_OFFSET = 0]

}]

any idea how to access them?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
arunpatidar
arunpatidarAccepted solution
New Participant
Aug 20, 2018 3:34 PM UTC

Hi,

If you copy paste, this is not gonna work with JS, you need to convert this into JS USE API syntax.

http://aempodcast.com/2015/javascript/understanding-javascript-use-api-aem/#.W3rfP2aB3q1

Arun Patidar

7 replies

smacdonald2008
Level 10
Aug 20, 2018 6:42 PM UTC

Here is another AEM 6.3 article that shows you how to work with HTL and JS USE API -- Creating a Tab layout component for Adobe Experience Manager

Translate
arunpatidar
arunpatidarAccepted solution
New Participant
Aug 20, 2018 3:34 PM UTC

Hi,

If you copy paste, this is not gonna work with JS, you need to convert this into JS USE API syntax.

http://aempodcast.com/2015/javascript/understanding-javascript-use-api-aem/#.W3rfP2aB3q1

Translate
Arun Patidar
smacdonald2008
Level 10
Aug 20, 2018 3:14 PM UTC

Are you using JS USE API to work with a HTL component?

Translate
Level 3
Aug 20, 2018 3:07 PM UTC

that doesnt work if i just copy and past that into my javascript. is there something else i need to do to get the java working in javascript?

Translate
arunpatidar
New Participant
Aug 20, 2018 3:03 PM UTC

You can loop through to get desire property like

ValueMap property = getResource.adaptTo(ValueMap.class);
for(Entry<String, Object> e : property.entrySet()) {
  
String key = e.getKey();
  
Object value = e.getValue();
  
//use the key and value here
}

No JS USE API is a way to write java inside JS, so won't be a problem.

Translate
Arun Patidar
Level 3
Aug 20, 2018 2:58 PM UTC

i cant use that because i wont always know the names of the nodes.

i am using javascript by the way so would this cause any problems?

Translate
arunpatidar
New Participant
Aug 20, 2018 2:42 PM UTC

Hi,

getItem() returns ValueMap, you can read values from value map like

  dbUserName = valueMapObj.get("dbUser", "No UserId found");

 

ValueMap ("The Adobe AEM Quickstart and Web Application.")

Translate
Arun Patidar