0 Replies Latest reply on Jun 6, 2017 7:23 PM by Hristo Stoyanov

    Page navigation improvements

    Hristo Stoyanov Master

      I might be missing something, but the current Page navigation subsystems may need architecture improvements.

       

      1. The NavigationPanel is still rooted in the old GWT widgets and panels. That makes installing custom navigation Panel a bit of pain as we have to deal with RootPanel. Ideally, one would design a new navigationa panel (leaving the old one for backward compatibility) that depends on the new jsinterop elements. Ditto for TransitionalAnchor .

       

      2. It is not easy to design controllers or interceptors that are triggered when pages transition. Ideally, we can:

       

      a. Use Java 8 - style call backs that can be installed in the Navigation object itself like:

          navigation.installGlobalBeforePageShowing((String pageToHide,String pageToShow)->{/* do something*/ });  //We only know the page names at this point

          navigation.installGlobalDuringPageShowing((Object pageToHide, Object pageToShow)->{/*do something*/ }); //Pages has been instantiated

          navigation.installGlobalDuringPageHiding((Object pageToHide, Object pageToShow)->{/*do something*/ });    //Pages has been instantiated

       

      This is very similar to PageNavigationErrorHandler works, but uses functional Java-8 call backs. Note that this could lead to better page security handling rather than the current page roles, etc.

       

      b. Extend the (old) annotation style approach (for page lifecycle events -  @PageShowing, @PageShown, @PageHiding) to make them work outside the page object and take different optional parameters:

       

          @ApplicationScoped

          //This is not a page, just an application scoped bean

          MyGlobalPageTransitionInterceptor{

               ...

               @PageShowing private void pageTransitionHandler(Object opageToHide,Object pageToShow){

                   // centralize logic, for example -  make a navbar menu item active.

               }

          }

       

       

      The current workaround that I have for issue 2. is quite unpleasant and involves a page base class to take care of the whole page machinery:

       

      class BasePage {

          @Inject    protected Event<PageActivity> event;

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

      }

       

      @Page

      public class HomePage extends BasePage {

          //... The usual page content stuff

      }

       

      Any better suggestions?