Hi,
I'm quite new in smartgwt and i have some troubles with registering clickHandler on IButton added to panels which I then show and hide depending on what panel I need.
The problem is that only last registered clickHandler works properly.
I uploaded attachement with sample code (I know it's ugly written, but I made it only to show the problem)
Can anyone help me with this problem?
Here's the code:
I'm quite new in smartgwt and i have some troubles with registering clickHandler on IButton added to panels which I then show and hide depending on what panel I need.
The problem is that only last registered clickHandler works properly.
I uploaded attachement with sample code (I know it's ugly written, but I made it only to show the problem)
Can anyone help me with this problem?
Here's the code:
Code:
package com.test.testevent.client; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.ClickListener; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.VerticalPanel; import com.google.gwt.user.client.ui.Widget; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; public class TestClass implements EntryPoint { public void onModuleLoad() { final VerticalPanel vMainPanel = new VerticalPanel(); final HorizontalPanel hMenuPanel = new HorizontalPanel(); final HorizontalPanel hContainerPanel = new HorizontalPanel(); final VerticalPanel vPanel1 = new VerticalPanel(); IButton iButton1 = new IButton(); iButton1.setTitle("button on panel 1"); iButton1.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { Window.alert("Hello world FlexTable 1!!"); } }); vPanel1.add(iButton1); final VerticalPanel vPanel2 = new VerticalPanel(); IButton iButton2 = new IButton(); iButton2.setTitle("button on panel 2"); iButton2.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { Window.alert("Hello world from VerticalPanel 2 !!"); } }); vPanel2.add(iButton2); Button button1 = new Button("panel 1"); Button button2 = new Button("panel 2"); button1.addClickListener(new ClickListener(){ public void onClick(Widget sender) { for(int i = 0;i < hContainerPanel.getWidgetCount(); i++){ hContainerPanel.remove(i); } hContainerPanel.add(vPanel1); } }); button2.addClickListener(new ClickListener(){ public void onClick(Widget sender) { for(int i = 0;i < hContainerPanel.getWidgetCount(); i++){ hContainerPanel.remove(i); } hContainerPanel.add(vPanel2); } }); hMenuPanel.add(button1); hMenuPanel.add(button2); vMainPanel.add(hMenuPanel); vMainPanel.add(hContainerPanel); RootPanel.get().add(vMainPanel); } }
Comment