Hi Guys,
[b]
Situation
[/b]
My Vaadin application uses a very classic sequence:
- Application.init
1.1 new MyMainWindow()
1.1.1 new UriFragmentUtility
1.1.2 uriFragmentUtility.addListener( new MyFragmentChangedListener() )
1.1.3 uriFragmentUtility.getFragment() == null - MyFragmentChangedListener.fragmentChanged(…)
The UriFramentUtility.getFragment() javadoc says:
According to this comment, it seems normal that during 1.1.3, getFragment() returns null (because Application.init is not over yet). Still according the comment, my problem below seems known and “expected”
Problem
My problem is probably very common.
If the user enters through an URL with no anchor, it goes to the home page.
i.e.: http://www.MyDomainName.com/
At point 1.1.3, I decide to put in MyMainWindow, the content of the home page.
That case works fine.
But if the user enters through a more specific url, we directly show the corresponding content
i.e.: http://www.MyDomainName.com/#products
At point 1.1.3, we would decide not to show the home page in MyMainWindow, but the list of products.
But, because at point 1.1.3, uriFragmentUtility.getFragment() == null, MyMainWindow thinks it must show the home page. And the home page is briefly shown in the browser.
Immediately after, point 2 happens and the products page is constructed server side (content of MyMainWindow), then shown in the browser.
Question
How to avoid the 1st (useless) rendering of the home page?
I don’t understand the suggestion of the UriFramentUtility.getFragment() javadoc. Does it mean that I should look at the HttpServletRequest myself?
How would you solve that problem?
Further understanding
If I understand well, UriFramentUtility is mainly a browser side GWT component.
It means that if I’ve a new HttpSession, or even if I open a new tab, a first request/response cycle is needed to bring the component on the browser, and then a second request/response will notify the FragmentChangedListeners. It means that the current verison of UriFragmentUtility will not be of any help for the initial uri.