java - 避免在 vaadin 7 中使用已弃用的 vaadin 6 方法

标签 java methods vaadin deprecated

我正在进行从版本 vaadin 6vaadin 7 的项目更新。在vaadin 7版本中很大程度上使用了方法getPaintable()来自类 ApplicationConnection。尽管如此,它在 vaadin 7 中已被弃用。检查 apiofficial tutorial 之后我还没有发现和理解它是通过什么方法或方法组合来替换的。例如,如果我想做:

ComponentConnector paintable = this.client.getPaintable(uidl);

如何仅使用 vaadin 7(未弃用)api 执行上述语句

更新:

答案证明了我的怀疑 ApplicationConnection getConnector(java.lang.String connectorId, int connectorType) 中的方法应该使用它,但仍然缺少 int 类型 connectorType 是什么以及如何获取它。有什么建议吗?

更新2:

答案中建议的替换似乎合理并且可能有效,但我担心的是: 我们应该在 vaadin 7 中普遍使用 UIDL 类吗?我的印象是,不应在 vaadin 7 中调用方法 updateFromUIDL(UIDL uidl, ApplicationConnection client) 。我们如何获取 uidl.getId()uidl.getTag() 。我还认为 uidl.getId() 应该替换为 AbstractConnector getConnectorId() 中的方法。 。我对吗?

最佳答案

更新:

查看已弃用的 getPaintable 方法的实现后,您应该可以将其替换为

ComponentConnector paintable = (ComponentConnector) getConnector(uidl.getId(),
            Integer.parseInt(uidl.getTag()));

但不要忘记这可能只是一个中间步骤。 Vaadin 7 changes the general mechanism for Client-Server interaction of widgets :

The old mechanism with UIDL, paintContent() and changeVariables() is still there for a while to ease migration, but it is recommended to update your components to the new mechanisms, which also tend to result in much cleaner code. Using the old mechanisms requires implementing LegacyComponent.

如果比较Vaadin 6的积分图与 Vaadin 7 ,您将看到总体集成机制发生了怎样的变化。

原始答案:

<强> Vaadin dev ticket: Deprecate ApplicationConnection.getPaintable(UIDL)

描述:

应将 getPaintable(UIDL) 的功能移至 getPaintable(String PaintableId),并应弃用 getPaintable(UIDL)

更改日志:

#8439 已弃用 ApplicationConnect.getPaintable(UIDL) 并添加 getConnector(String id, String ConnectorType)

关于java - 避免在 vaadin 7 中使用已弃用的 vaadin 6 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18763868/

相关文章:

java - 减少 Vaadin Charts 2 中图表内的空白

java - 如何从SD卡打开pdf

java - TransformerConfigurationException : Could not compile stylesheet, 错误 - 无协议(protocol)

java - "String[]::new"是什么意思?

java - 创建具有不同参数的相似子类实例的方法

objective-c - objective-c 和C++中的函数调用

java - 将 spring boot 与 vaadin 结合使用时,js 文件出现 404

java - 在android中使用带有multipart的HttpUrlConnection上传文件的进度非常快

Python:与 OOP 中的类、属性和方法混淆

java - 如何在 Vaadin 8 中设置网格以按自定义比较器排序?