Remember current tab (zk tab box) before navigation

asked 2021-04-12 21:41:12 +0800

RomanZK gravatar image RomanZK
1 1

Let's say I am working on a view (i.e a zul page). On this view I am using tab box ui component. I am currently working on the third tab. e.g. the 3rd tab (counting from the left. horizontally). Then I trigger navigation to load another view. In this view, I have a back button to navigate back to previous view. Upon loading previous view I noticed that the tab box always defaults to displaying the first tab.

I will like zk to remember the last tab I worked on before navigation. i.e. if I was working on the 3rd tab, I want the zul page to load with the tab box selecting the 3rd tab not the first.

How can I do this ?

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2021-04-16 01:09:15 +0800

RomanZK gravatar image RomanZK
1 1

I intend to perform the above using mvvm approach.

link publish delete flag offensive edit

answered 2021-04-19 10:08:58 +0800

cor3000 gravatar image cor3000
5868 2 7
ZK Team

updated 2021-04-19 10:09:51 +0800

MVC / MVVM don't make a difference in this case. From what I am reading you are working in a multi page application so that the browser back button will load the previous URL. This leaves mainly 2 options to store information to recover the previous state inside the URL:

use a bookmark (url fragment) via desktop.setBookmark and read the bookmark information in the onBookmarkChange-Event after the user went back

or use desktop.pushHistoryState or desktop.replaceHistoryState in order to set a URL parameter to the current URL e.g. 'somepage.zul?activeTab=3'. When the user goes back you can read the URL parameter with @QueryParam("activeTab")

I haven't tested this yet so in case of problems please post a runnable zkfiddle so that anyone can have a look to fix implementation problems.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

1 follower



Asked: 2021-04-12 21:41:12 +0800

Seen: 9 times

Last updated: Apr 19

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More