But when I create the menu I have to write the behaviour of each widget (when hide/show etc), so I have to instance them. I know what you mean by using Singleton but with that approach I can specify the behaviour, because they're not created yet.
What I want is a way to create a menu with widgets associated to it and work like a standard web app with html pages, showing the widget requested in the menu and hiding the other ones. But the problem is that I´d like not having to instance all widgets at the beggining, but I don´t see any other way to give them the correct behaviour. Any other help? Thx On 27 oct, 13:56, Jeff Schwartz <jefftschwa...@gmail.com> wrote: > You can do it either way depending upon your requirements. If you want your > widgets to maintain their state use singletons with a POJO getter factory > method which is easy to implement. For example, let's say you have a > composite widget YourWidgetClass. Just add the following code to it. > > private static YourWidgetClass instance = null; > public static YourWidgetClass getInstance(){ > if(null == instance){ > instance = new YourWidgetClass(); // or a non default constructor > if you require > } > return instance; > > } > > private YourWidgetClass(){} // make all your constructors private > > Now anywhere you need to reference YourWidgetClass you do so by calling > YourWidgetClass.getInstance() instead of its constructor. Because > YourWidgetClass is now a singleton whatever state it maintains will always > be available. > > Jeff > > > > On Wed, Oct 27, 2010 at 7:05 AM, Pablo G.F <blay...@gmail.com> wrote: > > I´m a newbie to GWT. > > My scenario is: > > > My project is a web application. My idea is using a top menubar, with > > some menuItems. Click on one of this menuItems, will "open" a widget > > like a search form with a grid to show results, another kind of form, > > etc. Like if a regular web page with links in a menu bar on top. > > I have to main questions: > > > a) In case of implementing this with pure GWT, the menu and the pages > > (by pages in this case I mean , widgets composite by forms, grids , > > etc ). Have I to create all widgets and show/hide them depending on > > the menuItem clicked, or can I create / delete dinamically? Because > > creating them it´s obviously inefficient. > > > b) I think it would be easier if the menu loads .html pages with GWT > > widgets on them. So the widget loads when the html page loads. But I > > don´t know if this is possible and how to do it with GWT (I mean, the > > menubar made in GWT, acting like a regular HTML menu, like using > > links). > > > Sorry if it´s not very clear what I´m trying to say, (because I know > > it isnt), but I don´t know exaclty where to start or what to do > > exaclty. > > > In resume, i want a web application with a menu where to select what > > part of my application to show. > > > Thanks, and sorry for my English ;) > > > -- > > You received this message because you are subscribed to the Google Groups > > "Google Web Toolkit" group. > > To post to this group, send email to google-web-tool...@googlegroups.com. > > To unsubscribe from this group, send email to > > google-web-toolkit+unsubscr...@googlegroups.com<google-web-toolkit%2bunsubscr...@googlegroups.com> > > . > > For more options, visit this group at > >http://groups.google.com/group/google-web-toolkit?hl=en. > > -- > Jeff -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.