UriFragmentUtility Problem

public class StartWindow extends Window {
public StartWindow(Application application) {

        utilities = new UriFragmentUtility();
    addComponent(utilities);
    
    utilities.addListener(new FragmentChangedListener() {
		
		private static final long serialVersionUID = 1L;
		public void fragmentChanged(FragmentChangedEvent source) {
                         String fragment = source.getUriFragmentUtility().getFragment();
                         if (fragment != null) {

                         }
		}
	});
	setContent(buildWindow());
}

public VerticalLayout buildWindow() {
	
	VerticalLayout layout = new VerticalLayout();
            -----------------

	Button button= new Button();

	button.addListener(new ClickListener() {
		public void buttonClick(ClickEvent event) {
				getApplication().setMainWindow(new MainWindow());
				getApplication().removeWindow(StartWindow.this);
				utilities.setFragment("mainwindow");
			}
		}
	});

            -----------------
	return layout;
}

}

public class MainWindow extends Window {
-----------------
-----------------
}

Here UriFragmentUtility didn’t work [ie., didn’t show ‘mainwindow’ in browser URL ]

Please anybody help me…

Please use the code formatter when pasting code (the orange <> icon next to the smiley) otherwise it is difficult to read.

Upon reading quickly it seems like :

  1. you are adding the UriFragmentUtility to the current window
addComponent(utilities);
  1. you remove the current window
getApplication().removeWindow(StartWindow.this);
  1. you try to update the fragment
utilities.setFragment("mainwindow");

At step 3), the UriFragmentUtility is not in the page anymore (removed in step 2)) so it can not do anything anymore.

Maybe your new MainWindow should create a new UriFragmentUtility, add it to it’s layout and after that update the fragment.