0

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 :

<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

delete flag offensive retag edit

Comments

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
0

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

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

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

...
<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

link publish delete flag offensive edit

Comments

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
0

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

chillworld gravatar image chillworld flag of Belgium
5322 4 9
https://github.com/chillw...

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

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.

Edit:

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

Comments

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

Follow
1 follower

RSS

Stats

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

Seen: 45 times

Last updated: Feb 19 '16

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