GWT - how to map website hierarchical structure to actions / places / extensions?

I am new to GWT here and my English is not so good, so please excuse me. I need to create a website using GWT. The website has a hierarchical structure: the main global signature and a couple of buttons. Each button opens a new part of the application, which has its own tabs. each of the sub-tabs allows navigation. eg:

Basic form

→ problems with the application

---> preferences ---> create something ---> edit something

→ administration

---> user management -> policies

Now, I want to understand what is the best option for using GWT. I thought of two options: 1. will be at the main entry point. in our launch function, we will create an ActivityManager for each submenu (= sub tab = child). each submenu will create activity managers for each of its submenus, etc. we will set the display for each activity manager and the event of the place of the fire change.

the problem is that I need to manage the places (all places should go to the main activity, which should take their parameters and delegate them to sub-items, etc.) otherwise, when the user copies and pastes the URL, this will result to start only child activity, and parent activity will not be initialized.

  • I can create an OOP hierarchy for widgets, so there will be activity for each sheet in the hierarchy structure tree. the hierarchy of offsets will also correspond. each fork sheet contains its own components, and all its parent components (such as the main title of the form) in this case, only one asset is active.

What is the best option? How to implement a hierarchical structure?

thanks....

+4
source share
1 answer

The best option for a menu hierarchy is to use nested TabPanel widgets. They can go as deep as you need, and this is a great alternative to creating a menu.

I see that you also want to manage two things:

  • When the user enters the URL, you want him to land on the correct tab.
  • When a user moves between tabs, you want the URL to change depending on where he goes.

Putting the user on the correct tab

For # 1, you need to control the user coming to your application in the onModuleLoad method. See This Code Snippet for the right tab.

 public void onModuleLoad() { tabPanel = new TabPanel(); tabPanel.add(new HTML("<h1>Page 0 Content: Llamas</h1>"), " Page 0 "); tabPanel.add(new HTML("<h1>Page 1 Content: Alpacas</h1>"), " Page 1 "); tabPanel.add(new HTML("<h1>Page 2 Content: Camels</h1>"), " Page 2 "); String hash = Window.Location.getHash(); if (hash != null && hash.startsWith("#page")) { int tabIndex = Integer.parseInt(hash.substring(5)); tabPanel.selectTab(tabIndex); } else { tabPanel.selectTab(0); } RootPanel.get().add(tabPanel); } 

This code

Navigation History Management

See this page in the GWT documentation . My code above was taken from this page, but in my example, I removed history management.

In both cases, the key concept is to find the correct widget based on the hash of the URL and select it.

0
source

Source: https://habr.com/ru/post/1342085/


All Articles