Hi,

I think that you're missing an instance variable "test" of type TestBean
inside your component. It's the variable that us used for the Property Model

Regards,
Yaya Ndongo

On Oct 27, 2016 16:16, "ganea iulia" <superbiss...@gmail.com> wrote:

> Hi,
>
> Please help me with following issue:
>
>
> I'm using wicket 7.
>
> I have a form with a AutocompleteTextField.
>
> The autocompletion works ok until I need to submit the form, when I get
> following message:
>
>
>    - The value of 'test' is not a valid TestBean.
>
>
> Here is my component:
>
> IAutoCompleteRenderer<TestBean> testRenderer = new
> IAutoCompleteRenderer<TestBean>() {
>
> private static final long serialVersionUID = -7038764178796856779L;
>
> @Override
> public void render(TestBean object, Response response, String criteria) {
> response.write((new StringBuilder()).append("<li
> idvalue=\"").append(object.getCod).append("\"
> textvalue=\"").append(object.getUniqueName()).append("\">").toString());
> response.write(object.getUniqueName());
> response.write("</li>");
> }
>
> @Override
> public void renderFooter(Response response, int ItemId) {
> response.write("</ul>");
>
> }
>
> @Override
> public void renderHeader(Response response) {
> response.write("<ul>");
>
> }
>
> };
> AutoCompleteTextField<TestBean> txt = new
> AutoCompleteTextField<TestBean>("test", new PropertyModel<TestBean>(this,
> "myTestBean"), TestBean.class,
> testRenderer, (new AutoCompleteSettings().setPreselect(true))) {
>
> private static final long serialVersionUID = 1L;
> private List<TestBean> TestList = null;
>
> @Override
> protected Iterator<TestBean> getChoices(String input) {
> if (Strings.isEmpty(input)) {
> return Collections.emptyIterator();
> } else {
> if (input.length() > 0) {
> if (TestList == null || TestList.isEmpty() || !input.substring(0,
> 1).toUpperCase().equals(TestList.get(0).getUniqueName().substring(0,
> 1).toUpperCase())) {
> TestList =
> SpringCtx.getAppDB(TestBeanDao.class).selectAproxByUniqueName(input.
> substring(0,
> 1));
> }
> }
> }
>
> int autoCompleteFieldNumChoices = 20;
>
> List<TestBean> choices = new
> ArrayList<TestBean>(autoCompleteFieldNumChoices);
>
> for (int i = 0; i < TestList.size(); i++) {
> final TestBean testBean = TestList.get(i);
> final String testName = testBean.getUniqueName();
>
> if (testName.toUpperCase().startsWith(input.toUpperCase())) {
> choices.add(testBean);
> if (choices.size() == autoCompleteFieldNumChoices) {
> break;
> }
> }
> }
> return choices.iterator();
> }
> };
>

Reply via email to