You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by armandoxxx <ar...@dropchop.com> on 2011/07/06 22:50:33 UTC

Autocomplete - get model object

Hey guys ... 

Is there any autocomplete component available that would actually store
Beans in models and not ID and or String ... 
I know id is to identify the object, and Text is for displaying it .. but
I've got a situation where backend service returns objects without IDs and I
can't ask the service .. can you please load this object by ID when i need
it ... so storing selected object (somewhere), (hopefully) in a model of
autocomplete component would be great .. but ...from what I searched  all
autocompletes out there return texts (as AutoCompleteTextField) or IDs  (as
ObjectAutoCompleteField) .. none can gice you an object :( ... 

any help would be greatly appreciated !

Regards

Armando

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Autocomplete-get-model-object-tp3649960p3649960.html
Sent from the Users forum 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


Re: Autocomplete - get model object

Posted by armandoxxx <ar...@dropchop.com>.
that's what I did ... 

used choice provider to store all data it has loaded .. and then I iterate
that data when I need it .. and find my object .. 



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Autocomplete-get-model-object-tp3649960p3650147.html
Sent from the Users forum 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


Re: Autocomplete - get model object

Posted by Christian Huber <hu...@butterbrot.org>.
Not sure if am understanding your problem correctly but how about this:

The main problem is that those objects do not have ids associated with 
them because your service just does not use ids for the objects. But as 
far as i understood you have the chance to store the objects you need 
somewhere after you retreived them from your service, right?

So can't you just assign some arbitrary ids to your objects when storing 
them and then use those ids within the autocomplete component?

Of course this would mean that you might end up storing a lot of objects 
in your page/component/etc which might not be feasible..

Am 06.07.2011 23:38, schrieb armandoxxx:
> not working ..
>
> here's the situation .. I have an Object with address data(street, house
> number, city, etc) .. so I use Autocomplete to search for streets meanin ..
> user writes in street name and dropdown shows .. street name and city in
> wich street is in (meaning same streets can exists in different cities) ..
> so when choice is selected only street is written to the text box .. and
> when I wanted to use a converter same street names occur on many choices so
> equals method is not appropriate for checking .. cause user might have
> selected the 3rd choice and converter would get me an object with the first
> one it finds .. and ... NO I cant pust city beside street in text field,
> cause city is in it's own field ;) .. that's why I'm trying to get the
> object autocomplete field and not this text autocomplete field ..
>
> but hey .. thank you for your help ;)
>
> regards
>
> Armando
> PS: cant believe nobody ever needed anything like this :D
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Autocomplete-get-model-object-tp3649960p3650048.html
> Sent from the Users forum 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
>

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


Re: Autocomplete - get model object

Posted by Michael O'Cleirigh <mi...@rivulet.ca>.
Hello,

Have a look at the datatable-autocomplete project in wicketstuff-core:

(maven details: org.wicketstuff:datatable-autocomplete:1.4.17.2)

It allows you to show the autocomplete matches in a datatable which lets 
you show what ever fields of the object you want and have full control 
over how they are rendered.

The datatable-autocomplete-example application indexes java methods from 
the JVM's rt.jar (it depends on the jvm but it should be in the range of 
70-90,000 methods).

Here is how the  AutoCompletingTextField is setup:

https://github.com/wicketstuff/core/blob/core-1.4.x/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/main/java/org/wicketstuff/datatable_autocomplete/web/page/HomePage.java#L215

Run it like this:
MAVEN_OPTS=-Xmx512m -XX:MaxPermSize=128M mvn jetty:run

The example uses a PatriciaTrie as the data source (i.e. we read all of 
the objects into memory and index them for fast prefix searches) but the 
underlying datatable just takes an IDataProvider so it would be possible 
to use other data sources aswell.

Your most recent question on this thread is about how to do stuff on 
selection of a row so in the case of datatable-autocomplete that would 
be done implementing the ITableRowSelection<T> interface.  (the example 
shows this, you update the models for the components impacted by the 
selection and then target.addComponent(field) to get them updated in the 
browser).


Regards,

Mike

> here's the situation .. I have an Object with address data(street, house
> number, city, etc) .. so I use Autocomplete to search for streets meanin ..
> user writes in street name and dropdown shows .. street name and city in
> wich street is in (meaning same streets can exists in different cities) ..
> so when choice is selected only street is written to the text box .. and
> when I wanted to use a converter same street names occur on many choices so
> equals method is not appropriate for checking .. cause user might have
> selected the 3rd choice and converter would get me an object with the first
> one it finds .. and ... NO I cant pust city beside street in text field,
> cause city is in it's own field ;) .. that's why I'm trying to get the
> object autocomplete field and not this text autocomplete field ..
>
> but hey .. thank you for your help ;)
>
> regards
>
> Armando
> PS: cant believe nobody ever needed anything like this :D
>
>
> --
> View this message in context:http://apache-wicket.1842946.n4.nabble.com/Autocomplete-get-model-object-tp3649960p3650048.html
> Sent from the Users forum 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
>


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


Re: Autocomplete - get model object

Posted by armandoxxx <ar...@dropchop.com>.
not working .. 

here's the situation .. I have an Object with address data(street, house
number, city, etc) .. so I use Autocomplete to search for streets meanin ..
user writes in street name and dropdown shows .. street name and city in
wich street is in (meaning same streets can exists in different cities) ..
so when choice is selected only street is written to the text box .. and
when I wanted to use a converter same street names occur on many choices so
equals method is not appropriate for checking .. cause user might have
selected the 3rd choice and converter would get me an object with the first
one it finds .. and ... NO I cant pust city beside street in text field,
cause city is in it's own field ;) .. that's why I'm trying to get the
object autocomplete field and not this text autocomplete field .. 

but hey .. thank you for your help ;) 

regards

Armando
PS: cant believe nobody ever needed anything like this :D


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Autocomplete-get-model-object-tp3649960p3650048.html
Sent from the Users forum 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


Re: Autocomplete - get model object

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

use AutoCompleteTextField with a custom converter:

     getConverter(Class) {
         return new IConverter() {
             convertToObject(input, locale) {
                 iterator = getChoices(input);

                 if (iterator.hasNext()) {
                     choice = iterator.next();
                     if (!iterator.hasNext()) {
                         // unique choice found
                         return choice;
                     }
                 }

                 return null;
             }
         }
     }

The texts have to be unique of course.

Sven

On 07/06/2011 10:50 PM, armandoxxx wrote:
> Hey guys ...
>
> Is there any autocomplete component available that would actually store
> Beans in models and not ID and or String ...
> I know id is to identify the object, and Text is for displaying it .. but
> I've got a situation where backend service returns objects without IDs and I
> can't ask the service .. can you please load this object by ID when i need
> it ... so storing selected object (somewhere), (hopefully) in a model of
> autocomplete component would be great .. but ...from what I searched  all
> autocompletes out there return texts (as AutoCompleteTextField) or IDs  (as
> ObjectAutoCompleteField) .. none can gice you an object :( ...
>
> any help would be greatly appreciated !
>
> Regards
>
> Armando
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Autocomplete-get-model-object-tp3649960p3649960.html
> Sent from the Users forum 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
>


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