asked
2014-01-29 18:13:09 +0800
robertkaren 77 ● 7 I am new to zk and am having trouble with this.
I have a textbox for a filename with a 'browse' button next to it which will open another window (below).I am having trouble passing the textbox (object or path) to the controller
of the new window. I want it to set value of the original textbox after user selects something from tree in popup window. What is best way to pass it to the 2nd window's controller. I don't want to hardcode a path to the textbox because I want to reuse the popup's controller elsewhere. Thanks for any help!
Button creating new window:
public class SaveFileTabpanelController extends SelectorComposer<Component> {
private Window window;
@Wire
Textbox filenameTextbox;
@Listen ("onClick = #browseBtn")
public void onClickBrowseBtn() {
String template = "browseFolder.zul"
Map<String, Object> args = new HashMap<String, Object>();
args.put("testString", "test string 1");
args.put("textbox", filenameTextbox);
window = (Window)Executions.createComponents(template, null, args);
window.doModal();
}
}
new window zul:
<window id="browseFolderOuterWin" title="Select a folder"
height="500px" width="400px"
apply="com.namsi.eztab.services.BrowseFolderController">
<borderlayout>
<north> <label id="testLbl" value="123"/>
</north>
<center border="0">
<tree id="foldersTree" style="height:18px;"
width="100%" vflex="true">
<treecols sizable="true">
<treecol width="100%"/>
</treecols>
<treechildren>
<treeitem>
<treerow>
<treecell label="${arg.testString}" >
<attribute name="onDoubleClick">
testLbl.setValue(self.getLabel() + "rk");
</attribute>
</treecell>
</treerow>
</treeitem>
<treeitem>
<treerow>
<treecell label="dir 2"/>
</treerow>
</treeitem>
</treechildren>
</tree>
</center>
<south border="0">
<hbox width="100%" pack="center">
<button id="closeBtn" label="Close" />
</hbox>
</south>
</borderlayout>
</window>
controller of new window:
public class BrowseFolderController extends SelectorComposer<Component> {
private Window window;
String testString2 = null;
@Wire
Window browseFolderOuterWin;
@Listen ("onClick = #closeBtn")
public void onClickCloseBtn() {
System.out.println(this + " detaching, testString2 = " + testString2);
browseFolderOuterWin.detach();
}