View Full Version : Different between Singleton Model and Using Registry?

10 May 2012, 11:14 PM
Hi Everyone,
Could some one tell me the different between using Singleton model and Using Registry? Looking like the following example.

//First way
public class SingletonContentPanel extends ContentPanel{
//singleton model instance
private fianl static ContentPanel singletonContentPanel = new SingletonContentPanel();
//other class fields
public ContentPanel getSingletonContentPanel(){
return singletonContentPanel;

private SingletonContentPanel(){
//do some default setings
//such as layout

//other method including onRender method

//using in other container
//singleton model way
public class TestSingleModelContentPanel extends ContentPanel{

public TestContentPanel(){
this.setLayout(new FitLayout());

protected void onRender(Element parent, int index){


//Second way

//using in other container
//using GXT Registry class
public class TestRegistryContentPanel extends ContentPanel{

private ContentPanel subContentPanel;

public TestRegistryContentPanel(){
this.setLayout(new FitLayout());
subContentPanel = new ContentPanel();
//using Registry class, we could retrieve this instance in other place in client side code

protected void onRender(Element parent,int index){
//now we could get the ContentPanel instance and use in here

Do someone what different between them?