PDA

View Full Version : root = (ExamplesModel) Registry.get(Examples.MODEL



mwmcmullen
17 May 2010, 1:51 AM
final TreeModel root = (ExamplesModel) Registry.get(Examples.MODEL);
root.set("name", "Ext GWT");


What does this do? You can find it in the TreePanel Reordering example here:

http://www.extjs.com/examples/#reorderingtree

mwmcmullen
18 May 2010, 5:16 AM
Any help at all? Just when I think I've cracked it - I run across this little nugget.

micgala
18 May 2010, 6:06 AM
If you check the gxt source, there are some samples.

There you find this Examples class.
There, the ExamplesModel is created.

It uses then the Registry, which is a gxt helper for storing objects by id.
It used the Id Examples.MODEL ("model")

Then, what that piece of code you asked does is:
It gets the TreeModel from somewhere (Registry).

Then, it creates a property named "name", with value "Ext GWT".

Regards,
Michel.

mwmcmullen
18 May 2010, 6:33 AM
If you check the gxt source, there are some samples.

There you find this Examples class.
There, the ExamplesModel is created.

It uses then the Registry, which is a gxt helper for storing objects by id.
It used the Id Examples.MODEL ("model")

Then, what that piece of code you asked does is:
It gets the TreeModel from somewhere (Registry).

Then, it creates a property named "name", with value "Ext GWT".

Regards,
Michel.

Is there any particular reason why one would want to use the Registry? As far as I can see from the example, there is no other references to the Registry class, therefore I don't understand it's use very much.

Alternatively, I have a TreeStore with a MyClassModel as it's parameter. The Store currently contains everything I want in my tree, is there any way I can instead doing something with this and avoid this Registry class or TreeModel class?

micgala
18 May 2010, 7:10 AM
Well, that is up to you.
If you find a reason on storing a property globally for everywhere in your application, then you can use the Registry.
I never used it.

You don't need to use it at all.
You also don't need to use TreeModel as well.

mwmcmullen
19 May 2010, 5:51 AM
Well, that is up to you.
If you find a reason on storing a property globally for everywhere in your application, then you can use the Registry.
I never used it.

You don't need to use it at all.
You also don't need to use TreeModel as well.

Thanks for that. I got the basic thing working now.

Also, could you please help with my modelling classes? I have:

ABCModelData implements ModelData, Serializable
with the class variables NAME and PROP

ABCModelDataImpl extends ABCModelData
Not entirely too sure what i'm supposed to edit here, so I stole the example code

I want a basic two layer hierarchical structure where you can have many props to a name, and many names to a TreePanel.

When I want to update or create a new layer, do I just instantiate ABCModelDataImpl and pass in my NAME and PROP? If I'm to have many props to a name, do I create a List<String> for prop in the ABCModelData abstract class, or will I have to call a NEW ModelData class instead to store it (i.e. CBAModelData)?

mwmcmullen
20 May 2010, 5:39 AM
Essentially what I'm asking for is a way in which I can have a model which stipulates a Name and Property, however you can have many Properties (which are the same, i.e. Brown, Blue under Colours) to a name.

The only thing I don't know is if I can have a List<String> in a model, or if I need some other form of class then reference it as the 'Property' in the main model.

So I suppose this is a question asking for guidance or if it is possible to have a List<String> as a property?

Perhaps I'm confused. I don't know.