0
main.zul

    ...@init('Main')...
        <zk>
        ...
           <include src="north.zul"/>
           <include src="@bind(vm.pageSource)"/>
        ...
        <zk>

north.zul
    ...@init('North')...
        <zk>
        ...
           <a onClick="@command('linkClicked')">link</a>
        ...
        <zk>

Main.java
...
private String pageSource = "content1.zul"
//getter setter of PageSource

North.java
...
@command
public void linkClicked(){
   // access main object and call main.setPageSource("content2.zul") (how to do this ?)
}


Now if a http request come for main.zul then instance of Main and North will be created and is there anyway i can access Main object ?

Is there any thing like ZKcontext , where i can ask for session scope instances ?

4

1 回答 1

1

You should post a global command from your onClick event in north.zul:

onClick="@global-command('switchContent', file='content2.zul')"

In your Main.java you listen for this global command:

@GlobalCommand
@NotifyChange("pageSource")
public void switchContent(@BindingParam("file") String file) {
  setPageSource(file);
}
于 2013-10-18T13:30:39.323 回答