-
28 Oct 2010 2:59 AM #1
Menu and widget management
Menu and widget management
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.
For example, look at this forum page, there is a menu bar at top with sections : Home, Products, Support, etc, clicking on each one will send you to the appropiate page. I wanna "use" the widget I want (the one I click on the menu) (they will have a form + grid appareance, or a form, big grid, etc using all the window size like if a html page or so).
This is the approach that came first to my mind, but I´m open to other solutions for my target.
Thx
-
28 Oct 2010 3:04 AM #2
Isnt GWT.runAsync what you are looking for?
-
28 Oct 2010 3:17 AM #3
Just another question
is there any method for deleting a widget and removing it from memory?
-
28 Oct 2010 3:18 AM #4
What do you mean? When a widget gets removed from its parent. It gets detached and so clears all listeners. The only thing that remains is your reference inside your code. You will need to clear that out too.
-
28 Oct 2010 3:37 AM #5
Suppouse I have two classes which extend LayoutContainer.
Then I have a ContentPanel with a MenuBar as the top component. I instance both widgets (the classes of first paragraph) and add them to the contentPanel, and by clicking on the items of the menuBar, I choose which widget to show (hiding the other one).
In the case I have a lot of widgets my approach at first would be the same, instance them, attach them and add behaviour to the menuBar (hide / show thing). But as they´re a lot of widgets I don´t know if it would result a slow application , so what Ithoght was that It would be great if there was a way to delete the widget so i instance it when it´s needed.
A pseudocode:
Widget1 w1 = null;
Widget2 w2= null;
ContentPanel cp = new ContentPanel();
cp.add(w1);
cp.add(w2);
menuBar bar = new MenuBar();
create item a;
when click a{
if (w1!=null)
w1.delete;
if (w2!=null)
w2.delete;
w2 = new Widget2();
w2.show();
}
when click b{
if (w1!=null)
w1.delete;
if (w2!=null)
w2.delete;
w1 = new Widget1();
w1.show();
}
menuBar.add(item a)
menuBar.add(item b)
cp.setTopComponent(menubar)
So, it only has instanced the widget which will show...it´s possible?
I thought about "deleting" but maybe just deattaching it ...or even changing the reference w1 and w2 to null the java garbage collector will free it...
-
28 Oct 2010 3:40 AM #6
Yes that is possible. Initiate your widget in your listener of your MenuItem and add it to your ContentPanel. First remove all other from the ContentPanel. This way there is only one widget added to the contentpanel at any time.
-
28 Oct 2010 3:45 AM #7
Sorry for so many questions about the same...
but what I want to know is by removing all widgets from its parent , they will be "deleted" or will be in memory (so suppouse i click 10000 times in an item, it will remove all items 10000 times and instance a widget 10000). will be they in memory? I don´t know if you understand exactly what im asking.
thx
-
28 Oct 2010 3:46 AM #8
As long as your code does not reference it anymore (null them out), and you remove them with contentPanel.removeAll() or contentPanel.remove(..) the browser garbage collector should take care of it.
-
28 Oct 2010 3:55 AM #9
Similar Threads
-
Local state management vs Server session management
By J@y in forum Ext 3.x: Help & DiscussionReplies: 2Last Post: 6 Aug 2009, 3:14 PM -
Errors in : gxt-2.0-M3.jar!/com/extjs/gxt/ui/client/widget/menu/Menu.java
By jamelboubaker in forum Ext GWT: DiscussionReplies: 4Last Post: 30 Jun 2009, 3:45 AM -
Menu Widget
By rmanchu in forum Community DiscussionReplies: 2Last Post: 4 May 2008, 8:02 PM -
YUI Menu widget & boxWrap()
By end-user in forum Ext 1.x: Help & DiscussionReplies: 0Last Post: 10 Oct 2007, 5:21 AM -
Screencast Ext Menu Widget
By TommyMaintz in forum Community DiscussionReplies: 5Last Post: 12 Mar 2007, 5:46 AM


Reply With Quote