PDA

View Full Version : Custom Field, how to start?



lmivan
14 Nov 2009, 12:40 AM
Hello all,

I want to create a new custom Field to display something like that: http://raibledesigns.com/rd/entry/creating_a_facebook_style_autocomplete.

In a previous version of my software I adapted and converted the code of the previous example to integrate it with my code. You can check a demo at http://mufly.dyndns.org:8080/, then click on New button and in the field "Tag" you can see the behaviour. Now that I'm migrating all my GWT code to GXT 2.0.1 I want to create a custom field for the component to use it in a custom BindingForm.

I think that I must extend from Field, but I am a little bit lost because I have no idea what methods I must to implement in my custom Field class. I have examined the code of the Field.class but it is complicated for me.

Could you please "guide me to the light" and say to me which methods should I be care of?

Thanks a lot and regards, Iván.

Arno.Nyhm
16 Nov 2009, 8:12 AM
pls: post your current implementation of this widget.

lmivan
16 Nov 2009, 8:18 AM
pls: post your current implementation of this widget.

My current implementation does not differs a lot from the implementation in the linked blog. I have added some methods to set by code the Tags read from the database and for clear the component. You can see the code here (TagAutoSuggest.java):

http://code.google.com/p/mufly/source/browse/tags/Mufly-0.2.4/src/net/mufly/client/ui/tag/

and its support/complementary classes in the package net.mufly.client.ui.tag.autoSuggest.

Anyway, i think this is not the problem because this component is a textfiled with "vitamins" :-P.

Thanks a lot.

Regards, Iván.

Arno.Nyhm
16 Nov 2009, 8:19 AM
some more ideas about suggestbox - but no solutions :-(
http://www.extjs.com/forum/showthread.php?t=67294&highlight=suggestbox
http://www.extjs.com/forum/showthread.php?t=63808&highlight=suggestbox

Arno.Nyhm
16 Nov 2009, 8:24 AM
there are some ExtJS solutions - maybe you get there an idea how to make it in GXT:

http://www.extjs.com/forum/showthread.php?t=33794

lmivan
17 Nov 2009, 6:45 AM
Thanks for your replies.

Maybe I haven't explained very well. I don't want to create this suggestBox in GXT. I want to reuse the code and the only thing I want to do is extend from Field. I mean, in a FormBinding I add FieldString, FieldDate,... set the label and they are displayed like this example (GridStore binding): http://www.extjs.com/examples/explorer.html#gridstorebinding

I want to reuse my code in order to add to the FormBinding a new "SuggestField" with the behaviour already implemented, BUT I have examined the class Field and I don't know which methods I must override and extend. This is my real question.

Thanks again for your time.

Regards, Iván.

Arno.Nyhm
17 Nov 2009, 8:48 AM
mhh - i dont have a idea.

maybe the AdapterField is also interesting for you

use it or extend it for your field


BTW: but look at this advice from svn:


When doing custom fields, you should not extend Adapterfield. That is the wrong class for this approach. You should extend directly Field.http://www.extjs.com/forum/showthread.php?p=404738#post404738

and also here why this is not a good solution.
http://www.extjs.com/forum/showthread.php?p=330422

lmivan
18 Nov 2009, 12:22 AM
Thanks for your time. I'll try to analyze with more detail the Field.class to subclass from it.

Regards, Iván.

Arno.Nyhm
18 Nov 2009, 8:24 AM
if you are successful pls post your code here :-)

lmivan
22 Nov 2009, 6:31 AM
I quit!. It is impossible for me convert the code or analize the Field in order to extend it. I'm very lost. I'm going to change the component and find another that fits in my requirements.

Thanks a lot!.

Regards, Iván.

oddy
29 Nov 2009, 5:13 PM
I quit!. It is impossible for me convert the code or analize the Field in order to extend it. I'm very lost. I'm going to change the component and find another that fits in my requirements.

Thanks a lot!.

Regards, Iván.
There is nothing special about creating custom fields. Start with exploring subclasses of the Field class. Pay attention to the defaultAutoCreate property and override onRender, getValue, setValue and reset methods. And don't forget to clear all your custom objects in onDestroy method.

lmivan
30 Nov 2009, 2:46 AM
There is nothing special about creating custom fields. Start with exploring subclasses of the Field class. Pay attention to the defaultAutoCreate property and override onRender, getValue, setValue and reset methods. And don't forget to clear all your custom objects in onDestroy method.

Ok, thanks a lot. I'm going to try it... :-D