-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3675754
By: tskale
A window is created as follows:
java.util.Map params = new java.util.HashMap(); params.put("key", "value"); Window theWin = (Window)exec.createComponents("/testWindow.zul",
Path.getComponent("//myPage/wmain"), params); theWin.doOverlapped();
The window is created. In the window I need to show the parameter passed to it in params map. What code is required in ??? below?
<!-- testWindow.zul -->
<window>
The parameter key is = ???
</window>
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3675887
By: henrichen
In Java (ZScript)
Executions.getCurrent().getParameter("key").
In EL, ${param['key']}
/henri
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3676079
By: tskale
Henri:
Please load the following files:test.zul and testWindow.zul
Click a button to create a label.
Click on a label to create testWindow.
The value of key passed to testWindow is null.
Is there any error in the code below?
Thanks for your help.
========= test.zul ===========
<?page id="testPage" ?>
<zk>
<zscript>
<![CDATA[
public class MyLabel extends Label
{
public MyLabel(String txt)
{
super();
this.setValue(txt);
this.setStyle("color: blue");
this.addEventListener("onClick", new MyLabelListener());
}
}
public class MyLabelListener implements EventListener
{
public boolean isAsap()
{
return true;
}
public void onEvent(Event event)
{
MyLabel comp = (MyLabel)event.getTarget();
final Execution exec = Executions.getCurrent();
java.util.Map params = new java.util.HashMap();
params.put("key", "value of key");
Window theWin = (Window)exec.createComponents("/testWindow.zul",
Path.getComponent("//testPage/mainWin"), params);
theWin.doOverlapped();
}
}
]]>
</zscript>
<window id="mainWin">
<button label="show label">
<attribute name="onClick">
MyLabel theLabel = new MyLabel("The new label");
theLabel.setParent(self.getParent());
</attribute>
</button>
</window>
</zk>
====== testWindow.zul ===========
<zk>
<window id="testWindow" title="test Window" border="normal" visible="false"
width="500px" top="0px" left="300px" closable="true" > <attribute name="onCreate">
val = Executions.getCurrent().getParameter("key") ;
System.out.println("****** value passed is " + val); </attribute> The value is <label value="${param['key']}" /> </window> </zk>
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3676117
By: henrichen
Sorry, my previous answer is _NOT_ correct. The following is used when passing request parameters across pages.
In Java (ZScript)
Executions.getCurrent().getParameter("key").
In EL, ${param['key']}
-------------------
When passing arguments via createComponents() or createComponentsDirectly(), it should be
In Java (zacript)
Executions.getCurrent().getArg().get("key").
In EL, ${arg['key']}
/henri
Asked: 2006-04-07 23:16:33 +0800
Seen: 716 times
Last updated: Apr 08 '06