Is there an equivalent of smartclient's DMI.call for smartGWT?
Announcement
Collapse
No announcement yet.
X
-
Thank you for your reply. I'll look into it.
I just didn't like the the way I was coding as the following and I haven't been able to figure out how I do it less constrained from the use of Record and RecordList.
Creating Dynamic Tabs...
Code:resultSet=new ResultSet(dsTicket); resultSet.setDisableCacheSync(true); resultSet.addDataArrivedHandler(new DataArrivedHandler(){ @Override public void onDataArrived(DataArrivedEvent dataArrivedEvent) { tabSet=new TabSet(); tabSet.setTabBarAlign(Side.RIGHT); tabSet.setTabBarPosition(Side.TOP); tabSet.setWidth(1024); tabSet.setHeight(768); tabSet.setDestroyPanes(false); tabSet.addTabSelectedHandler(new TabSelectedHandler(){ @Override public void onTabSelected(TabSelectedEvent tabSelectedEvent) { int tabNum=tabSelectedEvent.getTabNum(); String id; if(tabNum>0 && (id=tabSelectedEvent.getTab().getID()).startsWith("T")){ Criteria criteriaTicket=new Criteria(); criteriaTicket.addCriteria("id",id.substring(1)); tabSet.updateTab(tabNum,ticketPanel.buildCanvas(criteriaTicket)); }else tabSet.updateTab(tabNum,communicationPanel.buildCanvas(resultSet.getCriteria())); } }); tabSet.addTabDeselectedHandler(new TabDeselectedHandler(){ @Override public void onTabDeselected(TabDeselectedEvent event) { if(event.getTabNum()>0 && ticketPanel.hasTicket(event.getTab().getID())) ticketPanel.saveForm(); } }); Tab negotiationTab=new Tab("商談"); negotiationTab.setPane(communicationPanel.buildCanvas(resultSet.getCriteria())); tabSet.addTab(negotiationTab); int startRow=dataArrivedEvent.getStartRow(); int endRow=dataArrivedEvent.getEndRow(); ticketPanel.clearTickets(); if(endRow>startRow){ //Is there a better way to do this? for(Record record:resultSet.getRange(startRow,endRow)){ Tab ticketTab=new Tab(); ticketTab.setTitle(record.getAttribute("alias")); ticketTab.setID("T"+record.getAttribute("id")); tabSet.addTab(ticketTab); ticketPanel.addTicket(ticketTab.getID(),record); } } tabSet.selectTab(tabNameToSelect!=null?tabNameToSelect:negotiationTab.getID()); ticketPanel.setTabSet(tabSet); Window detailWindow=buildDetailWindow(tabSet); detailWindow.setTitle(title); detailWindow.show(); detailWindow.centerInPage(); } });
Code:final ListGridField state=new ListGridField("state"); state.addRecordClickHandler(new RecordClickHandler(){ @Override public void onRecordClick(RecordClickEvent recordClickEvent) { final Record recordClicked=recordClickEvent.getRecord(); final int recordNum=recordClickEvent.getRecordNum(); final String id=recordClicked.getAttribute("id"); final Criteria criteria=new Criteria(); criteria.addCriteria("id",id); criteria.addCriteria("fetch",true); dsSupplierForm.fetchData(criteria,new DSCallback(){ @Override public void execute(DSResponse dsResponse, Object o, DSRequest dsRequest) { RecordList recordList=dsResponse.getDataAsRecordList(); Record record=recordList.get(0); String state=record.getAttribute("state"); Date lastOperatedOn=record.getAttributeAsDate("lastOperatedOn"); String errorMessage=record.getAttribute("errorMessage"); if(shouldContinuePolling(state)){ criteria.addCriteria("fetch",false); recordClicked.setAttribute("state",state); recordClicked.setAttribute("lastOperatedOn",lastOperatedOn); recordClicked.setAttribute("errorMessage",errorMessage); supplierListGrid.refreshRow(recordNum); final Timer timer=new Timer(){ @Override public void run() { dsSupplierForm.fetchData(criteria,new DSCallback(){ @Override public void execute(DSResponse dsResponse, Object o, DSRequest dsRequest) { RecordList recordList=dsResponse.getDataAsRecordList(); Record record=recordList.get(0); String state=record.getAttribute("state"); Date lastOperatedOn=record.getAttributeAsDate("lastOperatedOn"); String errorMessage=record.getAttribute("errorMessage"); recordClicked.setAttribute("state",state); recordClicked.setAttribute("lastOperatedOn",lastOperatedOn); recordClicked.setAttribute("errorMessage",errorMessage); supplierListGrid.refreshRow(recordNum); if(state.equals("READY")||state.equals("ERROR_LOGIN")|| state.equals("ERROR_FATAL")){ cancel(); listViewGrid.invalidateCache(); } } }); } }; timer.scheduleRepeating(15000); } } }); } });
Last edited by hanishi; 2 Apr 2010, 06:59.
Comment
Comment