[英]how to change browser history without going to place/ starting activity (gwt)
in my app i have a relative complex activity/place. 在我的应用程序中,我有一个相对复杂的活动/地方。 Resolving the state (from history token to model) on start of activity causes some server interactions. 在活动开始时解析状态(从历史令牌到模型)会导致一些服务器交互。 On user interactions the activity only updates the necessary parts of the model and therefore safes some server interactions - the activity/model has an inner state. 在用户交互中,活动仅更新模型的必要部分,因此保护一些服务器交互 - 活动/模型具有内部状态。
Is there a way to reflect the state in browser history without (re)starting the activity? 有没有办法在没有(重新)启动活动的情况下反映浏览器历史记录中的状态? ( History.newItem(token)
also causes start of activity) ( History.newItem(token)
也会导致活动开始)
UPDATE Chris' solution "nearly" works but another problem rose: in my ui i have a reset-button (a link to the place with empty token). 更新克里斯的解决方案“几乎”有效,但另一个问题上升了:在我的ui中我有一个重置按钮(指向空标记的地方的链接)。 If i click around the ui the token is updated fine but now the reset button doesn't work. 如果我点击ui周围令牌已更新,但现在重置按钮不起作用。 gwt thinks it is in the same place and so it ignores the reset click. gwt认为它在同一个地方,所以它忽略了重置点击。 Before this the problem was nearly the same: the token and place didn't change and so the reset button didn't work either. 在此之前问题几乎相同:令牌和地点没有改变,因此重置按钮也不起作用。 GWT logs this as "Asked to return to the same place" GWT记录为“被要求返回同一个地方”
So is there a way to let gwt restart the activity regardless of place equivalence? 那么有没有办法让gwt重新启动活动而不管地点等价?
Go to a new place, but have your ActivityMapper
return the same activity instance. 转到新位置,但让ActivityMapper
返回相同的活动实例。 That way, the activity is not restarted. 这样,活动就不会重新启动。
You have to find a mean of updating the activity when the place changes from some other mean though (eg browser history). 当地点从其他方面改变时,你必须找到更新活动的方法(例如浏览器历史记录)。 See GWT MVP updating Activity state on Place change for instance. 例如,请参阅GWT MVP更新Place更改的活动状态 。
There is a semi-solution, and although I don't want to recommend it , I'd like to add it here - just to warn against the drawbacks of this solution: 有一个半解决方案,虽然我不想推荐它 ,但我想在这里添加它 - 只是为了警告这个解决方案的缺点:
You could add tokens to the History without firing an event by calling History.newItem(token, false)
. 您可以通过调用History.newItem(token, false)
将标记添加到历史记录而不触发事件。
This is a semi-solution, because: 这是一个半解决方案,因为:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.