Problem with URI Fragment ???

Hi.
I am new to Vaadin and stuck at one place.
I have a button and I need when i click on this button, the URI will change and when the URI fragment is given, use it to click this button.
This is my code:

public class HeaderPanel extends HorizontalLayout implements
		Button.ClickListener, CitySelectedListener {

private Button moduleDeployer;

public HeaderPanel() {

final UriFragmentUtility fragment =  new UriFragmentUtility();

moduleDeployer = new Button("Deploy module");

addComponent(moduleDeployer);
addConponent(fragment);

moduleDeployer.addListener(new Button.ClickListener() {
			private static final long serialVersionUID = 1L;

			@Override
			public void buttonClick(ClickEvent event) {
                                
                                //Set the Uri Fragment when the button is clicked (It's OK)
                                fragment.setFragment(moduleDeployer.getCaption());

				BlackboardUtil.fire(new ServiceSelectedEvent(
						new ModuleDeployer()));
			}
		});

//When the URI Fragment is given, ... (It's not run)
fragment.addListener(new FragmentChangedEvent source) {

                 String uri = source.getUriFragmentUtility().getFragment();
                 if(uri!=null && uri == moduleDeployer.getCaption()) {

				BlackboardUtil.fire(new ServiceSelectedEvent(
						new ModuleDeployer()));

                  }

}

}

}

Can somebody help on this ? :frowning:

From Book of Vaadin:

The UriFragmentUtility is a special-purpose component that manages the URI fragment; it allows setting the fragment and to handle user-made changes to it.

So it seems that listeners are not called when you programmatically change the fragment. Move the fragment code into a separate method and call the method separately when you change the fragment by code. You can also create a setFragment(String) method that calls fragment.setFragment(fragment) and the method.

Fragment change listeners should be called also when setting the fragment from code unless you give “false” as a second parameter to setFragment(…).

Maybe the UriFragmentUtility is not yet attached (and painted?) or something like that - I didn’t check if it is required for the events to be fired but you should see it easily in the source code…