Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7070719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:36:02+00:00 2026-05-28T05:36:02+00:00

I have form with dateTimeField, and ListView. ListView looks like that: final ListView<String> countryView

  • 0

I have form with dateTimeField, and ListView.
ListView looks like that:

final ListView<String> countryView = new ListView<String>("country", model.<List<String>>bind("country")) {
            @Override
            protected void populateItem(final ListItem<String> 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);

And the addButton looks like that:

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<?> form)
        {
            onSubmit(target, form);
        }
    };

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?

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.

Thanks!

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.S Apache wicket 1.4.17

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:36:02+00:00Added an answer on May 28, 2026 at 5:36 am

    I faced a similar problem in my project, the workaround I found was to use a special Visitor. It will update the model even though the submitted input is invalid.

    public class VisitorUpdateModelWithoutValidation implements FormComponent.IVisitor {
    
    public Object formComponent(IFormVisitorParticipant formComponent) {
            if (formComponent instanceof FormComponent) {
                final FormComponent<?> formComponent1 = (FormComponent<?>) formComponent;
                boolean required = formComponent1.isRequired();
                if (required) {
                    formComponent1.setRequired(false);
                }
                formComponent1.modelChanging();
                formComponent1.validate();
                formComponent1.updateModel();
                formComponent1.modelChanged();
                if (required) {
                    formComponent1.setRequired(true);
                }
            }
    
            return Component.IVisitor.CONTINUE_TRAVERSAL;
        }
    }
    

    Simply use it in the onSubmit method of your behavior : getForm().visitFormComponents(new VisitorUpdateModelWithoutValidation());

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a model that looks something like this class Post(models.Model): id = models.IntegerField(unique=True,
I have a Django model that looks like this. class Solution(models.Model): ''' Represents a
I have a model that looks like this: class Movie(models.Model): title = models.CharField(max_length=200) slug
I have form, where some fields are looks like rows, so I can add/delete
I have a rather complex model that I am using to render a form
I have a model like this: class Tour(models.Model): Name=models.CharField(max_length=100) Count=models.SmallIntegerField() ActionDate=models.DateTimeField(editable=False) ActionUser=models.ForeignKey(User,editable=False) StatusType=models.ForeignKey(StatusType) now
I have form that displays several keywords (standard set of choice lists that changes
I have a custom model fields, that can have 'chain' argument. from django.db import
I have a model called ClassFile that takes a FileField (document): class ClassFile(models.Model): timestamp
I have a form like the one below: class ConsentFormTpl(forms.Form): title = forms.CharField() message

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.