RE: Wicket Auto complete text Issue (Correction)
ject) object).getMyStringValue(); } /** * [EMAIL PROTECTED] */ @Override protected final void renderChoice(final Object object, final Response response, final String criteria) { // TODO : write choices to response response.write(getTextValue(object)); } }; final AbstractAutoCompleteTextField autoCompleteField = new AbstractAutoCompleteTextField(id, autoCompleteRenderer){ private static final long serialVersionUID = 1L; /** * [EMAIL PROTECTED] */ @Override protected final List getChoiceList(final String searchTextInput) { // TODO : find my objects somehow return findMyObjectChoices(searchTextInput); } /** * [EMAIL PROTECTED] */ @Override protected final String getChoiceValue(final MyObject choice) { // TODO : get the choice text value (this can even be a common call from the renderer getTextValue if desired) return choice.getMyStringValue(); } }; autoCompleteField.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; /** * [EMAIL PROTECTED] */ @Override protected final void onUpdate(final AjaxRequestTarget target) { // TODO : do something with my object that was selected from the auto-complete choices final MyObject myObjectSelection = autoCompleteField.findChoice(); } }); -Original Message- From: Ricky [mailto:[EMAIL PROTECTED] Sent: Friday, April 25, 2008 3:09 PM To: users@wicket.apache.org Subject: Re: Wicket Auto complete text Issue Hi, I took a look at the solution below, unfortunately the above solution doesn't work because if the model in getTextValue( ) method is set (for the containing panel or any component for that matter) the *last* choice is selected and set as a model instead of the right one. It works only when there is only one selection in the drop down list. Any ideas would be appreciable. Rick On Fri, Apr 25, 2008 at 12:40 PM, Ryan Gravener <[EMAIL PROTECTED]> wrote: > Take a look at > > http://www.nabble.com/1.3%2C-resource-locator-and-properties-to16707905.html#a16708440 > > control+f to help wanted for autocomplete > > On Fri, Apr 25, 2008 at 12:29 PM, Ricky <[EMAIL PROTECTED]> wrote: > > > Hi, > > I am trying to get a model object when an autocomplete selection is > made; > > but model object comes back as a string rather than the model that was > > selected. Is there a way to get the selected Model (Actor) in the example > > below ? > > > > final AutoCompleteTextField actorAutoComplete = new > > AutoCompleteTextField("input-auto-complete-actor-search", new > Model((Actor) > > getModelObject()), new AbstractAutoCompleteRenderer() { > >protected final String getTextValue(final Object object) { > >return object.toString(); > >} > >protected final void renderChoice(final Object object, final > > Response response, final String criteria) { > >response.write(object.toString()); > >} > >}) { > >protected final Iterator getChoices(final String > > searchTextInput) { > >return getCollection().iterator(); > >} > >}; > >actorAutoComplete.add(new AjaxFormSubmitBehavior("onchange") { > >protected final void onSubmit(final AjaxRequestTarget > > target) { > >// MODEL OBJECT RETURNS STRING RATHER THAN AN ACTOR!! > >this.getComponent().getModelObject(); > >} > >}); > >} > >add(actorAutoComplete); > > > > Rick > > > > > > -- > Ryan Gravener > http://wmwm.us/wmwm-date > -- Regards Vyas, Anirudh || ॐ ||
RE: Wicket Auto complete text Issue
@Override protected final void renderChoice(final Object object, final Response response, final String criteria) { // TODO : write choices to response response.write(getTextValue(object)); } }; final AbstractAutoCompleteTextField autoCompleteField = new AbstractAutoCompleteTextField(id, autoCompleteRenderer){ private static final long serialVersionUID = 1L; /** * [EMAIL PROTECTED] */ @Override protected final Iterator getChoiceIterator(final String searchTextInput) { // TODO : find my objects somehow return findMyObjectChoices(searchTextInput).iterator(); } /** * [EMAIL PROTECTED] */ @Override protected final String getChoiceValue(final MyObject choice) { // TODO : get the choice text value (this can even be a common call from the renderer getTextValue if desired) return choice.getMyStringValue(); } }; autoCompleteField.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; /** * [EMAIL PROTECTED] */ @Override protected final void onUpdate(final AjaxRequestTarget target) { // TODO : do something with my object that was selected from the auto-complete choices final MyObject myObjectSelection = autoCompleteField.findChoice(); } }); -Original Message- From: Ricky [mailto:[EMAIL PROTECTED] Sent: Friday, April 25, 2008 3:09 PM To: users@wicket.apache.org Subject: Re: Wicket Auto complete text Issue Hi, I took a look at the solution below, unfortunately the above solution doesn't work because if the model in getTextValue( ) method is set (for the containing panel or any component for that matter) the *last* choice is selected and set as a model instead of the right one. It works only when there is only one selection in the drop down list. Any ideas would be appreciable. Rick On Fri, Apr 25, 2008 at 12:40 PM, Ryan Gravener <[EMAIL PROTECTED]> wrote: > Take a look at > > http://www.nabble.com/1.3%2C-resource-locator-and-properties-to16707905.html#a16708440 > > control+f to help wanted for autocomplete > > On Fri, Apr 25, 2008 at 12:29 PM, Ricky <[EMAIL PROTECTED]> wrote: > > > Hi, > > I am trying to get a model object when an autocomplete selection is > made; > > but model object comes back as a string rather than the model that was > > selected. Is there a way to get the selected Model (Actor) in the example > > below ? > > > > final AutoCompleteTextField actorAutoComplete = new > > AutoCompleteTextField("input-auto-complete-actor-search", new > Model((Actor) > > getModelObject()), new AbstractAutoCompleteRenderer() { > >protected final String getTextValue(final Object object) { > >return object.toString(); > >} > >protected final void renderChoice(final Object object, final > > Response response, final String criteria) { > >response.write(object.toString()); > >} > >}) { > >protected final Iterator getChoices(final String > > searchTextInput) { > >return getCollection().iterator(); > >} > >}; > >actorAutoComplete.add(new AjaxFormSubmitBehavior("onchange") { > >protected final void onSubmit(final AjaxRequestTarget > > target) { > >// MODEL OBJECT RETURNS STRING RATHER THAN AN ACTOR!! > >this.getComponent().getModelObject(); > >} > >}); > >} > >add(actorAutoComplete); > > > > Rick > > > > > > -- > Ryan Gravener > http://wmwm.us/wmwm-date > -- Regards Vyas, Anirudh || ॐ ||
Re: Wicket Auto complete text Issue
Hi, I took a look at the solution below, unfortunately the above solution doesn't work because if the model in getTextValue( ) method is set (for the containing panel or any component for that matter) the *last* choice is selected and set as a model instead of the right one. It works only when there is only one selection in the drop down list. Any ideas would be appreciable. Rick On Fri, Apr 25, 2008 at 12:40 PM, Ryan Gravener <[EMAIL PROTECTED]> wrote: > Take a look at > > http://www.nabble.com/1.3%2C-resource-locator-and-properties-to16707905.html#a16708440 > > control+f to help wanted for autocomplete > > On Fri, Apr 25, 2008 at 12:29 PM, Ricky <[EMAIL PROTECTED]> wrote: > > > Hi, > > I am trying to get a model object when an autocomplete selection is > made; > > but model object comes back as a string rather than the model that was > > selected. Is there a way to get the selected Model (Actor) in the example > > below ? > > > > final AutoCompleteTextField actorAutoComplete = new > > AutoCompleteTextField("input-auto-complete-actor-search", new > Model((Actor) > > getModelObject()), new AbstractAutoCompleteRenderer() { > >protected final String getTextValue(final Object object) { > >return object.toString(); > >} > >protected final void renderChoice(final Object object, final > > Response response, final String criteria) { > >response.write(object.toString()); > >} > >}) { > >protected final Iterator getChoices(final String > > searchTextInput) { > >return getCollection().iterator(); > >} > >}; > >actorAutoComplete.add(new AjaxFormSubmitBehavior("onchange") { > >protected final void onSubmit(final AjaxRequestTarget > > target) { > >// MODEL OBJECT RETURNS STRING RATHER THAN AN ACTOR!! > >this.getComponent().getModelObject(); > >} > >}); > >} > >add(actorAutoComplete); > > > > Rick > > > > > > -- > Ryan Gravener > http://wmwm.us/wmwm-date > -- Regards Vyas, Anirudh || ॐ ||
Re: Wicket Auto complete text Issue
Take a look at http://www.nabble.com/1.3%2C-resource-locator-and-properties-to16707905.html#a16708440 control+f to help wanted for autocomplete On Fri, Apr 25, 2008 at 12:29 PM, Ricky <[EMAIL PROTECTED]> wrote: > Hi, > I am trying to get a model object when an autocomplete selection is made; > but model object comes back as a string rather than the model that was > selected. Is there a way to get the selected Model (Actor) in the example > below ? > > final AutoCompleteTextField actorAutoComplete = new > AutoCompleteTextField("input-auto-complete-actor-search", new Model((Actor) > getModelObject()), new AbstractAutoCompleteRenderer() { >protected final String getTextValue(final Object object) { >return object.toString(); >} >protected final void renderChoice(final Object object, final > Response response, final String criteria) { >response.write(object.toString()); >} >}) { >protected final Iterator getChoices(final String > searchTextInput) { >return getCollection().iterator(); >} >}; >actorAutoComplete.add(new AjaxFormSubmitBehavior("onchange") { >protected final void onSubmit(final AjaxRequestTarget > target) { >// MODEL OBJECT RETURNS STRING RATHER THAN AN ACTOR!! >this.getComponent().getModelObject(); >} >}); >} >add(actorAutoComplete); > > Rick > -- Ryan Gravener http://wmwm.us/wmwm-date