Note that there are some explanatory texts on larger screens.

plurals
  1. POApache wicket: how to update model after validation error
    primarykey
    data
    text
    <p>I have form with dateTimeField, and ListView. ListView looks like that:</p> <pre><code>final ListView&lt;String&gt; countryView = new ListView&lt;String&gt;("country", model.&lt;List&lt;String&gt;&gt;bind("country")) { @Override protected void populateItem(final ListItem&lt;String&gt; item) { final String country = item.getModelObject(); item.add(new ValidationDisplayableLabel("country", country, new String[] { modelPath })); item.add(new AjaxLink("deleteLink") { @Override public void onClick(AjaxRequestTarget target) { model.getObject().getCountry().remove(country); if (issPeriod) { addButton.setVisible(true); countryTextField.setVisible(true); findButton.setVisible(true); } if (target != null) target.addComponent(rowPanel); } }); } }; countryTextField = new ValidationDisplayableTextField("countryCodeInput", model.bind("oneCountry"), "job.country.value"); **countryView.setReuseItems(true);** rowPanel.add(countryView); rowPanel.add(countryTextField); addButton.setOutputMarkupPlaceholderTag(true); rowPanel.add(addButton); </code></pre> <p>And the addButton looks like that:</p> <pre><code>AjaxSubmitLink addButton = new AjaxSubmitLink(LinkNames.addCountry.toString()) { @Override public void onSubmit(AjaxRequestTarget target, Form form) { if (model.getObject().getOneCountry() != null) addCountry(); if (target != null) target.addComponent(rowPanel); target.addComponent(form.getPage().get("feedbackPanel")); } @Override protected void onError(AjaxRequestTarget target, Form&lt;?&gt; form) { onSubmit(target, form); } }; </code></pre> <p>The thing is, that when I fail my dateTimeField (e.g. set hours to 100), enter country code in countryTextField, and press on addButton, it displays validation message in feedback panel, that hour range is incorrect, but don't add the country. This is because my model isn't updated. Maybe there is a way to update it manually? So validation message will be displayed, but the country listView still could be updated? </p> <p>Submit of the whole form is on other button, so logically it is normal to add a country even if there is a validation error in dateTimeField. </p> <p>Thanks!</p> <p>P.S. i've read a lot of posts about similar problem, but most of them were solved with .setReuseItems(true), but it doesn't work in my case. </p> <p>P.P.S Apache wicket 1.4.17</p>
    singulars
    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.
    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