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

Palette in Form calls onSubmit twice, model is erased on second onSubmit

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Invalid
    • 1.3.5, 1.4-RC1, 1.4-RC2
    • 1.3.5, 1.4-RC1, 1.4-RC2
    • wicket-extensions
    • None

    Description

      in following code, onSubmit is called twice, model is erased on second submit:
      ----------------------------------------------------------------
      import java.util.ArrayList;
      import java.util.Arrays;
      import java.util.Collection;
      import java.util.List;

      import org.apache.wicket.extensions.markup.html.form.palette.Palette;
      import org.apache.wicket.markup.html.WebPage;
      import org.apache.wicket.markup.html.form.Button;
      import org.apache.wicket.markup.html.form.ChoiceRenderer;
      import org.apache.wicket.markup.html.form.Form;
      import org.apache.wicket.model.IModel;
      import org.apache.wicket.model.Model;

      public class TestPalettePage extends WebPage
      {
      enum TestEnum

      { E1,E2,E3,E4 }

      ;

      IModel<List<TestEnum>> _model=(IModel<List<TestEnum>>)(new Model(new ArrayList(Arrays.asList(TestEnum.values()))));
      IModel<Collection<TestEnum>> _choices=(IModel<Collection<TestEnum>>)(new Model(new ArrayList(Arrays.asList(TestEnum.values()))));

      public TestPalettePage()
      {
      Form form=new Form("form")
      {
      @Override
      protected void onSubmit()

      { System.out.println("Selected: "+_model.getObject()); }

      };

      ChoiceRenderer<TestEnum> choiceRenderer=new ChoiceRenderer<TestEnum>("name","ordinal");
      Palette<TestEnum> palette=new Palette<TestEnum>("palette",_model,_choices,choiceRenderer,3,true);

      form.add(palette);
      form.add(new Button("submit"));

      add(form);
      }
      }
      -------------------------------------------------------

      Attachments

        Activity

          People

            ivaynberg Igor Vaynberg
            michael.mosmann Michael Mosmann
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: