0 Replies Latest reply on Feb 18, 2013 8:09 AM by Harald Pehl

    Navigation support for multiple platforms / form factors

    Harald Pehl Newbie

      Recently I added support for different form factors to my errai based application called "Schlawiner" (https://schlawiner-hpehl.rhcloud.com/). Therefore I added a FormFactor class which can be injected as needed: https://github.com/hpehl/schlawiner/blob/develop/src/main/java/name/pehl/schlawiner/client/ui/FormFactor.java

       

      I'm using the form factor in my code to dispatch navigation to the platform dependent views: https://github.com/hpehl/schlawiner/blob/develop/src/main/java/name/pehl/schlawiner/client/MainView.java. What I don't like about my solution is the if-then-else boilerplate. I can think of a more declarative, annotation driven way to do this:

       

      {code}

      @Page(path = "main", startingPage = true)

      public class MainView

      {

           @Inject TransitionTo<SinglePlayerView> toSinglePlayer;

           ...

      }

      ---

      @Page

      public class SinglePlayerView extends Composite {...}

      ---

      @Page

      @Desktop

      public class SinglePlayerDesktopView extends SinglePlayerView {...}

      ---

      @Page

      @Tablet

      public class SinglePlayerTabletView extends SinglePlayerView {...}

      {code}

       

      In this case SinglePlayerView would be an "abstract" page which is the super class for all device dependent views. The navigation module would then use the form factor annotations to choose the matching view. What do you think? Does this sound like a reasonable approach?

       

      Can you think of other ways on how to implement (navigation) support for different form factors? Are there already plans to integrate support for different form factors into errai(-navigation)?