tag:blogger.com,1999:blog-510594773915377610.post5290546710180600512..comments2024-02-29T22:09:44.421-08:00Comments on potatoes and carrots no bones: Pass Event to Other Componentbenbai123http://www.blogger.com/profile/02710053250987444028noreply@blogger.comBlogger36125tag:blogger.com,1999:blog-510594773915377610.post-56788008093791896422013-02-21T03:57:38.320-08:002013-02-21T03:57:38.320-08:00I have asked one question here http://stackoverflo...I have asked one question here http://stackoverflow.com/questions/15001670/how-to-get-viewmodel-from-selectedtab-in-zkAnonymoushttps://www.blogger.com/profile/02829243799214473163noreply@blogger.comtag:blogger.com,1999:blog-510594773915377610.post-56921844194533547842013-02-21T03:51:08.403-08:002013-02-21T03:51:08.403-08:00Is there a sample that can reproduce this issue?Is there a sample that can reproduce this issue?benbai123https://www.blogger.com/profile/02710053250987444028noreply@blogger.comtag:blogger.com,1999:blog-510594773915377610.post-79726380135469878492013-02-21T01:58:55.755-08:002013-02-21T01:58:55.755-08:00These is one issue with this approach here in usin...These is one issue with this approach here in using Singleton Class .Let us suppose i have open A<B,C,D tab and i am in D tab so Singleton class have COmponent class of D now if i will click on tab A then methods of TabD will be call Which is a issue.Anonymoushttps://www.blogger.com/profile/02829243799214473163noreply@blogger.comtag:blogger.com,1999:blog-510594773915377610.post-30455284713978039672013-02-14T20:24:40.913-08:002013-02-14T20:24:40.913-08:00Thanks Ben for your helpThanks Ben for your helpAnonymoushttps://www.blogger.com/profile/02829243799214473163noreply@blogger.comtag:blogger.com,1999:blog-510594773915377610.post-76919819962735240302013-02-14T17:14:30.961-08:002013-02-14T17:14:30.961-08:00Seems the spec of modal window, repliedSeems the spec of modal window, repliedbenbai123https://www.blogger.com/profile/02710053250987444028noreply@blogger.comtag:blogger.com,1999:blog-510594773915377610.post-2413457724740984022013-02-14T09:26:31.567-08:002013-02-14T09:26:31.567-08:00Ben do you have any idea about this http://stackov...Ben do you have any idea about this http://stackoverflow.com/questions/14879269/zk-listbox-onselect-issueAnonymoushttps://www.blogger.com/profile/02829243799214473163noreply@blogger.comtag:blogger.com,1999:blog-510594773915377610.post-84082786550836021812013-02-14T09:07:15.403-08:002013-02-14T09:07:15.403-08:00Yeah this seems a good way to go.Yeah this seems a good way to go.benbai123https://www.blogger.com/profile/02710053250987444028noreply@blogger.comtag:blogger.com,1999:blog-510594773915377610.post-61824660462286894002013-02-14T08:36:02.033-08:002013-02-14T08:36:02.033-08:00Thanks Again Ben ...i got another idea and look li...Thanks Again Ben ...i got another idea and look like it is working fine with me What i did? I made a Singleton Class and added a variable of Component class with get/set method. Now in each of my view Model afterCompose() i am calling setter method of Component variable from singleton class, and passing current viewModel Component object to it and in my HomeViewModel CTRL key event method i adding this code so it calling method from Selected tab .<br /><br />Component ctrlkeyComp = idBinder.getCompObject();<br /> if(ctrlkeyComp != null){<br /> Binder bind = (Binder) ctrlkeyComp.getAttribute("binder");<br /> <br /> if (bind == null)<br /> return;<br /> bind.postCommand("doActionInChildVM", map);<br /> }<br /><br />Anonymoushttps://www.blogger.com/profile/02829243799214473163noreply@blogger.comtag:blogger.com,1999:blog-510594773915377610.post-20007724030459263762013-02-14T06:06:25.226-08:002013-02-14T06:06:25.226-08:00There's an idea coming in to my mind, since re...There's an idea coming in to my mind, since requests are thread safe, we can assume the create event of tab and the init of child vm are occur at the same time, in other words, if we maintain two list say tabList and vmList, we can assume the order of tab in tabList will match the order of child vm in vmList, i.e., we can do something as below:<br /><br />1. find the order of selected tab in parent vm<br /><br />2. get the corresponding child vm based on the order found before in vmList<br /><br />3. call binder.postCommand of child vm<br /><br />just a rough concept, not testedbenbai123https://www.blogger.com/profile/02710053250987444028noreply@blogger.comtag:blogger.com,1999:blog-510594773915377610.post-40714854823069721172013-02-13T18:49:19.069-08:002013-02-13T18:49:19.069-08:00According to the javadoc (http://www.zkoss.org/jav...According to the javadoc (http://www.zkoss.org/javadoc/6.5.1/zk/org/zkoss/bind/impl/BinderImpl.html#postCommand(java.lang.String, java.util.Map)), postCommand will post a command to current binder, it can not post command from parent vm to child vm. You can try use EventQueue directly as needed.benbai123https://www.blogger.com/profile/02710053250987444028noreply@blogger.comtag:blogger.com,1999:blog-510594773915377610.post-69575954194605526532013-02-12T01:57:27.349-08:002013-02-12T01:57:27.349-08:00Can it possible to run bind.postCommand("meth...Can it possible to run bind.postCommand("methodName", map); here ?Anonymoushttps://www.blogger.com/profile/02829243799214473163noreply@blogger.comtag:blogger.com,1999:blog-510594773915377610.post-72096121043287982312013-02-07T05:45:36.014-08:002013-02-07T05:45:36.014-08:00That's right, then you can find the parent tab...That's right, then you can find the parent tab (from child vm) and detect whether it is the selected tab (in the global event from parent vm).benbai123https://www.blogger.com/profile/02710053250987444028noreply@blogger.comtag:blogger.com,1999:blog-510594773915377610.post-38584106174897055902013-02-07T03:51:33.389-08:002013-02-07T03:51:33.389-08:00Ok but If we are adding a calling a GlobalComamnd ...Ok but If we are adding a calling a GlobalComamnd from Parent View Model and creating a global command in each of the Child viewmodel then it is going to each viewmodel global command because name is same in each child viewmodelAnonymoushttps://www.blogger.com/profile/02829243799214473163noreply@blogger.comtag:blogger.com,1999:blog-510594773915377610.post-84238698253026821942013-02-07T01:54:00.749-08:002013-02-07T01:54:00.749-08:00Maybe you can try global command in this way:
1. ...Maybe you can try global command in this way:<br /><br />1. Store the selected tab in parent vm, and pass it to each child vm with global command<br /><br />2. Store any component (maybe the first one under child vm) in the child zul within child vm, and continuously get parent component until find a tab then check whether it is the selected tab when global command triggered.benbai123https://www.blogger.com/profile/02710053250987444028noreply@blogger.comtag:blogger.com,1999:blog-510594773915377610.post-61815088776273176032013-02-06T22:58:26.989-08:002013-02-06T22:58:26.989-08:00In my case its very hard to do that Can we do some...In my case its very hard to do that Can we do something like postcommand where we can give command name and the command will fire child viewmodel ?Anonymoushttps://www.blogger.com/profile/02829243799214473163noreply@blogger.comtag:blogger.com,1999:blog-510594773915377610.post-58158978418974597922013-02-06T05:17:05.735-08:002013-02-06T05:17:05.735-08:00You can also use tp.getFirstChild().getFirstChild...You can also use tp.getFirstChild().getFirstChild() if the first element of each inner page is the element that apply child vm.benbai123https://www.blogger.com/profile/02710053250987444028noreply@blogger.comtag:blogger.com,1999:blog-510594773915377610.post-13264629927989667672013-02-06T05:03:27.999-08:002013-02-06T05:03:27.999-08:00can it possible we can change this line
Events.pos...can it possible we can change this line<br />Events.postEvent("onActionRequest", tp.getFirstChild().getFellow("div"), data);<br /><br />As you are doing id binding i will want to give command name or other thing because i have plenty with different component if i will add id static id in each pages i have to change plenty of places .Can we have any other solution here?Anonymoushttps://www.blogger.com/profile/02829243799214473163noreply@blogger.comtag:blogger.com,1999:blog-510594773915377610.post-48275750162209854822013-02-06T03:38:52.918-08:002013-02-06T03:38:52.918-08:00By the way, the sample above firing event to selec...By the way, the sample above firing event to selected tab child from tabbox instead of using global commandbenbai123https://www.blogger.com/profile/02710053250987444028noreply@blogger.comtag:blogger.com,1999:blog-510594773915377610.post-50001438081097052032013-02-06T03:37:24.843-08:002013-02-06T03:37:24.843-08:00I've tested it and the onCtrlKey event fired f...I've tested it and the onCtrlKey event fired for each tab without any problem, basically the parent component (tabbox) will receive the events of its children (all tabs)benbai123https://www.blogger.com/profile/02710053250987444028noreply@blogger.comtag:blogger.com,1999:blog-510594773915377610.post-47102136829288535692013-02-06T02:40:06.843-08:002013-02-06T02:40:06.843-08:00Here you added ctrl key event in tab while in my c...Here you added ctrl key event in tab while in my case i added ctrl key event in windows compoentn so it will available for each tab because my all tab is added from java code and its too complex to add ctrl key in tab componentAnonymoushttps://www.blogger.com/profile/02829243799214473163noreply@blogger.comtag:blogger.com,1999:blog-510594773915377610.post-51581744226846855412013-02-06T02:30:35.046-08:002013-02-06T02:30:35.046-08:00Thanks Let me try your example Thanks Let me try your example Anonymoushttps://www.blogger.com/profile/02829243799214473163noreply@blogger.comtag:blogger.com,1999:blog-510594773915377610.post-84789671002898517922013-02-06T02:16:26.247-08:002013-02-06T02:16:26.247-08:00Maybe you can try the form binding (http://books.z...Maybe you can try the form binding (http://books.zkoss.org/wiki/ZK%20Developer's%20Reference/MVVM/Data%20Binding/Form%20Binding), if this still not work in your case, you can try customize the tabbox as needed, e.g., like this sample at zkfiddle (http://zkfiddle.org/sample/vmmp6p/1-MVVM-Test)benbai123https://www.blogger.com/profile/02710053250987444028noreply@blogger.comtag:blogger.com,1999:blog-510594773915377610.post-88029186705392696092013-02-05T17:56:01.412-08:002013-02-05T17:56:01.412-08:00I have home.zul which contain menu with item and w...I have home.zul which contain menu with item and when you will click on any menu item it will open a tab for each menu item a new tab will open now each tab contain a zul page where user can do certain operation and by Ctrl keys like Ctrl+s for Saving, Ctrl+r for Refresh, Ctrl+q for query etc will perform. If I will use global command I have to write that global command in each tab view model or we can say child of home. Now suppose I open a tab then ctrl key will fire now I open another tab now 2 times ctrl key will fire , while I will want only active tab view model will fire a event on ctrl key<br />Anonymoushttps://www.blogger.com/profile/02829243799214473163noreply@blogger.comtag:blogger.com,1999:blog-510594773915377610.post-73324873455524271702013-02-05T15:05:18.570-08:002013-02-05T15:05:18.570-08:00Are the tabs under parent VM or child VM?Are the tabs under parent VM or child VM?benbai123https://www.blogger.com/profile/02710053250987444028noreply@blogger.comtag:blogger.com,1999:blog-510594773915377610.post-74128697175650575162013-02-05T07:32:08.630-08:002013-02-05T07:32:08.630-08:00Here in my case tab contain a wholee page differen...Here in my case tab contain a wholee page different tab means a different page also tab are created dynamically from java code and when tab or page is selected and user doing something then if user use ctrl key then I have to fire save, refresh, delete etc.Anonymoushttps://www.blogger.com/profile/02829243799214473163noreply@blogger.com