根据我的观察,历史记录用于具有多个 AJAX 交互的单个 html 页面。它只是将每个状态分配给一个特定的标记来区分(或标记)它们。而对于 Places,它用于不同的 html 页面。它将每个 html 页面分配给一个字符串标记。
他们之间有什么关系吗?我理解正确吗?
最佳答案
如 official documentation 中所述:
A place is a Java object representing a particular state of the UI. A Place can be converted to and from a URL history token (see GWT’s History mechanism) by defining a PlaceTokenizer for each Place, and GWT’s PlaceHistoryHandler automatically updates the browser URL corresponding to each Place in your app.
因此,您可以想到比历史更高层次的地点和事件。例如,您可以通过使用 History.newItem("token")
更改历史记录 token 来转到应用程序中的新“位置”。但您可以使用 PlaceController
执行相同操作:placeController.goTo(new TokenPlace())
。 TokenPlace
与历史 token token
显式关联,在到达此位置时实例化一个 Activity
类,等等。在幕后,History.newItem("token")
仍会被调用,但您不必担心手动管理历史记录 token 。作为奖励,您的应用程序可能会变得更少耦合,因为现在 Activity1
不必了解有关 Activity2
的任何信息 - Activity1
只是触发搬到新地方。它不关心它与哪个事件相关。
关于ajax - GWT 中的历史和地点之间有什么区别/关系?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28201843/