Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    DMI.call for smartGWT

    Is there an equivalent of smartclient's DMI.call for smartGWT?

    #2
    Consider a DataSource operation of type "custom" instead - this supports DMI and is often more convenient. See DataSource.performCustomOperation() in the latest nightlies.

    Comment


      #3
      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();
                  }
              });
      or Checking some kind of state...
      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


        #4
        Hi Isomorphic,

        If we have server-side operations that don't map cleanly to any datasource how would you suggest they're catered for?

        Reading the SmartClient docs, RPC DMI seems like the perfect fit for the use case I'm thinking of.

        Comment


          #5
          Almost anything that fits as an RPC DMI works as a DataSource "fetch" operation. So long as you are calling these operations programmatically, you do nt neqed to conform closely to the operationType (eg no need for a primary key or correct return values for update/add).

          Comment

          Working...
          X