I'm currently rewriting an application from Stripes to Wicket in a
project here and have the following (simplified) problem.

I've got two list components that are filled from a model, and then I
use javascript to transfer items between them, but when the lists are
submitted no new values are added to the model.. Is this expected
behavior or am I missing something? Below are the code (javascript for
moving items and selecting all items before submitting are taken out)

Btw, if I select the first five items in the list and add them to the
other they are dublicated and in the submitted list, so it seems like
you only can submit existing items (with same id) to a list/model,
seems kind of strange to me...

thx,
Kjetil

Page:
-----------
public class HomePage extends BasePage {
   private static final long serialVersionUID = 1L;
   private MyModel mymodel;

   private class InputForm extends Form {
       private InputForm(String name) {
           super(name, new CompoundPropertyModel(mymodel));
           add(new ListMultipleChoice("fewChoice", new
PropertyModel(this, "mymodel.fewChoice"), mymodel.getFewChoice()));
           add(new ListMultipleChoice("manyChoice", new
PropertyModel(this, "mymodel.manyChoice"), mymodel.getManyChoice()));
           add(new Label("message", "Cool....."));
       }
       public MyModel getMymodel() {
           return mymodel;
       }
       public void setMymodel(MyModel m) {
           mymodel = m;
       }
       public void onSubmit() {
           MyModel mm = (MyModel) getModelObject();
           info("SITE CHOICE:");
           for (Object o1 : mm.getFewChoice()) {
               String o = (String) o1;
               info(o);
           }
           info("MANY CHOICE:");
           for (Object o1 : mm.getManyChoice()) {
               String o = (String) o1;
               info(o);
           }
       }
   }

   public HomePage(final PageParameters parameters) {
       mymodel = new MyModel();
       final FeedbackPanel feedback = new FeedbackPanel("feedback");
       add(feedback);
       add(new InputForm("inputForm"));
   }
}


HTML page:
-------------------
<form wicket:id="inputForm">
       <input type="submit" value="Send data.."
onclick="selectAll(this.form.one); selectAll(this.form.two);"/>
       <span wicket:id="message">messages will be put here</span>
       <table>
           <tr>
               <td>
                   <select wicket:id="fewChoice" id="one"
style="height:300px;width:300px;">
                       <option>site 1</option>
                       <option>site 2</option>
                   </select>
               </td>
               <td><input class="button" type="button"
value="&nbsp;&gt;&nbsp;"
                          onclick="moveOptions(one, two);"/>
                   <br>
                   <input class="button" type="button"
value="&nbsp;&lt;&nbsp;"
                          onclick="moveOptions(two, one);"/>
               </td>
               <td>
                   <select wicket:id="manyChoice" id="two"
style="height:300px;width:300px;">
                       <option>choice 1</option>
                       <option>choice 2</option>
                   </select>
               </td>
           </tr>
       </table>
   </form>




Model:
-----------
public class MyModel implements IClusterable {
   private List<String> fewChoice = new ArrayList<String>();
   private List<String> manyChoice = new ArrayList<String>();

   public List getFewChoice() {
       return fewChoice;
   }

   public void setFewChoice(List fewChoice) {
       this.fewChoice = fewChoice;
   }

   public List getManyChoice() {
       return manyChoice;
   }

   public void setManyChoice(List manyChoice) {
       this.manyChoice = manyChoice;
   }

   public MyModel() {
       fewChoice.add("One");
       fewChoice.add("Two");
       fewChoice.add("Three");
       fewChoice.add("Four");
       fewChoice.add("Five");
       for(int i = 1; i < 15; i++) {
           manyChoice.add("# " + i);
       }
   }
}

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to