In GWT how do I handle the tab click event?

谁说我不能喝 提交于 2019-12-24 00:51:33

问题


I have a tab layout panel in my ui.xml :

<g:TabLayoutPanel ui:field="tabPanel" barHeight='30'>
  <g:tab>
    <g:header size='7'>tab1</g:header>
    <g:SimplePanel ui:field="tab1" height="100%"/>
  </g:tab>
  <g:tab>
    <g:header size='7'>tab2</g:header>
    <g:SimplePanel ui:field="tab2" height="100%"/>
  </g:tab>
</g:TabLayoutPanel>

how do I handle the event generated on clicking Tab2?


回答1:


Handle the SelectionEvent<Integer> or BeforeSelectionEvent<Integer> depending on your requirements.

e.g:

tabPanel.addSelectionHandler(new SelectionHandler<Integer>() {
  @Override
  public void onSelection(SelectionEvent<Integer> event) {
    if (event.getSelectedItem() == 1) {
      // Code
    }
  }
});

or:

@UiHandler("tabPanel")
void onTabSelection(SelectionEvent<Integer> event) {
  if (event.getSelectedItem() == 1) {
    // Code
  }
}


来源:https://stackoverflow.com/questions/9059214/in-gwt-how-do-i-handle-the-tab-click-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!