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

  • Home
  • SEARCH
  • 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 8520081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:26:08+00:00 2026-06-11T06:26:08+00:00

I have a dynamic form that I’m writing in Wicket with a handful of

  • 0

I have a dynamic form that I’m writing in Wicket with a handful of forms that get duplicated with a “Click here to add more issues” type of button. I’ve written a very basic (I’m still new to Wicket) AJAXy listener that mostly works, but I can’t figure out how to remove or even hide the items in my ListView.

This makes me wonder, is there any way to just have some JS duplicate the form fields? Before I retooled the form with Wicket components I had the Jquery Dynamic Form Plugin duplicating the values. This worked great and was very easy to understand (an important plus). However I can’t figure out how this would affect Wicket if I simply used the plugin instead of something like

    //Issue box magic
    final MarkupContainer rowPanel = new WebMarkupContainer("issuesPanel");
    rowPanel.setOutputMarkupId(true);
    form.add(rowPanel);
    ArrayList numIssues = new ArrayList();
    numIssues.add(new Object());
    numIssues.add(new Object());
    numIssues.add(new Object());
    final ListView lv = new ListView("issuesBox", numIssues) {
        @Override
        protected void populateItem(ListItem item) {
            int index = item.getIndex() + 1;

            item.add(new DropDownChoice("issues", combinedIssues));
            item.add(new TextField<String>("note"));
        }
    };
    lv.setReuseItems(true);
    rowPanel.add(lv);
    form.add(new AjaxSubmitLink("addIssue", form) {
        @Override
        public void onSubmit(AjaxRequestTarget target, Form form) {
            lv.getModelObject().add(new Object());
            if (target != null)
                target.add(rowPanel);
        }
    }.setDefaultFormProcessing(false));
    form.add(new AjaxSubmitLink("removeIssue", form) {
        @Override
        public void onSubmit(AjaxRequestTarget target, Form form) {
            //Wicket gets very angry when you remove components, so just hide it (recommended way)
            if (target != null) {
                Component lastObject = (Component)lv.get(lv.getList().size() - 1);
                lastObject.setVisible(false);
                log.debug("Components " + lv.get );
            }

        }
    }.setDefaultFormProcessing(false));

The JQuery plugin is much easier to use, but how can I tell Wicket that there are more fields than it thought there were?

Note I’m also trying to avoid the AJAX call just to add a new issue which in the siltation I’m using the app in might become a problem.

Any suggestions?

  • 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-06-11T06:26:10+00:00Added an answer on June 11, 2026 at 6:26 am

    You can’t just add form elements in html via ajax. With Wicket, you have a compenent tree in html and Java, and both must match. In the end, Wicket must know what todo with the values when you submit the form.

    Not sure I understand your particular requirements, but I guess a similar problem might be that of adding adresses to an person. Here, I would build a AdressEditPanel that contains a form with all the fields that are required for one adress. That Panel would have an PersonAdress (as an example) Object as Model.

    On the Person, you would have an Collection of Adresses and use a ListView to render and edit each Adress. In the populateItem() function of the ListView you would add one instance of a AdressEditPanel to the item.

    If you need to add an Adress to an person, simply add an entry to the collection of adresses and redisplay the form (I would work with out Ajax first, and once it works do the minimal change required to switch to ajax).

    Hope that helps

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

Sidebar

Related Questions

I have a dynamic form that users can add/delete sets of input fields. I
I have a dynamic form that allow to add many fields dynamically, I Know
I have a form that needs to be dynamic, allowing the user to add
I have a dynamic form that is generated based on javascript. Here's the relevant
I have a dynamic form that is to be displayed using an iPad. This
I have a dynamic form that adds users to the site, made so you
I have a form that is populated with dynamic form elements based on a
I have a form with a stage that has a dynamic number of groups
I have a dynamic form that I've written in rails. I want to be
I have a dynamic form that i am creating in php then i have

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.