2 Replies Latest reply on Sep 27, 2016 6:03 PM by Hristo Stoyanov

    Page navigation error - Errai 4.0.0-snapshot

    Hristo Stoyanov Master

      Hi all,

      Not sure why I started getting this errors - they seem pretty random and happen when I switch pages from the navigation menu. I dont think i saw them 2-3 month ago with the 4.0 shapshots back then.

       

       

      An then occasionally I get this:

       

      Here is the code of the page:

      ============================

      @ApplicationScoped

      @Page(path = PageActivity.ABOUT)

      @Templated("#content")

      public class AboutPage extends AbstractBasePage {

       

       

          @Inject

          @DataField

          private Footer footer;

       

       

          @Override

          protected String getPageName() {

              return PageActivity.ABOUT;

          }

       

       

          @Override

          protected void pageShowing() {

              event.fire(new PageActivity(pageShowing, getPageName()));

          }

         

      }

      ==============================

      abstract public class AbstractBasePage {

         

          @Inject

          protected Main theWebApp;

       

       

          @Inject

          protected SecurityContext securityContext;

       

       

          @Inject

          protected Event<PageActivity> event;

       

       

          @Inject

          protected TransitionTo<PlanPage> planPage;

       

       

          abstract protected String getPageName();

       

       

          @PageShown

          protected void pageShown() {

              event.fire(new PageActivity(pageShown, getPageName()));

          }

       

       

          @PageShowing

          protected void pageShowing() {

              if (!User.ANONYMOUS.equals(getCachedUser()) && !userHasRole(ACTIVE_ERRAI)) {

                  planPage.go();

              }

              event.fire(new PageActivity(pageShowing, getPageName()));

          }

       

       

          @PageHiding

          protected void pageHiding() {

              event.fire(new PageActivity(pageHiding, getPageName()));

          }

       

       

          @PageHidden

          protected void pageHidden() {

              event.fire(new PageActivity(pageHidden, getPageName()));

          }

       

       

          final protected boolean userHasRole(Role... role) {

              return role != null

                      && securityContext.getCachedUser().getRoles().containsAll(Arrays.asList(role));

          }

       

       

          final protected Plan getUserPlan() {

              Set<Role> userRoles = getCachedUser().getRoles();

              if (userRoles.contains(ULTIMATE.role)) {

                  return ULTIMATE;

              }

              if (userRoles.contains(ENTERPRISE.role)) {

                  return ENTERPRISE;

              }

              if (userRoles.contains(PREMIUM.role)) {

                  return PREMIUM;

              }

              if (userRoles.contains(BASIC.role)) {

                  return BASIC;

              }

              return null;

             

          }

       

       

          final protected boolean isAnonymous() {

              return userHasRole(Role.NOBODY);

          }

       

       

          final protected User getCachedUser() {

              return securityContext.getCachedUser();

          }

       

       

      }

      ===========================================

      @ApplicationScoped

      @Templated("Skeleton.html#footer")

      public class Footer {

       

       

          private final static String MESSAGE = "whatever";

       

       

          @Inject

          @DataField

          private Div footer;

         

          @AfterInitialization

          private void postConstruct() {

              footer.setInnerHTML(MESSAGE);

          }

      }