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 6547785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:52:23+00:00 2026-05-25T11:52:23+00:00

First I want to say I saw a site: https://cwiki.apache.org/WICKET/autocomplete-using-a-wicket-model.html Still I have some

  • 0

First I want to say I saw a site:
https://cwiki.apache.org/WICKET/autocomplete-using-a-wicket-model.html

Still I have some problem with implementation.

Context
I have form where want to edit Order from my database.
I want to autocomplete client’s name in form and save it to database.

Problem
I can see suggestions of client names and I can choose which client’s name I’ll use.
Just when I submit form new client won’t be saved in order, in database.
I don’t know how to relate form Model with AutoCompleteTextField input.

Any ideas ?

Pseudo code of my classes:

Order{
  Long id;
  String date;
  Client client;
  Status status;
  ...
}

Client{
  Long id;
  String name;
  String nip;
  String address;
  String postcode;
  String city;
  String phone;
  String mail;
  ...
}

Status{
   Long id;
   String name;
   String value;
}

Edited:
Yes you are right.

My implementation of AbstractAutoCompleteTextField from site:

AbstractAutoCompleteRenderer autoCompleteRenderer = new AbstractAutoCompleteRenderer() {

                protected final String getTextValue(final Object object) {
                    Client client = (Client) object;
                    return client.getName();
                }

                protected final void renderChoice(final Object object, final Response response, final String criteria) {
                    response.write(getTextValue(object));
                }

            };


            // textfield
            AbstractAutoCompleteTextField<Client> name = new AbstractAutoCompleteTextField<Client>("name", new PropertyModel(order, "client"), autoCompleteRenderer) {

                protected final List<Client> getChoiceList(final String input) {
                    return clientService.findByNames(10, 0, input);
                }

                protected final String getChoiceValue(final Client choice) throws Throwable {
                    return choice.getId().toString();
                }
            };
form.add(name);

My form implementation you asked for:

form = new Form("orderForm", new CompoundPropertyModel(order)) {
            @Override
            public void onSubmit() {
                orderService.update((Order) getDefaultModelObject());
                setResponsePage(OrdersPage.class);
                // Form validation successful. Display message showing edited
                // model.
            }
        };

With this code I got: “‘Hurtownia Techniczna “ADA”‘ is not proper Client.” (translated from Polish) in feedback panel.

  • 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-25T11:52:24+00:00Added an answer on May 25, 2026 at 11:52 am

    I think, that’s where things go wrong:
    AbstractAutoCompleteTextField<Client> name = new AbstractAutoCompleteTextField<Client>("name", new PropertyModel(order, "client"), autoCompleteRenderer)

    Rest of the answer edited to reflect the correct use case

    To be specific: You’re creating a PropertyModel of your orders client value, which is a Client-Object and tie it to a TextField. To create a Client-object from the TextField, wicket needs a converter. There are lots of build-in converters but none of them is capable of converting to a custom object. Thus you’ll need to provide the converter by implementing IConverter. Since I don’t know how you store and retrieve your Client-objects I can only show you a generic example, a Locale-Converter used in one of my projects:

    public class LocaleConverter implements IConverter {
    
        private static final long serialVersionUID = 3251433094703013493L;
    
        /* (non-Javadoc)
         * @see org.apache.wicket.util.convert.IConverter#convertToObject(java.lang.String, java.util.Locale)
         */
        @Override
        public Object convertToObject(String value, Locale locale) {
        Locale retValue = null;
        try {
            retValue = LocaleUtils.toLocale(value);
        } catch (IllegalArgumentException e) {
            throw (new ConversionException("" + value + " is not a valid locale.", e));
        }
        return retValue;
    }
    
        /* (non-Javadoc)
         * @see org.apache.wicket.util.convert.IConverter#convertToString(java.lang.Object, java.util.Locale)
         */
        @Override
        public String convertToString(Object value, Locale locale) {
            return value.toString();
        }
    
    }
    

    Then you’ll need to register your new converter to your application. Again, this will be slightly different for you since you’ve got a different converter…

    @Override
    protected IConverterLocator newConverterLocator() {
        ConverterLocator newConverterLocator = (ConverterLocator) super.newConverterLocator();
        newConverterLocator.set(Locale.class, new LocaleConverter());
        return newConverterLocator;
    }
    

    This method needs to be included in your application class.

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

Sidebar

Related Questions

First off, I want to say this site is AWESOME! and it helped me
I want to show first element that is hidden by jquery. my html code
Hi Masters Of Web Development, first I want to say that I did not
First I want to say lots of thanks to Rich seller to solving my
First I want to say that I'm really new to neural networks and I
first I want to say that I hope this doesn't look like I am
First, I want to say that I'm out on deep water here, since I'm
First of all. I want to say that i've acctualy read the other posts
This is my first post, so first of all I want to say a
Say that a page loads and the first thing I want to do is

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.