8 Replies Latest reply on May 5, 2014 5:06 PM by csa

    Build offline application with Errai

    malpi

      Hi there,

       

      I have discovered that Errai offeres many options to handle the case, if the client looses connection to the server, that was one of the reasons why we've chosen errai.

       

      Since we created a kind of prototyp of our Application, we want to try the offline mode. What for me, is a bit unclear, is how I can compile an offline to use version of the Application.

       

      Do I have to do it the "GWT-Way" and create a customized linker which will create the propper manifest, or is there an easier solution which comes with Errai? If so, where can I find documentation for that, in both cases?

       

      Hope it's clear what I mean...

       

      Thanks in advance!

        • 1. Re: Build offline application with Errai
          csa

          Hi Malte,

           

          Can you explain what you mean by "how I can compile an offline to use version of the Application"? GWT's output is perfectly cacheable JavaScript which browser's can display even when offline (give your webserver is configured correctly and the page was visited before). See http://www.gwtproject.org/doc/latest/DevGuideCompilingAndDebugging.html#perfect_caching.


          Errai provides a number of facilities to simplify building application that should work when offline:


          - Errai JPA to persist entities into the browser's local storage

          - Errai DataSync to synchronize entities in local storage with the server

          - ShadowServices that will be used when a Bus/RPC endpoint is not reachable

          - Bus Lifecycle listeners to detect when the bus goes offline

           

          Cheers,

          Christian

          1 of 1 people found this helpful
          • 2. Re: Build offline application with Errai
            malpi

            Hi Christian,

             

            sorry that I answer that late, but I had much to do in the past. I've read a bit more about the HTML5-Caching concept and it's a bit more clear for me. Maybe I should have done this before asking here.

             

            The usecases I want to test are the following:

             

            1. User accesses the Application while being online (Therefore it should be cached)
            2. Usecase 1:
              1. Shutdown the server => Connection will be lost
              2. Application should still be usable due to the caching
              3. Server is coming back to life => Application should therefore reconnect
            3. Usecase 2:
              1. The user closes the application
              2. In the meantime the server will be shutdown
              3. User tries to access the App again, the files should be in the cache
              4. Server is coming back to life => Application should therefore reconnect

            What we did so far, is implementing the Bus Lifecycle listener, which is recognizing perfectly when the ApplicationServer is going offline and online.

            As far as I read, I have to create a GWT Linker, to create the HTML5-Manifest and to state which files need to be cached? (https://code.google.com/p/mgwt/wiki/HTML5Manifest) This is what I wanted to ask for in my initial question. Do I have to implement this linker on my own, or is there something prepared in the Errai Framework?

             

            Hope it's more clear what I mean.

             

            Cheers,

             

            Malte

            • 3. Re: Build offline application with Errai
              csa

              Hi Malte,

               

              Yes, good point. If you plan to use HTML's offline capabilities you will have to serve a manifest file that only lists the JS sources (permutations) that the corresponding client needs.

               

              We don't have a built-in linker and servlet for that but Daniel Kurka's solution looks great and you should be able to use it. This is a similar solution that also looks reusable: http://code.google.com/p/gwt2go/source/browse/#svn%2Ftrunk%2Fgwt2go%2Fsrc%2Fcom%2Fgwt2go%2Fdev%2Flinker

               

              Cheers,

              Christian

              • 4. Re: Build offline application with Errai
                malpi

                Hi Christian,

                 

                Thanks for pointing this out.

                 

                Cheers,

                 

                Malte

                • 5. Re: Build offline application with Errai
                  malpi

                  Hi there,

                   

                  I've spent yesterday evening to make this running. In General the mgwt Framework is no help at all, since there will be only compiled Manifests for IE 7 - 9, old Opera versions and Old Safari versions.

                   

                  Whereas the gwt2go example is really helpfull! But you have to consider that in any case you have to annotate your Linkerclass with "@Shardable". Furthermore you have to put your Linker module into the Serverside, what makes sense, but otherwise you will have some dependency conflicts. In the documentation it's stated that it doesn't matter.

                   

                  Cheers,

                   

                  Malte

                  • 6. Re: Build offline application with Errai
                    csa

                    Thanks for the update, Malte! This will be helpful to others.

                     

                    If you feel this approach can be improved or have an idea what Errai could do to simplify this, feel free to create a JIRA for us. Contributions are always welcome!

                     

                    Cheers,

                    Christian

                    • 7. Re: Build offline application with Errai
                      malpi

                      Hi Christian,

                       

                      I think it could be helpful to provide a default Linker by the Errai Framework. Because it's a default implementation which can be reused everywhere. And without the generated manifest, the offline capabilities of Errai are somehow useless.

                       

                      On the other hand at least from my point of view this functionality should be provided by GWT. Therefore it's up to your team to decide that. By time I will conclude my example in a Blogpost and let you know.

                       

                      Best Regards,

                       

                      Malte

                      • 8. Re: Build offline application with Errai
                        csa

                        Hi Malte,

                         

                        I agree having such a linker in Errai (or GWT for that matter) would be really useful. Looking forward to your blogpost!

                         

                        If you want to contribute your linker to Errai you are more than welcome to send us a pull request and/or create a JIRA for us.

                         

                        Thanks,

                        Christian