0

How to read parameter in created component

asked 2006-04-07 23:16:33 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


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>


delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2006-04-08 02:31:10 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


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


link publish delete flag offensive edit

answered 2006-04-08 10:04:58 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


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>

link publish delete flag offensive edit

answered 2006-04-08 11:07:51 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


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


link publish delete flag offensive edit
Your reply
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

RSS

Stats

Asked: 2006-04-07 23:16:33 +0800

Seen: 716 times

Last updated: Apr 08 '06

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