How would one use a [Wicket] ListView with a form? -


i have added form on submit of have add more wicket controls labels, textfields , button ajex link. not able correct html. can please me rid of ?

voucherpanel.html

<html xmlns:wicket> <head> </head> <body>   <wicket:panel>     <div class="form-block">       <div wicket:id="form">         <wicket:message key="lbl.vouchercode" />         <div wicket:id="list">           <input wicket:id="word" type="text" />         </div>         <div wicket:id="vouchercode"></div>       <button wicket:id="submit"><wicket:message key="submittext"/></button>          </div>     </div>   </wicket:panel> </body> </html> 

voucherpanel.java

public class voucherpanel extends panel {   private static final long serialversionuid = 1l;    public voucherpanel(final string id)   {     super(id);      final textfield<string> vouchercodefield = new textfield<string>("vouchercode", model.of(""));     vouchercodefield.setrequired(true);      final button button = new button("submit");      form<?> form = new form<void>("form")     {        @override       protected void onsubmit()       {                numberoffields = new arraylist<string>();                int noofvocuhers = getnoofallowedvoucher();// returing number               (int = 0; < noofvocuhers; i++) {                 numberoffields.add(new string(""));             }              add(new listview<object>("list", numberoffields) {                 private static final long serialversionuid = 1l;                  @override                 protected void populateitem(listitem<object> item) {                     final string word = (string) item.getmodelobject();                     system.out.println( "word   =" +word );                     textfield<string> textfield = new textfield<string>("word",  model.of(""));                     textfield.setoutputmarkupid(true);                     item.add(textfield);                 }             });          }       }     };      add(form);      form.add(vouchercodefield);     form.add(button);   } } 

  1. you're trying assign textfield <div> element (vouchercode), need <input type="text"> instead.
  2. you need add list form right away, onsubmit late. set outside, similar button , call mylistview.setlist when submitting form.

these 2 things spotted... if still have problems please let know error messages get.


Comments