Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-3762

NumberTextField does not work with lists

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.5-RC5
    • wicket
    • None

    Description

      When I use NumberTextField to edit values in the list of integers form submission fails with
      Last cause: null
      WicketMessage: Exception 'java.lang.NullPointerException' occurred during validation org.apache.wicket.validation.validator.RangeValidator

      TextField works fine for list of Strings, so form 1 does not work, form2 works fine. Expectation is that form 1 works, repro case attached

      ArrayList ints = new ArrayList(Arrays.asList(1,2,3,4));
      ArrayList strings = new ArrayList(Arrays.asList("1","2","3","4"));

      public ArrayList getInts()

      { return ints; }

      public void setInts(ArrayList ints)

      { this.ints = ints; }

      public ArrayList getStrings()

      { return strings; }

      public void setStrings(ArrayList strings)

      { this.strings = strings; }

      Form f = new Form("editor", new CompoundPropertyModel(this));
      ListView ints = new ListView("ints") {

      @Override
      protected void populateItem(ListItem listItem)

      { listItem.add( new NumberTextField<Integer>("v", (IModel<Integer>) listItem.getDefaultModel(),Integer.class)); }

      };
      f.add(ints);
      add(f);

      Form f2 = new Form("editor2", new CompoundPropertyModel(this));
      ListView strs = new ListView("strings") {

      @Override
      protected void populateItem(ListItem listItem)

      { listItem.add( new TextField("v", listItem.getDefaultModel())); }

      };
      f2.add(strs);
      add(f2);

      Attachments

        1. w-int-list-editor.zip
          20 kB
          Konstantin Ignatyev

        Activity

          People

            ivaynberg Igor Vaynberg
            kgignatyev Konstantin Ignatyev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: