0

Send Event from iFrame to Parent-zul with Parameter

asked 2015-12-09 20:21:13 +0800

andij62 gravatar image andij62
301 1 6

Hi all,

i have a zul with an iframe inside. The iframe shows html-code generated with

AMedia amedia = new AMedia("info.html", "text/html", "text/html", i.toString());
info.setContent(amedia);

In the HTML-Code i will integrate a Link with an OnClick-Event. When the Link is clicked an Event must fired to the Parent-zul with an Parameter.

Is this possible and how should the onClick-Event and the Logic in Controller should look like? Or is there another possibility?

Can anyone help me?

Regards Andy

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-02-17 12:04:04 +0800

gganassin gravatar image gganassin flag of Luxembourg
540 6
http://www.hybris.com/

Hello! I hope i correctly interpreted your requirements:

Index.zul:

    <zk>
<script type="text/javascript">
function abc(myValue) {
    zAu.send(new zk.Event(zk.Widget.$('$win'), 'onTest', myValue, {toServer:true}));
}
</script>
<window id="win" title="Container Window" border="normal" width="300px" onTest='org.zkoss.zul.Messagebox.show("data: " + event.getData())'>
    <iframe src="test01/test.zul" />
</window>
</zk>

iframed one:

<window title="IFrame Window" border="normal" width="150px">
    <html>
        <a onclick="parent.abc(123456);" href="#">fire!</a>
    </html>
</window>

Notes:

in the container window i am sending a server event onTest via zAu: but of course it is up to you to decide what to implement inside the abc() function.

Hope it helps! Giovanni

link publish delete flag offensive edit

Comments

Perfect! Thank you!

andij62 ( 2016-02-17 14:16:27 +0800 )edit

you are very welcome! please vote the answer ;)

gganassin ( 2016-02-17 14:36:14 +0800 )edit
Your answer
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
1 follower

RSS

Stats

Asked: 2015-12-09 20:21:13 +0800

Seen: 43 times

Last updated: Feb 17 '16

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