Created
February 6, 2013 02:52
-
-
Save senthilmuthiah/4719826 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" arg0="childwindow" ?> | |
<?page title="Child Window" contentType="text/html;charset=UTF-8"?> | |
<zk> | |
<window id="childwindow" title="Child Window" border="normal" | |
mode="modal" width="30%" apply="org.com.demo.ChildWindowController"> | |
<label value="Change the first name and Last name and click the button close to return the values"></label> | |
<separator></separator> | |
<label value="First Name"></label> | |
<separator></separator> | |
<textbox id="firstName" value="@{childwindow$ChildWindowController.firstName}"></textbox> | |
<separator></separator> | |
<label value="Last Name"></label> | |
<separator></separator> | |
<textbox id="lastName" | |
value="@{childwindow$ChildWindowController.lastName}"> | |
</textbox> | |
<separator></separator> | |
<separator></separator> | |
<button id="btn" label="Close"></button> | |
</window> | |
</zk> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.com.demo; | |
import java.util.HashMap; | |
import org.zkoss.zk.ui.Component; | |
import org.zkoss.zk.ui.Execution; | |
import org.zkoss.zk.ui.Executions; | |
import org.zkoss.zk.ui.event.Event; | |
import org.zkoss.zk.ui.event.EventQueue; | |
import org.zkoss.zk.ui.event.EventQueues; | |
import org.zkoss.zk.ui.event.Events; | |
import org.zkoss.zk.ui.select.SelectorComposer; | |
import org.zkoss.zk.ui.select.annotation.Listen; | |
import org.zkoss.zk.ui.select.annotation.Wire; | |
import org.zkoss.zul.Button; | |
import org.zkoss.zul.Messagebox; | |
import org.zkoss.zul.Textbox; | |
import org.zkoss.zul.Window; | |
@SuppressWarnings("serial") | |
public class ChildWindowController extends SelectorComposer<Component> { | |
@Wire | |
Button btn; | |
@Wire | |
Window childwindow; | |
private Window parentWindow; | |
private String firstName; | |
private String lastName; | |
public String getFirstName() { | |
return firstName; | |
} | |
public void setFirstName(String firstName) { | |
this.firstName = firstName; | |
} | |
public String getLastName() { | |
return lastName; | |
} | |
public void setLastName(String lastName) { | |
this.lastName = lastName; | |
} | |
public void doAfterCompose(Component comp) throws Exception { | |
super.doAfterCompose(comp); | |
final Execution execution = Executions.getCurrent(); | |
setFirstName((String) execution.getArg().get("firstName")); | |
setLastName((String) execution.getArg().get("lastName")); | |
parentWindow = (Window) execution.getArg().get("parentWindow"); | |
} | |
@Listen("onClick = button#btn") | |
public void changeLabel() { | |
final HashMap<String, Object> map = new HashMap<String, Object>(); | |
map.put("firstName", this.firstName); | |
map.put("lastName", this.lastName); | |
childwindow.detach(); | |
Events.sendEvent(new Event("onSaved", parentWindow)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?page title="Parent Window" contentType="text/html;charset=UTF-8"?> | |
<zk> | |
<window id="parentWindow" title="Parent Window" border="normal" apply="org.com.demo.ParentWindowController"> | |
<label value="First Name"></label> | |
<separator></separator> | |
<textbox id="firstName"></textbox> | |
<separator></separator> | |
<label value="Last Name"></label> | |
<separator></separator> | |
<textbox id="lastName"></textbox> | |
<separator></separator> | |
<button label="Show Window" id="showWindow"></button> | |
</window> | |
</zk> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.com.demo; | |
import java.util.HashMap; | |
import org.zkoss.zk.ui.Component; | |
import org.zkoss.zk.ui.Executions; | |
import org.zkoss.zk.ui.SuspendNotAllowedException; | |
import org.zkoss.zk.ui.event.Event; | |
import org.zkoss.zk.ui.event.EventListener; | |
import org.zkoss.zk.ui.event.EventQueue; | |
import org.zkoss.zk.ui.event.EventQueues; | |
import org.zkoss.zk.ui.select.SelectorComposer; | |
import org.zkoss.zk.ui.select.annotation.Listen; | |
import org.zkoss.zk.ui.select.annotation.Wire; | |
import org.zkoss.zk.ui.util.GenericForwardComposer; | |
import org.zkoss.zul.Messagebox; | |
import org.zkoss.zul.Textbox; | |
import org.zkoss.zul.Window; | |
@SuppressWarnings("serial") | |
public class ParentWindowController extends SelectorComposer<Window> { | |
@Wire | |
private Window parentWindow; | |
@Wire | |
Textbox firstName; | |
@Wire | |
Textbox lastName; | |
@SuppressWarnings({ "rawtypes", "unchecked" }) | |
public void doAfterCompose(Window comp) throws Exception { | |
super.doAfterCompose(comp); // wire variables and event listners | |
} | |
@Listen("onClick=#showWindow") | |
public void showChild() { | |
final HashMap<String, Object> map = new HashMap<String, Object>(); | |
map.put("firstName", firstName.getValue()); | |
map.put("lastName", lastName.getValue()); | |
map.put("parentWindow", parentWindow); | |
Executions.createComponents( | |
"ChildWindow.zul", null, map); | |
} | |
/** | |
* This method is actualy an event handler triggered only from the Child | |
* window dialog and it is responsible to reflect the data changes | |
* | |
*/ | |
public void onSaved(Event event) { | |
Messagebox.show("OnSaved"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment