DWR

Avoid downloading multiple declarations of generated JavaScript classes

Details

  • Type: Improvement Improvement
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 3.0.RC1
  • Component/s: None
  • Description:
    Hide
    To avoid importing code for generated bean classes once for every interface we could either generate a separate file for each bean class or gather all generated bean classes in a single file that is only included once.

    We add some URLs to DWR:
    dwr/dto/ThisDto.js
    if (typeof ThisDto != "function") {
        function ThisDto () {
            this.field1 = ...;
            ...
    dwr/dto/ThatDto.js
    if (typeof ThatDto != "function") {

    Normally:
    dwr/interface/Remote.js
    [automatically includes dwr/dto/*]
    ... interface definition etc.

    But if we add an init-param into web.xml, something like autoIncludeDtoScripts=false (default: true) then dwr/interface/Remote.js doesn't include the dto scripts.
    Show
    To avoid importing code for generated bean classes once for every interface we could either generate a separate file for each bean class or gather all generated bean classes in a single file that is only included once. We add some URLs to DWR: dwr/dto/ThisDto.js if (typeof ThisDto != "function") {     function ThisDto () {         this.field1 = ...;         ... dwr/dto/ThatDto.js if (typeof ThatDto != "function") { Normally: dwr/interface/Remote.js [automatically includes dwr/dto/*] ... interface definition etc. But if we add an init-param into web.xml, something like autoIncludeDtoScripts=false (default: true) then dwr/interface/Remote.js doesn't include the dto scripts.

Activity

Hide
Mike Wilson added a comment - 12/Aug/08 12:34 PM

I have now checked in the following enhancement:

A new servlet init-param that allow you to control class generation:
<init-param>
<param-name>generateDtoClasses</param-name>
<param-value>interface,dtoall,dto</param-value>
</init-param>
In the above example mapped classes are enabled for generation in all possible locations. The default value if not specifying this parameter is "interface" which is the same as DWR 2.x behaviour.

The meaning of the setting values are:
interface:
-> /dwr/interface/<proxy>.js includes all mapped classes
dtoall:
-> /dwr/dtoall.js includes all mapped classes
dto:
-> /dwr/dto/<class>.js includes a single mapped class

Show
Mike Wilson added a comment - 12/Aug/08 12:34 PM I have now checked in the following enhancement: A new servlet init-param that allow you to control class generation: <init-param> <param-name>generateDtoClasses</param-name> <param-value>interface,dtoall,dto</param-value> </init-param> In the above example mapped classes are enabled for generation in all possible locations. The default value if not specifying this parameter is "interface" which is the same as DWR 2.x behaviour. The meaning of the setting values are: interface: -> /dwr/interface/<proxy>.js includes all mapped classes dtoall: -> /dwr/dtoall.js includes all mapped classes dto: -> /dwr/dto/<class>.js includes a single mapped class

People

Dates

  • Created:
    13/Jul/08 11:19 AM
    Updated:
    12/Aug/08 12:34 PM
    Resolved:
    12/Aug/08 12:34 PM