简体   繁体   中英

GWT , Remove History token

I have a GWT project, using Activities and Places. My problem is with history token.

Pattern of my token :

#/{key 1}/{value 1}/{key 2}/{value 2}  

Value 1 must be Number

Value 2 must be Number

the valid token is :

#/view/1/date/123123123123

I decided to validate the token and then the problem appears.

In example, if the user change manually the token :

#/view/qqweqweqwedate/date/123123123123

In this case Value 1 is not a Number. I catch this exception and fix the token with the default value. The problem is that the invalid token is in the history and when I click "Back" button on the browser it appears again .

Could someone tell me how to remove the invalid token from the history or don't allow it to be written in the history ?

Once you set a new hash (new token in GWT), it is stored in the browser history stack.

You cannot remove tokens from the browser history, so the most you can do is to handle this event with code. I mean, when the user clicks back, the malformed token will be visited, and you can be notified doing whatever you want: to fix the token again and bring the user to the correct token, or to call History.back() so as the user is sent to the previous token.

The problem I see is whether to know when the user comes from the already fixed token screen to send it back.

In theory, you could use event.oldURL and event.newURL using javascript, but those attributes are not exposed in GWT, so you should implement them by hand using jsni.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM