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

      0  

    Default ContentLayout not showing

    ContentLayout not showing


    Hello:

    I have this class

    Code:
    public class ButtonExample extends LayoutContainer{
    
        public void onRender(Element parent, int index){
            super.onRender(parent, index);
            
            Button button= new Button("CLICK ME!",new SelectionListener<ButtonEvent>(){  
                public void componentSelected(ButtonEvent ce) {  
                    MessageBox box = new MessageBox();
                    box.setButtons(MessageBox.OKCANCEL);
                    box.setTitle("Botón pulsado");
                    box.show();
                }
            });
            
            add(button);
        }
    }
    Then I have this other class:

    Code:
    public class MainMenu extends Viewport{
    
        private ButtonExample buttonExample = null;
        
        @Override
        protected void onRender(com.google.gwt.user.client.Element parent, int index) {
            super.onRender(parent, index);
        
            //String xml = MenuConstants.stringXML;
            
            final MenuBar bar = new MenuBar();
            final ContentPanel mainPanel = new ContentPanel();
            Menu menu;
            MenuItem menuItem;
            MenuBarItem menuBarItem;
            
            menu = new Menu();
            menuItem = new MenuItem("Alta");   
            menuItem.addSelectionListener(new SelectionListener<MenuEvent>(){
    
                @Override
                public void componentSelected(MenuEvent ce) {
                
                    //setReferencesNull();
                    buttonExample = new ButtonExample();
                    mainPanel.add(buttonExample);
                }
                
            });
            
            menu.add(menuItem);
    
            menuBarItem = new MenuBarItem("Empresas Grupo",menu);
            bar.add(menuBarItem);
            
    mainPanel.setTopComponent(bar);
            add(mainPanel);
            
        }
    If I add the buttonExample in the onRender body, it works, and a button appears. But if I add it on the SelectionListener, it doesn´t appear. I´m missing something, any help?

  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


    Code:
     menuItem.addSelectionListener(new SelectionListener<MenuEvent>(){
    
                @Override
                public void componentSelected(MenuEvent ce) {
                
                    //setReferencesNull();
                    buttonExample = new ButtonExample();
                    mainPanel.add(buttonExample);
    mainPanel.layout();
                }
                
            });
    Everytime you fnished with modifying a container, you need to call layout.

Similar Threads

  1. Container Not Showing Anything
    By darren in forum Ext 3.x: Help & Discussion
    Replies: 5
    Last Post: 28 Mar 2010, 11:26 AM
  2. Radiobutton not showing
    By vivekajm in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 7 May 2009, 9:01 PM
  3. LoadMask not showing
    By adinata in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 8 Apr 2009, 4:34 PM
  4. Quicktips not showing
    By Eisstern in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 13 Aug 2008, 3:11 AM
  5. Actionbar not showing
    By rune carlsen in forum Ext.nd for Notes/Domino
    Replies: 3
    Last Post: 18 Feb 2008, 1:55 PM

Thread Participants: 1