Apache Wicket navbar set active after redirect

310 Views Asked by At

I have the navbar menu at header. The header is used on every page.

Class hierarchy: WebPage <- BasePage(includes new Header) <- Page...

At navbar I have no whole web pages, but I need to active some NavbarButton if something is happend in body.

For example, there are two pages Persons.html and AddPerson.html, but one

NavbarButton button = new NavbarButton(Persons.class, Model.of("Persons")) {
        @Override
        public boolean isActive(final Component button) {
            if (button.getPage().getPageClass() == AddPerson.class) {
            }
            return super.isActive(button);
        }

I'd like to active button when Persons.html is choised as well as AddPerson.html.

Any ideas?

1

There are 1 best solutions below

1
On

It seems you use Wicket-Bootstrap. Use:

public boolean isActive(final Component button) {
  Class currentPageClass = button.getPage().getPageClass();
  if (Persons.class.equals(currentPageClass) || AddPerson.class.equals(currentPageClass)) {
     return true;
  }
  return super.isActive(button);
}