从选定的CellList项中获取信息

时间:2014-04-08 08:48:34

标签: java gwt

我正在尝试从cellList中提取modelID。但我无法找到任何方法。目前我将数据放入列表(这里是ModelID),然后将此列表发送到cellList。我认为它在当前状态下工作,因为窗口警告框显示我放入列表的所有项目。但我想从CellList中选择的项目中提取ModelID。这可能吗?如果是,它怎么能实现?

List<String> newData = new ArrayList<String>();
            for (ModelInfo modelInfo : getModelInfoList())
            {
                int modelID = modelInfo.getModelID();
                int modelCreator = modelInfo.getModelCreator();
                String modelName = modelInfo.getModelName();
                String modelCreationDate = modelInfo.getModelCreationDate();
                newData.add("ModelID:" + modelID + "Creator: " + modelCreator + " Diagram name: " + modelName + " Diagram creation date " + modelCreationDate);
            }

选择处理程序

 // Add a selection model to handle user selection.
    final SingleSelectionModel<String> selectionModel = new SingleSelectionModel<String>();
    cellList.setSelectionModel(selectionModel);

    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
      public void onSelectionChange(SelectionChangeEvent event) {
        String selected = selectionModel.getSelectedObject();
        if (selected != null) {
          //Extract MODELID TODO
          Window.alert("You selected: " + selected);
        }
      }
    });

祝你好运, Kerrai

0 个答案:

没有答案