Hi,

The form components aren't updated because form processing for AjaxSubmitLink 
is set to false.
See the javadoc for AjaxSubmitLink#setDefaultFormProcessing.

BTW, when using ListView for rendering form components consider reading WARNING 
section in javadoc for ListView class.

----- Исходное сообщение -----
От: "Sebastian80" <[email protected]>
Кому: [email protected]
Отправленные: Суббота, 12 Ноябрь 2011 г 17:46:51
Тема: Model isn't updated on AJAX submit link invocation

Hi there,

I'm trying to implement an AJAXfied Wicket list view. On my research I
stumbled upon the code on
http://www.oktech.hu/kb/adding-and-removing-rows-wicket-listview-via-ajax
and modified it a bit.

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 again). Why does this happen? I don't see any issue with this code.
Wicket version is 1.5.2.

Here is the Java code:

// Initialization of form
...

// List all rows
ArrayList<String> rows = new ArrayList<String>(2);
rows.add(new String());
rows.add(new String());

final ListView<String> lv = new ListView<String>("rows", rows) {
    @Override
    protected void populateItem(ListItem<String> item) {
        int index = item.getIndex() + 1;
        item.add(new Label("index", index + "."));

        TextField<String> text = new TextField<String>("text",
item.getModel());
        item.add(text);
    }
};
rowPanel.add(lv);

    AjaxSubmitLink addLink = new AjaxSubmitLink("addRow", form) {

    @Override
    protected void onError(AjaxRequestTarget target, Form<?> form) {
        if (target != null) target.add(rowPanel);
    }

    @Override
    protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
        lv.getModelObject().add(new String());
        if (target != null) target.add(rowPanel);
    }
};
addLink.setDefaultFormProcessing(false);
rowPanel.add(addLink);
...

And the associated mark up:
<div wicket:id="rowPanel">

        1.
        <input type="text" wicket:id="text"/>

     # Add row
</div>

Has someone any idea on this issue? I'm completely stuck on this issue.
Thanks in advance.

Best regards,
Sebastian

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Model-isn-t-updated-on-AJAX-submit-link-invocation-tp4034095p4034095.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to