Add the Appropriate States to Browser's History

Your application has to decide what are the appropriate states to add to the browser's history. For example, in a multi-step operation, each state is a good candidate to add to browser's history, such that users can jump over these states or bookmark them for later use.

Once you decide when to add a state to the browser's history, you can simply invoke the setBookmark method of the org.zkoss.zk.ui.Desktop interface when appropriate. Adding a state to the browser's history is called bookmarking. Notice that it is not the bookmarks that users add to the browser (aka., My Favorites in Internet Explorer).

Tip: You might call the adding state in the server as the server's bookmarks in contrast with the browser's bookmarks.

For example, assume you want to bookmark the state when the Next button is clicked, then you do as follows.

<button label="Next" onClick="desktop.setBookmark(&quot;Step-2&quot;)"/>

If you look carefully at the URL, you will find ZK appends #Step-2 to the URL.

If you press the BACK button, you will see as follows.