Note that there are some explanatory texts on larger screens.

plurals
  1. POModel isn't updatd on AJAX submit link invocation
    primarykey
    data
    text
    <p>I'm trying to implement an AJAXfied Wicket list view. On my research I stumbled upon the code on <a href="http://www.oktech.hu/kb/adding-and-removing-rows-wicket-listview-via-ajax" rel="nofollow">this site</a> and modified it a bit.</p> <p>The model is not updated properly. So whenever a value is entered in a text field, it is forgotten if the AJAX submit link is invoked (the text field is empty). Why does this happen? I don't see any issue with this code. Wicket version is 1.5.2.</p> <p>Here is the Java code:</p> <pre><code>// Initialization of form ... // List all rows ArrayList&lt;String&gt; rows = new ArrayList&lt;String&gt;(2); rows.add(new String()); rows.add(new String()); final ListView&lt;String&gt; lv = new ListView&lt;String&gt;("rows", rows) { @Override protected void populateItem(ListItem&lt;String&gt; item) { int index = item.getIndex() + 1; item.add(new Label("index", index + ".")); TextField&lt;String&gt; text = new TextField&lt;String&gt;("text", item.getModel()); item.add(text); } }; rowPanel.add(lv); AjaxSubmitLink addLink = new AjaxSubmitLink("addRow", form) { @Override protected void onError(AjaxRequestTarget target, Form&lt;?&gt; form) { if (target != null) target.add(rowPanel); } @Override protected void onSubmit(AjaxRequestTarget target, Form&lt;?&gt; form) { lv.getModelObject().add(new String()); if (target != null) target.add(rowPanel); } }; addLink.setDefaultFormProcessing(false); rowPanel.add(addLink); ... </code></pre> <p>And here is the mark up:</p> <pre><code>&lt;div wicket:id="rowPanel"&gt; &lt;span wicket:id="rows"&gt; &lt;span wicket:id="index"&gt;1.&lt;/span&gt; &lt;input type="text" wicket:id="text"/&gt; &lt;/span&gt; &lt;a href="#" wicket:id="addRow"&gt;Add row&lt;/a&gt; &lt;/div&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload