Java Sencha GXT XTemplate tpl用于内部tpl
我正在尝试使用GXT 3.0的XTemplates(类似于EXT),这里有两个简单的java对象,它们具有以下关系:Java Sencha GXT XTemplate tpl用于内部tpl,java,templates,for-loop,extjs,gxt,Java,Templates,For Loop,Extjs,Gxt,我正在尝试使用GXT 3.0的XTemplates(类似于EXT),这里有两个简单的java对象,它们具有以下关系: class A { String name; public String getName() { return name; } } class B { String name; public String getValue(A a) { return a.getName(); } } 我想为以下模板应用带有2个
class A {
String name;
public String getName() {
return name;
}
}
class B {
String name;
public String getValue(A a) {
return a.getName();
}
}
我想为以下模板应用带有2个参数(列表>列表,列表>bList)的XTemplate:
<tpl for="aList">
<tpl for="bList">
////// Questions? How to call function B.getValue(A) ???
///// this does not work for me: {this.getValue(parent)}
</tpl>
</tpl>
//////有问题吗?如何调用函数B.getValue(A)???
/////这对我不起作用:{this.getValue(父项)}
有任何机构熟悉这种请求吗?
谢谢。有一个特殊的命名对象可以帮助您处理这个名为
父对象的问题-它访问外部作用域
<tpl for="aList">
<tpl for="bList">
Name of inner item, i.e. b.getName() is {name} <br />
Name of outer item, i.e. a.getName() is {parent.name}
</tpl>
</tpl>
内部项的名称,即b.getName()是{Name}
外部项的名称,即a.getName()为{parent.Name}
如果有第三个循环,您可以将调用链接到parent以进一步退出-parent.parent.name
如果A有一个getPhone()
方法,而B没有,那么parent
是可选的,因为显然您不能引用不存在的B.getPhone()
同样的原则也适用于这样的情况,即每个孩子的详细信息与家长的详细信息一起打印。查看template.html
文件的源代码,了解在这种情况下如何使用parent