You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by m_salman <mo...@yahoo.com> on 2008/11/10 00:01:05 UTC

AutoCompleteTextField: Making Wicket call getChoices method on 'onClick' event

Hi,

I need some help with the AutoCompleteTextField.  I would like it to show
the choice list when some one clicks in the field not just when the user
type a letter or two.  I find that, atleast in my case, when I click on the
field getChoices method is not called.  

I have tried some thing such as adding 'onClick' ajax event. But it does not
seem to work.

Below is my code and I will gretaly appreciate any help.

Thanks,

-Mohammad


	private void addAutoCompleteTextField(
		final PresenterParameterText presenter)
	{
		AutoCompleteSettings autoCompleteSettings = new AutoCompleteSettings();
		autoCompleteSettings.setShowListOnEmptyInput(true);
		
		
		final AutoCompleteTextField<String> textField 
				= new AutoCompleteTextField<String>(
						"value", 
						new PropertyModel<String>(presenter, "value"),
						autoCompleteSettings)
		{
				@Override
				protected Iterator<String> getChoices(String input)
				{
					List<String> list;
					try
					{
						//list = ..........						                                                   
//return list.iterator();						
					}
					catch (Throwable t)
					{
						getRequestCycle().setRedirect(true); 
						throw new RestartResponseException(new ErrorPage(t)); 									
					}					
				}				
		};
		
		add(textField);
		
		textField.setOutputMarkupPlaceholderTag(true);
		textField.add(	new AjaxEventBehavior("onclick") 
		{
            	                    @Override
                                 protected void onEvent(AjaxRequestTarget
target) 
            	                    {
            		             presenter.setValue("");
            		             target.addComponent(textField);

                                       // How do I fire the event to call
the textFields getChoices method ???
            	                    }
                           });
		
		
	}
-- 
View this message in context: http://www.nabble.com/AutoCompleteTextField%3A-Making-Wicket-call-getChoices-method-on-%27onClick%27-event-tp20411983p20411983.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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