本文介绍了GWT - 刷新标签面板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带3个标签的tabpanel。其中一个选项卡有一个表格,该表格使用数据库中的数据绘制表格。但是,如果输入新数据,在选择标签之后,我必须刷新浏览器页面才能看到更新。
我向tabpanel添加了以下选择处理程序:
tabpanel.addSelectionHandler(new SelectionHandler< Integer>( )
{
public void onSelection(SelectionEvent< Integer> event)
{
int tabId = event.getSelectedItem();
Widget tabWidget = tabpanel.getWidget(tabId );
if(tabWidget!= null)
{
//假设要刷新的代码会在这里...
}
}
} );
我该怎么做,以便当某个选项卡被选中时,该选项卡会刷新?
非常感谢您的帮助。
只需将您的数据访问代码放入注释区域即可。所以例如 int tabId = event.getSelectedItem();
// PSEUDO CODE
data = AsyncCallback.getData()
tabPanel.setWidget(tabId,new Widget(data)); // PSEUDO CODE
I have a tabpanel with 3 tabs. One of the tabs has a table which draws a table with data from the database. But if new data is entered, after I select the tab I have to refresh the browser page to see the update.I've added the following selection handler to the tabpanel:
tabpanel.addSelectionHandler(new SelectionHandler<Integer>()
{
public void onSelection(SelectionEvent<Integer> event)
{
int tabId = event.getSelectedItem();
Widget tabWidget = tabpanel.getWidget(tabId);
if (tabWidget != null)
{
//assumming that code to refresh will go here...
}
}
});
What can I do so that when a certain tab is selected then that tab will refresh?
Thanks so much in advance.
解决方案
What you have done is correct. Just put your data access code in the commented area. So for example
int tabId = event.getSelectedItem();
// PSEUDO CODE
data = AsyncCallback.getData()
tabPanel.setWidget(tabId, new Widget(data)); // PSEUDO CODE
这篇关于GWT - 刷新标签面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!