From a zul, how to access a component inside an include

asked 2016-02-19 10:11:47 +0800

WilliamB gravatar image WilliamB
1609 1 6

I've the following setup.

Mainzul.zul :

   <include id="myInclude" src="mysubZul.zul" />
   <button onClick="@Command('myCmd', subValue=myTextBox.value)" />


   <textbox id="myTextBox" />

At the moment I cannot access the component in the include. I know how to wire it in my VM, but I want to avoid that.


delete flag offensive retag edit


did you try to use a transparent component such as a simple <div> instead of the <window> in the mysubZul.zul?

gganassin ( 2016-02-19 10:24:48 +0800 )edit

@gganassin that doesn't matter the include has the IdSpace interface also so he will hit always a difference IdSpace

chillworld ( 2016-02-19 10:49:31 +0800 )edit

@chill yep indeed but if you see my reply... he can target the include itself so that's not the issue. Having instead other inner IdSpaces inside the include will then make this goal prohibitive... no?

gganassin ( 2016-02-19 10:53:12 +0800 )edit

a little more detail about the VM or VM's can be helpfull.

chillworld ( 2016-02-19 11:04:18 +0800 )edit

@gganassin it makes It a little more difficult because he need to pass the idspace with the window only but it's still possible

chillworld ( 2016-02-19 11:12:01 +0800 )edit

2 Answers

Sort by » oldest newest most voted

answered 2016-02-19 10:41:47 +0800

gganassin gravatar image gganassin flag of Luxembourg
540 6

updated 2016-02-19 10:43:34 +0800

<include id="myInclude" src="included.zul" />
<button onClick="@command('myCmd', val=myInclude.getFellow('myTextBox').value)" />


public void myCmd(@BindingParam(value = "val") String val) {

NOTE: the included zul should use transparent components... otherwise you will be forced to know how it is composed (and to articulate even more the myInclude.getFellow('myTextBox'). You should anyway try to do in another way: myInclude.getFellow('myTextBox').value is really weak... as you can see if the inner .zul gets changed over time... it may cause issues.


link publish delete flag offensive edit


That's what I already implemented, but I wanted to know if there was a cleaner syntax like myInclude$myTextBox for the composer or #myInclude #myTextBox for the VM.

WilliamB ( 2016-02-19 13:18:49 +0800 )edit

answered 2016-02-19 10:50:52 +0800

chillworld gravatar image chillworld flag of Belgium
5337 4 9

updated 2016-02-19 14:36:31 +0800


A MVVM solution could be :

    <textbox id="myTextBox" value="@bind(vm.xxx)/>

As long your viewmodel have that getter/setter there is no problem.

I'll see for a solution with the id's but for MVVM I do think you need to avoid having id's.


In addition of the other answer :

Returns the first textbox under window (no id needed):

myInclude.query("window > textbox").value

Same but on id's : (is faster then previous)

myInclude.query("#win > #myTextBox").value
link publish delete flag offensive edit


Thanks Chill, but what I want is a zul way to access the component directly, as I stated above, I already use myInclude.getFellow('myTextBox').value but I wanted to know if there was a cleaner synthax.

WilliamB ( 2016-02-19 13:19:43 +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

1 follower



Asked: 2016-02-19 10:11:47 +0800

Seen: 67 times

Last updated: Feb 19 '16

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