FragmentChangedListener

Hi,

I am using FragmentChangedListener in init() method of Application class.

My url contains fragments like
www.foo.com/page1#123

Now when I change the url fragment like
www.foo.com/page1#456

the fragment listener is not called.

Actually, I am creating a link in this way and sending this URL in mail to some users.
So when they click on this URL the a new tab is opened in the browser and application is launched.
Suppose I have sent two links as shown above.

When I click on first link I get the fragment 123 which is as expected.
But when I click on second link a new tab is displayed but even in this case the fragment is 123 although the browser URL contains 456.

When I debugged the code found that the fragmentListener is not called in this case.

But when I open this two links in seperate browsers every thing works fine.

Could some one help on this issue.

First and foremost, make sure that the UriFragmentUtil remains present on the layout. It’s a bit weird, but it’s still a component, even though it’s invisible. So, make sure that you’re not removing the fragment component by mistake when redrawing some views, or something similar.

That’s at least what it sounds like.

Usually I have only one global fragment util in my application, which i place in the main layout, and keep the view changes in a layout “below” that.

Hi Henrik,

I have also tried by making fragment utility global.
But still it doesn’t work…
Also I am not removing it from the component.

Please find the code below–



final UriFragmentUtility uriFragmentUtility = new UriFragmentUtility();

public void init(){
Window mainWindow = (Window) springContext.getBean("mainWindow");
		mainWindow.setWidth(100, Sizeable.UNITS_PERCENTAGE);
        setMainWindow(mainWindow); 
        mainWindow.setImmediate(true); 
        mainWindow.setCaption(springContext.getMessage("application.title", null, springContext.getLocale()));
        
        
        
        //Register the URIFragmentUtility to get the fragments from the URL()
        
        mainWindow.addComponent(uriFragmentUtility);
        
        uriFragmentUtility.addListener(new FragmentChangedListener() {			
			public void fragmentChanged(FragmentChangedEvent source) {
				String fragment = source.getUriFragmentUtility().getFragment();
				if (fragment != null){
					springContext.setUrlFragment(fragment);					
				}
			}
		});
}