Uploaded image for project: 'NetBeans'
  1. NetBeans
  2. NETBEANS-6478

Support for Knockout's "checked" binding broken.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 14
    • platform - HTML4J
    • None

    Description

      HTML4J does not correctly support Knockout's "checked" binding that includes checkedValue. The following code snippet illustrating the use case is copied from the Knockout documentation:

      <!-- ko foreach: items -->
          <input type="checkbox" data-bind="checkedValue: $data, checked: $root.chosenItems" />
          <span data-bind="text: itemName"></span>
      <!-- /ko -->
      
      <script type="text/javascript">
          var viewModel = {
              items: ko.observableArray([
                  { itemName: 'Choice 1' },
                  { itemName: 'Choice 2' }
              ]),
              chosenItems: ko.observableArray()
          };
      </script>

      Having the corresponding Java:

      @HTMLDialog(url = "<snippet>.html")
      static HTMLDialog.OnSubmit showUI() {
          ViewModel model = new ViewModel();
          model.applyBindings();
          return (id) -> {
              List<Item> chosenItems = model.getChosenItems();
              return !chosenItems.isEmpty();
          };
      }
      
      @Model(className = "ViewModel", targetId = "", instance = true, builder = "with", properties = {
          @Property(name = "chosenItems", type = Item.class, array = true)
      })
      static final class ViewModelControl {
          @ComputedProperty
          static List<Item> items() {
              return Arrays.asList(new Item("Choice 1"), new Item("Choice 2"));
          }
      }
      
      @Model(className = "Item", instance = true, properties = {
          @Property(name = "itemName", type = String.class)
      })
      static final class ItemControl {
      }
      
      

      The content of `chosenItems` does not reflect changes in checkbox selection.

       

      Attachments

        1. kobinding.zip
          63 kB
          Jaroslav Tulach

        Activity

          People

            jtulach Jaroslav Tulach
            dbalek Dusan Balek
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: