0

Attach existing ViewModel to new tab

asked 2013-09-30 15:41:14 +0800

aavishai gravatar image aavishai
1

updated 2013-10-01 14:33:31 +0800

I'm creating a tabbox UI where each tab is a child of the tab before it. Some functionality requires that the child tab have the same ViewModel instance of it's parent tab. I've succeeded in passing the parent tab's ViewModel into the child tab by setting it as an attribute on the child, but I don't know how to set the passed in ViewModel to be the child's ViewModel.

The practical result is that while calling vm.foo(); works in the child tab, @command('foo') does not.

Any suggestions on how to set the child's ViewModel would be greatly appreciated. Thanks.

Edit: For the record, the parent-child relationship is purely business logic. The tabs are peer tabs in a standard tabbox.

delete flag offensive retag edit

Comments

For the record, the parent-child relationship is purely business logic. The tabs are peer tabs in a standard tabbox.

aavishai ( 2013-10-03 21:13:28 +0800 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2013-10-04 15:42:24 +0800

aavishai gravatar image aavishai
1

Here's the way I figured out how to do it:

<div id="manageProd" apply="org.zkoss.bind.BindComposer">
    <label value="@bind(manageProd.getAttribute('binder').setViewModel(vm))"/> 
    ...do stuff..
</div>
link publish delete flag offensive edit

Comments

No one will suggest to do Java stuff in ZUL file

sjoshi ( 2013-10-06 05:22:50 +0800 )edit

Fair enough. What is the correct way to achieve the same result? Also, why is it problematic to do Java stuff in a ZUL? ZK even suggests doing so in the last example on this ZK Developer's Guide page... http://books.zkoss.org/wiki/ZK_Developer's_Guide/ZUL_Components/Layout_and_Windows/Tab_Boxes (http://books.zkoss.org/wiki/ZKDeveloper'sGuide/ZULComponents/LayoutandWindows/TabBoxes)

aavishai ( 2013-10-06 16:24:29 +0800 )edit
0

answered 2013-10-01 05:31:20 +0800

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

If it is a Parent-Child Relation then you can use

Binder bind = (Binder) view.getParent().getAttribute("binder");
        if (bind == null)
            return;
        bind.postCommand("doColumnReordering", params);

doColumnReordering method is in Parent ViewModel
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: 2013-09-30 15:41:14 +0800

Seen: 31 times

Last updated: Oct 04 '13

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