Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-1640

Command send to wrong viewModel in nested case

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 6.5.1
    • Fix Version/s: 6.5.2
    • Component/s: Databind 2
    • Labels:
      None
    • Environment:

      os x, java 1.7

      Description

      When we have two viewmodels one inside the other (parent model view and child model view) commands are not binding correctly, if commands are in the child viewmodel, on a row generated by template.

      If we have two modelviews one(child) inside other(parent), and commands are fire from the child modelview inside something generated by template. Example:

      <window apply="org.zkoss.bind.BindComposer"
                  viewModel="@id('vmparent') @init('net.ParentVm')">
      
      ...
      <window apply="org.zkoss.bind.BindComposer"
                  viewModel="@id('vmchild') @init('net.ChildVm')">
                        
                         <button label="othercommand" onClick="@command('othercommand')"/>
      
                         <grid model="@bind(vmchild.elements)"  >
                              <rows>
                              <template name="model" var="element">
                                  <row>
                                          <button label="Edit"
                                                  onClick="@command('editSelectedItem',item=element)"></button> <!-- here is the problem -->
                                  </row>
                              </template>
                              </rows>
                          </grid>
      
      
      </window>
      
      
      </window>
      
      

      Zk thinks that the command "editSelectedItem" should be in net.ParentVm, and is trying to locate there, but it is not there, the command is located on net.ChildVm.
      And I got an error : cannot find any method that is annotated for the command editSelectedItemwith @Command in net.ParentVm

      This bug is very strange because if I click first on "othercommand" which was not on "template" is located correctly, and after that, the error stop rising.

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            dgofast dgofast
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: