0

Call function in child window [closed]

asked 2009-06-10 10:48:42 +0800

timshiu gravatar image timshiu
51

updated 2013-02-04 09:41:23 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

I would like to ask if there is any way to call the zscript function in child window?

e.g.

<window>
    <zscript>
        public void callChildFunc()
        {
            // Any way to call child window test() function ????
        }
    </zscript>
    <window>
        <zscript>
            public void test()
            {
                alert("Test");
            }
        </zscript>
    </window>
</window>
delete flag offensive retag edit

The question has been closed for the following reason "too localized" by sjoshi
close date 2013-02-08 05:57:42

5 Replies

Sort by ยป oldest newest

answered 2009-06-10 13:17:10 +0800

xenoky gravatar image xenoky
42

you can try giving an identifier to the window:
<window id="win">

then win.test()

link publish delete flag offensive edit

answered 2009-06-11 00:50:59 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

I don't think you can call win.test() in above case.
timshiu, if I were you I will
1. write the test function as a global function and pass any local variable as function arguments.
or 2. use post event from one to another, and handle the event locally.

link publish delete flag offensive edit

answered 2009-06-11 01:31:52 +0800

timshiu gravatar image timshiu
51

Thanks for your advice.
Actually, my scenario is that I want to create a macro component which can be plugged to any zul page.
There are window components on both the marco component page and zul page, and I need to call a function in the child window which will access the values of the components inside the child window.

1. If the zscript is inside the child window, we can get the values of components by the .value directly.
But the parent window cannot call the function in the child window directly.
2. If I place the zscript outside the child window and inside the marco component, I need to access the values of components by Path.getComponent().value method. Since the parent window can be different in different zul page and the window id is varied, the path for getComponent() cannot be hard-code in the marco component.

So, I would like to ask:
1) if there is any way to call the zscript function in child window? (It seems we cannot call the function in child window directly)
2) if there is any way to get the component in child window without the id of parent window?

link publish delete flag offensive edit

answered 2009-06-11 02:28:23 +0800

timshiu gravatar image timshiu
51

I found the solution finally.
There is a function called getFellow() which can be called by parent window to get the components inside the child window.

e.g. Textbox txtbx = macro_comp.getFellow("txtbx");

link publish delete flag offensive edit
link publish delete flag offensive edit

Question tools

Follow

RSS

Stats

Asked: 2009-06-10 10:48:42 +0800

Seen: 495 times

Last updated: Feb 04 '13

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