You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by kyc <br...@hku.hk> on 2020/04/28 06:54:37 UTC

The AutoCompleteTextField model callback setObject() not working

I am using wicket 7.14

The following setObject is not called if I select the item from the list
showing from AutoCompleteTextField.
However, it will be called if I type something on the textfield.  I tried
the wicket example with form surrounding the input tag and add
AjaxFormSubmitBehavior which was still not working.  I also tried the blur
event  suggested by some forum which also not work.   I was stuck on the
problem for many days.


	        final IModel<String> model = new IModel<String>()
	        {
	            private String value = null;

	            @Override
	            public String getObject()
	            {
	                return value;
	            }

	            @Override
	            public void setObject(String object)
	            {
	                value = object;
	            }

	            @Override
	            public void detach()
	            {
	            }
	        };


		    final AutoCompleteTextField<String> sampleField = new
AutoCompleteTextField<String>("sample", model, String.class, settings){
					private static final long serialVersionUID = -2129392693264844597L;

   ......
}

--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: The AutoCompleteTextField model callback setObject() not working

Posted by kyc <br...@hku.hk>.
I copied the page to my application to run but still have the problem.  It
may relate to different layout.  But I don't have the WicketExamplePage in
the example.

--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: The AutoCompleteTextField model callback setObject() not working

Posted by kyc <br...@hku.hk>.
Finally I found out the jquery.js is the reason makes the
AutoCompleteTextField not working.

Thanks Martin and Sven.

--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: The AutoCompleteTextField model callback setObject() not working

Posted by Sven Meier <sv...@meiers.net>.
Hi,

you find an example page in wicket-examples 
org.apache.wicket.examples.ajax.builtin.AutoCompletePage that works fine.

Could you try it and check the difference to your code please?

Have fun
Sven


On 28.04.20 10:55, kyc wrote:
> Dear Martin,
>
> Thank you for your answer.
>
> I upgraded to wicket 7.16 to test my program but the result is the same.  I
> checked the browser console / the network console and no error is found.
> (WICKET AJAX DEBUG box is also no error)
>
> Please note the model getObject() call back is called normally.  The item
> can be selected in the popup list and the selected string is shown in the
> textfield.  However, the value will be disappeared after refresh as the
> setObject() is not being called.
>
>
>
> Brenda
>
> --
> Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: The AutoCompleteTextField model callback setObject() not working

Posted by kyc <br...@hku.hk>.
Dear Martin,

Thank you for your answer.

I upgraded to wicket 7.16 to test my program but the result is the same.  I
checked the browser console / the network console and no error is found. 
(WICKET AJAX DEBUG box is also no error)

Please note the model getObject() call back is called normally.  The item
can be selected in the popup list and the selected string is shown in the
textfield.  However, the value will be disappeared after refresh as the
setObject() is not being called.



Brenda

--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: The AutoCompleteTextField model callback setObject() not working

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

On Tue, Apr 28, 2020 at 9:54 AM kyc <br...@hku.hk> wrote:

> I am using wicket 7.14
>

Try to upgrade to 7.16.


>
> The following setObject is not called if I select the item from the list
> showing from AutoCompleteTextField.
> However, it will be called if I type something on the textfield.  I tried
>

If it works when you type something but it doesn't when you select an item
then it looks like a JavaScript error.
Check the browser Dev Tools Console for JS error and Network tab for Ajax
request.


> the wicket example with form surrounding the input tag and add
> AjaxFormSubmitBehavior which was still not working.  I also tried the blur
> event  suggested by some forum which also not work.   I was stuck on the
> problem for many days.
>
>
>                 final IModel<String> model = new IModel<String>()
>                 {
>                     private String value = null;
>
>                     @Override
>                     public String getObject()
>                     {
>                         return value;
>                     }
>
>                     @Override
>                     public void setObject(String object)
>                     {
>                         value = object;
>                     }
>
>                     @Override
>                     public void detach()
>                     {
>                     }
>                 };
>
>
>                     final AutoCompleteTextField<String> sampleField = new
> AutoCompleteTextField<String>("sample", model, String.class, settings){
>                                         private static final long
> serialVersionUID = -2129392693264844597L;
>
>    ......
> }
>
> --
> Sent from:
> http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>