4 Replies Latest reply on Mar 22, 2013 10:46 AM by jfuerth

    Errai-UI templates fetch all their images

    mdhirsch30345

      We chose Errai-UI in part because it is nice to be able to have designers and coders use the same files for the UI template.  No translation is necessary.

       

      So we have lots of HTML files that look nice it a web browser.  Many of these files refer to images so they look good when you put the template into the browser, but for our deployed application we use an image bundle, or fetch them from the DB, or anything but pull them from the war, so that we benefit from all the GWT goodness. 

       

      But when I watch the network traffic for our app, I see that when the templated class loads, the web browser tries to fetch any referenced files, including these images.  I had thought that since the template is only a template, image files like that would not be loaded.

       

      So I guess my question is what really happens when a @Templated java class is instantiated?  Is the template read and fully parsed by the browser?  That is what I think I'm seeing happen.  In any case, is there a way to keep the images that are only there for the template to look nice in a browser from being loaded by the browser?

       

      Note that the loads never succeed because they aren't in our war, but trying to find them and getting the 404 from the server adds latency to load.  And, if anyone checks out what the browser is doing, they will see lots of 404s and beconfused or suspiscious. 

       

      Thanks,

       

      Michael

        • 1. Re: Errai-UI templates fetch all their images
          cbrock

          To answer your question, yes the templates are loaded and parsed at runtime. We don't have any sort of automated support for automatically packaging up image references into GWT resource bundles.

           

          It's certainly a compelling feature which we could look at supporting.

           

          The alternative would be to use GWT resource bundles as normal and inject them into the template. But that certainly loses the appeal of designers being able to work with them as you say.

           

          In any case, I could look at prototyping a way to generate bundles by parsing the templates at compile time.

          • 2. Re: Errai-UI templates fetch all their images
            mdhirsch30345

            Automatic bundling of images would be awesome.  That would make the templates much more convenient.

             

            An interim measure would be some way to determine which image files don't need to be downloaded because they are being replaced in the code.  Perhaps another attribute in the HTML file?

             

            Thanks for the explanation, Mike.

             

            Michael

            • 3. Re: Errai-UI templates fetch all their images
              magick93

              Just wanted to add my voice to this - I also think this would be a great feature.

              • 4. Re: Errai-UI templates fetch all their images
                jfuerth

                I'd also really like to see the same feature for stylesheets and JavaScript referenced within templates: all of it could be gathered up into resource bundles at compile time with zero additional configuration burden on the app developer.

                 

                If I understand correctly, in the case of JavaScript, this should even allow GWT to run the attached scripts through the Closure compiler if that's enabled during production builds.

                 

                -Jonathan