0

How to control object in multiple zul files

asked 2013-10-17 13:26:47 +0800

alexonline84 gravatar image alexonline84
1

I need to control a gmaps (in gmaps.zul file) from a button in another zul file (top.zul).

Both files are included in root.zul.

When I push my button ZK show me a popup error message: "Name is empty or target is null."

Here's my code:

* root.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);
    }
}

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-11-27 04:40:31 +0800

vincentjian gravatar image vincentjian
2245 6

Hi, you can use EventQueue, please refer to this document.

link publish delete flag offensive edit
Your answer
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
1 follower

RSS

Stats

Asked: 2013-10-17 13:26:47 +0800

Seen: 24 times

Last updated: Nov 27 '13

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