javascriptextjsgoogle-closure-compilergatein

Extjs 3.4 not fully working in GateIn 3.6 - Closure compiler compression issue


I am using ext-js version 3.4 with GateIn 3.6 (jboss as 7). On GateIn some ext components are not working fine (especially tree) when GateIn as in production mode. I think this issue is due to javascript compression mechanism. I got the same issue in GateIn 3.2 then after i find that in GateIn 3.6 they changed the java compression machanism (in this GateIn they are using closure compiler) but still have the same issue. Here follows my problem with example

I created two examples which contains same code of tree loading
Example 1 :- Here the ext js related files are not compressed
Example 2 :- Here the ext js files are compressed using closure compiler
(You can run the above two example by deploying it into a server like wamp, xamp, jboss... etc)

On Example 1 it is possible to expand the tree. But on the second case (Example 2) the tree expanded only first level. Is there is any idea to resolve this issue.

I cant directly specify the ext js libraries without compression in production mode. Because in GateIn java scripts are specified inside in gatein-resources.xml file. In production mode i think by default GateIn compresses the files in gatein-resources.xml using closure compiler.


Solution

  • If non compressing your ext-js scripts is an option for you, you can either :
    - add your scripts with the doHeaders method instead of using gatein-resources.xml : Remove duplicate header entries from doHeaders()
    - keep on using the gatein-resources.xml to import your javascripts, and make an exception for the compression by adding a route in the gatein/conf/controller.xml (a route which does not get the compress param) :

    <route path="/scripts/{gtn:version}/{gtn:scope}/">
      <route-param qname="gtn:handler">
        <value>script</value>
      </route-param>
      <path-param qname="gtn:version" encoding="preserve-path">
        <pattern>[^/]*</pattern>
      </path-param>
      <route path="/{gtn:resource}{gtn:lang}-min.js">
        <path-param qname="gtn:resource">
          <pattern>(ext-core-debug)</pattern>
        </path-param>
        <path-param qname="gtn:lang" capture-group="true">
          <pattern>-([A-Za-z]{2}(-[A-Za-z]{2})?)|</pattern>
        </path-param>
      </route>
    </route>
    
    <route path="/scripts/{gtn:version}/{gtn:scope}/">
      <route-param qname="gtn:handler">
        <value>script</value>
      </route-param>
      <path-param qname="gtn:version" encoding="preserve-path">
        <pattern>[^/]*</pattern>
      </path-param>
      <route path="/{gtn:resource}{gtn:lang}{gtn:compress}.js">
        <path-param qname="gtn:resource">
          <pattern>.+?</pattern>
        </path-param>
        <path-param qname="gtn:lang" capture-group="true">
          <pattern>-([A-Za-z]{2}(-[A-Za-z]{2})?)|</pattern>
        </path-param>
        <path-param qname="gtn:compress" capture-group="true">
          <pattern>-(min)|</pattern>
        </path-param>
      </route>
    </route>
    

    Adapt the pattern of the gtn:resource param to match your needs. With one of these solutions, all the scripts will be minified except the ones you define in your pattern.