1. #1
    Sencha User
    Join Date
    Oct 2010
    Posts
    129
    Vote Rating
    0
    blay is on a distinguished road

      0  

    Default 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

  2. #2
    Sencha User
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    Isnt GWT.runAsync what you are looking for?

  3. #3
    Sencha User
    Join Date
    Oct 2010
    Posts
    129
    Vote Rating
    0
    blay is on a distinguished road

      0  

    Default


    Just another question

    is there any method for deleting a widget and removing it from memory?

  4. #4
    Sencha User
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    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.

  5. #5
    Sencha User
    Join Date
    Oct 2010
    Posts
    129
    Vote Rating
    0
    blay is on a distinguished road

      0  

    Default


    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...

  6. #6
    Sencha User
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    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.

  7. #7
    Sencha User
    Join Date
    Oct 2010
    Posts
    129
    Vote Rating
    0
    blay is on a distinguished road

      0  

    Default


    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

  8. #8
    Sencha User
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    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.

  9. #9
    Sencha User
    Join Date
    Oct 2010
    Posts
    129
    Vote Rating
    0
    blay is on a distinguished road

      0  

    Default


    Ok, that's it, thanks sven

Similar Threads

  1. Local state management vs Server session management
    By J@y in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 6 Aug 2009, 3:14 PM
  2. Replies: 4
    Last Post: 30 Jun 2009, 3:45 AM
  3. Menu Widget
    By rmanchu in forum Community Discussion
    Replies: 2
    Last Post: 4 May 2008, 8:02 PM
  4. YUI Menu widget & boxWrap()
    By end-user in forum Ext 1.x: Help & Discussion
    Replies: 0
    Last Post: 10 Oct 2007, 5:21 AM
  5. Screencast Ext Menu Widget
    By TommyMaintz in forum Community Discussion
    Replies: 5
    Last Post: 12 Mar 2007, 5:46 AM

Thread Participants: 1