-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I've the following setup.
Mainzul.zul :
<window>
<include id="myInclude" src="mysubZul.zul" />
<button onClick="@Command('myCmd', subValue=myTextBox.value)" />
</window>
mysubZul.zul
<window>
<textbox id="myTextBox" />
</window>
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.
Thanks
...
<include id="myInclude" src="included.zul" />
<button onClick="@command('myCmd', val=myInclude.getFellow('myTextBox').value)" />
...
and
@Command
public void myCmd(@BindingParam(value = "val") String val) {
System.out.println(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.
Gio
William,
A MVVM solution could be :
<window>
<textbox id="myTextBox" value="@bind(vm.xxx)/>
</window>
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
Asked: 2016-02-19 10:11:47 +0800
Seen: 69 times
Last updated: Feb 19 '16
Structuring zul-code without includes?
Focus on the first input after closing modal window
MVVM : How can I add variable to applicationscope ?
Calling custom component constructor with params from zul
ZK Calendar Wire Spring-managed Beans Failed [closed]
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 )edita 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