Hi Guys,
I’m trying to use the URIFragmentUtility but it doesn’t work somehow in my case. Let me explain the situation:
-
the main Window contains custom layout. In the template I have a menu hard coded with for example #about, #home links. I’d like to change the content of the page by clicking on the links. But I click on the link the FragmentChangedListener doesn’t work.
-
I think the problem is the use of the CustomLayout and URIFragmentUtility together.
@Override
public void init() {
buildMainLayout();
setMainWindow(mainWindow);
}
private void buildMainLayout() {
setTheme("theme");
CustomLayout custom = new CustomLayout("mainLayout");
custom.addStyleName("customLayout");
mainWindow.setContent(custom);
final ProblemsTable table = new ProblemsTable(this);
custom.addComponent(table, "pagecontent");
Link link = new Link("link to a resource", new ExternalResource(
"/MathAlg/test/"));
link.setStyleName("menuButton");
custom.addComponent(link, "homeButton");
UriFragmentUtility urifu = new UriFragmentUtility();
custom.addComponent(urifu);
urifu.addListener(new FragmentChangedListener() {
private static final long serialVersionUID = 1L;
public void fragmentChanged(FragmentChangedEvent source) {
String fragment =
source.getUriFragmentUtility().getFragment();
// if (fragment != null){
// custom.addComponent(table, "pagecontent");
// }else if(fragment.equals("about")){
// System.out.println("TUkss");
// Label test = new Label("tuka ima, tuka nema !!");
// custom.removeComponent(custom);
// custom.addComponent(test,"pagecontent");
// }
System.out.println("fragment changed ?!"+fragment);
}
});
}