0

How to craete child nodes in ZUL file

asked 2009-10-12 11:22:12 +0800

cros gravatar image cros
153

I have a ZUL file in which I have follwoing code-----

redraw = { page ->

def c1=ClientMap.executeQuery("select name from ClientMap where nodeType='0'")

def random = new java.util.Random(System.currentTimeMillis());
def r1 = new java.util.Random(random.nextInt())

treeClient.clear()
childChildren.append{
c1.each { e ->
treeitem(value:r1.nextInt(c1.size())){
treerow{
treecell(label: e.toString()){
}
}// treerow

if (e.toString()=="HOSPITAL"){
def c2=ClientMap.executeQuery("select name from ClientMap where nodeType='1'")
childChildren.append{
c2.each { f ->
treeitem(value:r1.nextInt(c2.size())){
treerow{
treecell(label: f.toString())
}
}
}
}
}//if ends HOSP


if (e.toString()=="CLINIC"){
def c3=ClientMap.executeQuery("select name from ClientMap where nodeType='2'")
childChildren.append{
c3.each { f ->
treeitem(value:r1.nextInt(c3.size())){
treerow{
treecell(label: f.toString())
}
}
}
}
}//if ends CLINIC

if (e.toString()=="LAB"){
def c4=ClientMap.executeQuery("select name from ClientMap where nodeType='3'")
childChildren.append{
c4.each { f ->
treeitem(value:r1.nextInt(c4.size())){
treerow{
treecell(label: f.toString())
}
}
}
}
}//if ends CLINIC


}//treeitem c1 for
}//c1.each

}// end of childappend

}
==========================================
The BootStrap.groovy has following code===

def Client1 = new ClientMap(name:'HOSPITAL',nodeType:'0').save()
def Client2 = new ClientMap(name:'CLINIC',nodeType:'0').save()
def Client3 = new ClientMap(name:'LAB',nodeType:'0').save()
def Client4 = new ClientMap(name:'HOSPITAL1',nodeType:'1').save()
def Client5 = new ClientMap(name:'HOSPITAL2',nodeType:'1').save()
def Client6 = new ClientMap(name:'CLINIC1',nodeType:'2').save()
def Client7 = new ClientMap(name:'CLINIC2',nodeType:'2').save()
def Client8 = new ClientMap(name:'LAB1',nodeType:'3').save()
def Client9 = new ClientMap(name:'LAB2',nodeType:'3').save()

==========================================================
and ClientMap.groovy file has following code --------

class ClientMap {

String name
Integer nodeType

static constraints = {
name(blank: false)
nodeType(blank: false)

}
}
=====================================================================

I get treee structure as follows===

Hospital
Hospital1
Hospital2
Clinic
Clinic1
Clinic2
Lab
Lab1
Lab2

How can make "HOSPITAL1" child of HOSPITAL and "HOSPITAL2" child of HOSPITAL1 and so on..
To make the above tree look like ==

Hospital
  - Hospital1
      -Hospital2
Clinic
  - Clinic1
      -Clinic2
Lab
  -Lab1
      -Lab2

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2009-10-12 11:48:17 +0800

cros gravatar image cros
153

PLs help guys !!! ...I need to create a child nodes

link publish delete flag offensive edit

answered 2009-10-14 05:07:21 +0800

cros gravatar image cros
153

PLs help guys !!! ...

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-10-12 11:22:12 +0800

Seen: 126 times

Last updated: Oct 14 '09

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More