0

invoke component from different .zul

asked 2017-11-11 01:38:00 +0800

ignacio gravatar image ignacio
1

updated 2017-11-11 01:49:27 +0800

Hello everyone, I am trying to execute a Clients.shownotification, which is executed in a component that is in another zul, but it seems that the component did not exist. Both zul are running at the same time and have the same viewModel. This is my code.

MAIN.ZUL <window> <borderlayout >="" <west=""> <include src="/WEB-INF/include/menuPanel.zul"/> </west>

<center>                
   <borderlayout id="borde" >
      <center >
          <caption >
               <include src="/WEB-INF/include/toolbar.zul" />
          </caption>
      </center>
    </borderlayout>
 </center>

</borderlayout> </window>

MENUPANEL.ZUL

<listbox >="" <listhead="" sclass="menu-category" >="" <listheader="" label="CATEGORIA" id="cate"/> </listhead> </listbox>

TOOLBAR.ZUL

<label value="algo" onclick="Clients.showNotification("Seleccione categoría", Clients.NOTIFICATION_TYPE_WARNING, cate, "middle_center", 2000)"/>

delete flag offensive retag edit

3 Answers

Sort by » oldest newest most voted
1

answered 2017-11-13 10:01:44 +0800

hawk gravatar image hawk
2028 1 5
http://hawkphoenix.blogsp... ZK Team

updated 2017-11-13 10:02:35 +0800

Because <include> create an ID space, toolbar.zul and menuPanel.zul belong to different ID spaces since they are both inside <include>. If you can replace them with

<apply templateURI="/path/mypage.zul"/>

Then no id space is created and showNotification() will work.

link publish delete flag offensive edit
0

answered 2017-11-14 05:09:51 +0800

ignacio gravatar image ignacio
1

First, thanks for the response. I understand what you want to tell me, but I do not understand the solution. Would you suggest that you replace the <include> tag with the <apply> tag? If so, the error that occurs is that the <apply> component is not defined (Component definition not found: apply in [LanguageDefinition: xul/html])

link publish delete flag offensive edit
0

answered 2017-11-20 10:53:33 +0800

hawk gravatar image hawk
2028 1 5
http://hawkphoenix.blogsp... ZK Team

Please include the zuti.jar which contains <apply> in your project.

If you don't use ZK EE, you have to locate the target component correctly. ZK searches a component by ID in one id space only by default. Since <include> create an ID space, you have to find the target component manually. like:

<window id="w1">
    <button id="b" label="b"/>
</window>
<window id="w2">
    <button id="b" label="b" onClick='Clients.showNotification("msg", w1.query("#b"))'/>
    <button id="b2" label="b" onClick='Clients.showNotification("msg", w1.getFellow("b"))'/>
</window>

<window> also creates an id space.

You should give id to <include> first like:

<include id="toolbar" src="/WEB-INF/include/toolbar.zul" />

Then toolbar.query("#c")

please refer to https://www.zkoss.org/wiki/ZKDeveloper%27sReference/UIComposing/IDSpace#FindComponentManually

link publish delete flag offensive 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: 2017-11-11 01:38:00 +0800

Seen: 14 times

Last updated: Nov 20