On 31 mar, 03:03, Ian Bambury <[email protected]> wrote:
> There are any number of menus nested within each other. They are all
> instances of the same widget. Eventually, you reach a non-menu, a real
> 'page'.
>
> The top level menu reacts to history. It passes this to a routine in the top
> menu called setMenuByToken(oldToken, newToken)
> It may get passed a token like Admin/Database/Reset
>
> The '/' is a delimiter.
>
> It splits out the 'Admin' part and shows the Admin page which is also, in
> this case, a menu.
>
> So within the toplevel (site) menu, we now have the Admin menu displayed.
>
> The site menu calls setMenuByToken(oldToken, newToken) on the Admin menu
>
> oldToken is now "Database/Reset", newToken is "Admin"
>
> The Admin menu does the same as the site menu (since it is an instance of
> the same framework widget) - it displays the Database page (also a menu) and
> calls the database.setMenuByToken() routine with "Reset" and
> "Admin/Database"
>
> The database menu displays the Reset page. Since this is the final page and
> not a menu, it writes out the history token "Admin/Database/Reset"
>
> Now I know that it looks a bit silly, writing out what we started with, but
> the system also reacts to menu item clicks. If you click on menu items
> rather than react to history, a new token will be built up from that point
> on.
>
> Getting the token for a history change is done in the top-level menu. It
> just passes it to the setMenuByToken routine. The menus then cascade down
> displaying whatever is required (or a default if there is nothing specified,
> or the last displayed page if there has been one)
>
> When eventually a non-menu is displayed, a new history item is created.
I think I have a similar pattern, but it currently only "react to
history" (i.e. it always goes all the chain from the top, "clicking a
submenu" doesn't setMenuByToken for the "subbranch", it calls
History.setItem() and the onHistoryChange takes care of the rest).
Note that I'm not satisfied by this behavior and I'd like to refactor
everything into events with History.newItem(token, false) in the end
(something looking more like what you're describing here IIUC).
> If at this point, the existing history item is blank, I want to replace it
> with the new history item.
>
> All the processing code is in a framework project, the actual token is based
> on the menu text that the using project sets up, so I have no idea what the
> actual token will be.
>
> I don't know if that is any clearer :-)
So, when you first load the page without a hash/anchor, onModuleLoad
calls setMenuByToken with values ("", "") and the menu system takes
care of showing the "default" submenu and cascade the call to the
submenu, which in turn takes care of showing the "default" submenu,
etc. until a non-menu page is reached, which calls History.newItem
(...)?
(and in this case, you'd like to actually use Location.replace to
*not* create an history entry?)
If I'm correct, then you should probably pass down a "is default" flag
to setMenuByToken and only call History.newItem if !isDefault, i.e.
change your framework a bit...
Otherwise, if I were your, I'd just live with this intermediate
history entry...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---