2 Replies Latest reply on Sep 27, 2016 6:03 PM by hr.stoyanov

    Page navigation error - Errai 4.0.0-snapshot

    hr.stoyanov

      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);

          }

      }

        • 1. Re: Page navigation error - Errai 4.0.0-snapshot
          hr.stoyanov

          hard to tell from the Chrome console, but the exception is likely coming from:

           

          java.lang.IllegalStateException: Should only call onDetach when the widget is attached to the browser's document

          at com.google.gwt.user.client.ui.Widget.onDetach

          • 2. Re: Page navigation error - Errai 4.0.0-snapshot
            hr.stoyanov

            ...So, I am still stuck on that issue. My biggest problem is that with the latest GWT 2.8/Errai/Chrome I can not see the stack traces in order to figure out where in Errai the issue is.  Has anyone experienced obfuscated stack traces with the latest Errai 4?

             

            Apart from that, I know that in Errai somehow c.g.g.user.client.ui.Widget.onDetach() gets called without first checking with c.g.g.user.client.ui.Widget.isAttached() ?

             

            Sorry, i cannot be more specific until i figure out my stack trace problem...