我需要gmaps.zul
从另一个 zul 文件 ( ) 中的按钮控制 gmaps (在文件中top.zul
)。这两个文件都包含在root.zul
. 当我按下按钮时,ZK 会显示一条弹出错误消息:“ Name is empty or target is null.
”这是我的代码:
*根.zul *
<?link rel="stylesheet" type="text/css" href="/resources/css/style.css"?>
<zk>
<borderlayout hflex="1" vflex="1">
<north height="100px" border="none" >
<include id="northPanel" src="/top.zul"></include>
</north>
<center id="mainContent" autoscroll="true">
<include src="/gmaps.zul" ></include>
</center>
</borderlayout>
</zk>
* gmaps.zul *
<zk>
<div>
<gmaps id="map" width="500px" height="500px" lat="35" lng="-110" />
</div>
</zk>
** top.zul **
<zk>
<div apply="test.TestComposer">
<button id="btn" label="add marker" />
</div>
</zk>
** TestComposer.java **
public class TestComposer extends GenericForwardComposer {
private Gmaps map;
private double lat = 35;
private double lng = -110;
public void onClick$btn() {
Events.echoEvent("onAddMarker", map, null);
}
public void onAddMarker$map() {
Gmarker marker = new Gmarker();
lat += 0.001;
lng += 0.001;
marker.setLat(lat);
marker.setLng(lng);
marker.setParent(map);
}
}