Friday 1 July 2016

Get Children of Children in Liferay structures and templates

Children Levels(3 levels)



Sample Structure:

<?xml version="1.0"?>

<root>
<dynamic-element name="level1" type="text" index-type="keyword" repeatable="true">
<dynamic-element name="level2" type="text" index-type="" repeatable="true">
<dynamic-element name="level3" type="text" index-type="" repeatable="false"/>
</dynamic-element>
</dynamic-element>
</root>

Template:


#foreach($i in $level1.getSiblings())
#foreach($j in $i.level2.getSiblings())
#foreach($k in $j.level3.getSiblings())
<p>$i.data</p>
<p>$j.data</p>
<p>$k.data</p>
#end
#end
#end

 Example:

output will display based on your input values.
For Example If input is
 level1: Karthik 
 level2: Reddy 
 level3: M

Output in Webcontent Display:
Karthik
Reddy
M

Key Point : In liferay service builder if there is no primary key it will throw java.lang.RuntimeException there is no primary key for entity EntityName