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<Actor> 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