Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    loading js from external source

    SmartGWT 2.4
    GWT 2.1
    Firefox 3.6.15
    Win XP

    Hi,

    This may be a silly question, but I would like confirmation so I can be sure I am not causing myself future grief. I have been trying to relocate the sc directory outside of my project so I can serve it with a version name in the path and therefore allow the code to be cached forever. The problem I ran into is that setting the isomorphicDir does not seem to impact where (some of) the files are loaded from.

    Is the best practices solution to:

    <inherits name="com.smartgwt.SmartGwtNoScript"/>

    instead of:

    <inherits name="com.smartgwt.SmartGwt"/>

    and then load the javascript files from wherever I want in my host html file?

    Thanks,
    John

    #2
    I changed direction a number of times due to unexpected obstacles. Loading the javascript files from the host html page did not work for me in development mode. The onModuleLoad() call failed because isc was not yet defined. It seemed to work fine in production mode.

    I finally ended up with this:

    In my gwt.xml file
    Code:
      <inherits name="com.smartgwt.SmartGwtNoScript"/>
      <!-- inherits name="com.smartclient.theme.enterprise.Enterprise"/ -->
    
      <!-- Specify the app entry point class.                         -->
      <entry-point class='customformitem.client.CustomFormItem'/>
    
      <!-- Specify the paths for translatable code                    -->
      <source path='client'/>
      <source path='shared'/>
    
        <!--include all the SC API's -->
        <script src='http://www.software-images.net/scripts/sc/sc-2.4/modules/ISC_Core.js'/>
        <script src='http://www.software-images.net/scripts/sc/sc-2.4/modules/ISC_Foundation.js'/>
        <script src='http://www.software-images.net/scripts/sc/sc-2.4/modules/ISC_Containers.js'/>
        <script src='http://www.software-images.net/scripts/sc/sc-2.4/modules/ISC_Grids.js'/>
        <script src='http://www.software-images.net/scripts/sc/sc-2.4/modules/ISC_Forms.js'/>
        <script src='http://www.software-images.net/scripts/sc/sc-2.4/modules/ISC_RichTextEditor.js'/>
        <script src='http://www.software-images.net/scripts/sc/sc-2.4/modules/ISC_Calendar.js'/>
        <script src='http://www.software-images.net/scripts/sc/sc-2.4/modules/ISC_DataBinding.js'/>
        
        <!-- Include the theme -->
        <script src="http://www.software-images.net/scripts/sc/sc-2.4/skins/Enterprise/load_skin.js"/>
    and in my host html page:
    Code:
        <link type="text/css" rel="stylesheet" href="CustomFormItem.css">
    
        <title>Custom Form Item</title>
        
        <script> var isomorphicDir = "http://www.software-images.net/scripts/sc/sc-2.4/"; </script>
        <script type="text/javascript" language="javascript" src="customformitem/customformitem.nocache.js"></script>
    This worked for me and allows me to cache the static sc files in the browser, improving end user performance while allowing sc upgrades to be downloaded immediately when referenced.

    Note that the theme is also cached and is defined in the gwt.xml file. This works well for me, but probably not for someone who needs to alter the theme dynamically.

    If there are downsides to using this setup, I would appreciate hearing about them.

    Thanks,
    John

    Comment

    Working...
    X