DWR3 and AMD

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

DWR3 and AMD

gregorcok

Hi,

 

I just updated my project to load the DWR engine.js and interface using the AMD loading technique.  Previously I had been using the standard technique with the <script> statements.  Previously I was able to access the beans that were defined by the <convert>s in the dwr.xml file such that in my javascript I could instantiate one.   In my web.xml I have:

 

 

  <!-- specify the module prefix for AMD engine.js, dtoall.js and util.js -->

<init-param>

    <param-name>amdDwrBaseModulePath</param-name>

    <param-value>dwr</param-value>

</init-param>

 

<!-- specify the module prefix for AMD interfaces -->

<init-param>

    <param-name>amdInterfaceBaseModulePath</param-name>

    <param-value>myapp</param-value>

</init-param>

 

<!-- specify the module prefix for AMD dtos -->

<init-param>

    <param-name>amdDtoBaseModulePath</param-name>

    <param-value>mydata</param-value>

</init-param>

 

 

and in my dwr.xml I have these defined:

 

<dwr>

  <allow>

    <create creator="new" javascript="UrsRegWizardDataHandler"

       scope="application">

       <param name="class" value="temp.registration.UrsRegWizardDataHandler" />

    </create>

   

    <convert converter="bean" javascript="URSAnswer" match="temp.services.urs.URSAnswer"/> 

    <convert converter="array" match="[Ltemp.services.urs.URSAnswer"/>

</allow>

</dwr>

 

 

I’ve updated to loading the engine.js and interface and dto through AMD by first updating the dojoConfig to include the dwr, myapp, and mydata paths like so:

 

var map17 = { dojo: "dojo", dijit: "dijit", dojox: "dojox" };

var dojoConfig = {

    tlmSiblingOfDojo: false

    packages: [

        { name: "gridx", location: "/CompassThemesURS/themes/html/commonurs/dojo/gridx-1.3.0" },

        { name: "commonjs", location: "/CompassThemesURS/themes/html/commonurs/js" },

        { name: "commonsizzle", location: "/CompassThemesURS/themes/html/commonurs/sizzle-master" },

        { name: "dojo",  location: "/wps/portal_dojo/v1.7/dojo", packageMap: map17  },

        { name: "dijit",  location: "/wps/portal_dojo/v1.7/dijit", packageMap: map17  },

        { name: "dojox",  location: "/wps/portal_dojo/v1.7/dojox", packageMap: map17  },

        { name: "dwr",  location: "/UrsRegistrationWizard/dwr/amd"},

        { name: "myapp",  location: "/UrsRegistrationWizard/dwr/amd/interface"},

        { name: "mydata",  location: "/UrsRegistrationWizard/dwr/amd/dto"}

    ]   

};

 

 

and then in the javascript module I load the objects and instantiate the URSAnswer bean like so:

 

 

require(

  ["dwr/engine",

   "myapp/UrsRegWizardDataHandler",

   "mydata/URSAnswer",

    …

    ],

  function(dwr, UrsRegWizardDataHandler, URSAnswer,…) {

     …

      var myAnswer = new URSAnswer

 

 

When the page first loads I see in Firebug console that the URSAnswer fails to load:

 

"NetworkError: 404 Not Found - https://localhost:10060/wps/portal_dojo/v1.7/dojo/mydata/URSAnswer.js"

 

I don’t see how it’s prepending the wrong path to the URSAnswer.js file.  It seems clear that I’m using the mydata path which is mapped to the "/UrsRegistrationWizard/dwr/amd/dto" location.  Where is my syntax wrong with this new AMD style loading?  The DWR servlet still succeeds in converting objects that I’ve defined through the <convert> elements in the dwr.xml, but I don’t see how to gain access to those beans explicitly like I’m trying.  What am I missing?

 

 

Thanks,

Gregor Okorn,

 

Reply | Threaded
Open this post in threaded view
|

Re: DWR3 and AMD

Mike Wilson
Administrator
Your question is really about how the Dojo AMD loader works so may be better asked in a Dojo forum. I guess if you manually type the path "/UrsRegistrationWizard/dwr/amd/dto/URSAnswer.js you will get the correct script delivered by DWR, right?
 
All I can say is that different script loaders adhering to the AMD spec may be configured a little differently, and the "packages" feature sometimes has a special meaning.
I have successfully configured the RequireJS AMD loader using the paths option:
    paths: {
        "prefix": "location"
    }
so you should look for this or alternative options to configure your Dojo AMD loader.
 
Best regards
Mike
 
Okorn, Gregor C. wrote:

Hi,

 

I just updated my project to load the DWR engine.js and interface using the AMD loading technique.  Previously I had been using the standard technique with the <script> statements.  Previously I was able to access the beans that were defined by the <convert>s in the dwr.xml file such that in my javascript I could instantiate one.   In my web.xml I have:

 

 

  <!-- specify the module prefix for AMD engine.js, dtoall.js and util.js -->

<init-param>

    <param-name>amdDwrBaseModulePath</param-name>

    <param-value>dwr</param-value>

</init-param>

 

<!-- specify the module prefix for AMD interfaces -->

<init-param>

    <param-name>amdInterfaceBaseModulePath</param-name>

    <param-value>myapp</param-value>

</init-param>

 

<!-- specify the module prefix for AMD dtos -->

<init-param>

    <param-name>amdDtoBaseModulePath</param-name>

    <param-value>mydata</param-value>

</init-param>

 

 

and in my dwr.xml I have these defined:

 

<dwr>

  <allow>

    <create creator="new" javascript="UrsRegWizardDataHandler"

       scope="application">

       <param name="class" value="temp.registration.UrsRegWizardDataHandler" />

    </create>

   

    <convert converter="bean" javascript="URSAnswer" match="temp.services.urs.URSAnswer"/> 

    <convert converter="array" match="[Ltemp.services.urs.URSAnswer"/>

</allow>

</dwr>

 

 

I’ve updated to loading the engine.js and interface and dto through AMD by first updating the dojoConfig to include the dwr, myapp, and mydata paths like so:

 

var map17 = { dojo: "dojo", dijit: "dijit", dojox: "dojox" };

var dojoConfig = {

    tlmSiblingOfDojo: false

    packages: [

        { name: "gridx", location: "/CompassThemesURS/themes/html/commonurs/dojo/gridx-1.3.0" },

        { name: "commonjs", location: "/CompassThemesURS/themes/html/commonurs/js" },

        { name: "commonsizzle", location: "/CompassThemesURS/themes/html/commonurs/sizzle-master" },

        { name: "dojo",  location: "/wps/portal_dojo/v1.7/dojo", packageMap: map17  },

        { name: "dijit",  location: "/wps/portal_dojo/v1.7/dijit", packageMap: map17  },

        { name: "dojox",  location: "/wps/portal_dojo/v1.7/dojox", packageMap: map17  },

        { name: "dwr",  location: "/UrsRegistrationWizard/dwr/amd"},

        { name: "myapp",  location: "/UrsRegistrationWizard/dwr/amd/interface"},

        { name: "mydata",  location: "/UrsRegistrationWizard/dwr/amd/dto"}

    ]   

};

 

 

and then in the javascript module I load the objects and instantiate the URSAnswer bean like so:

 

 

require(

  ["dwr/engine",

   "myapp/UrsRegWizardDataHandler",

   "mydata/URSAnswer",

    …

    ],

  function(dwr, UrsRegWizardDataHandler, URSAnswer,…) {

     …

      var myAnswer = new URSAnswer

 

 

When the page first loads I see in Firebug console that the URSAnswer fails to load:

 

"NetworkError: 404 Not Found - https://localhost:10060/wps/portal_dojo/v1.7/dojo/mydata/URSAnswer.js"

 

I don’t see how it’s prepending the wrong path to the URSAnswer.js file.  It seems clear that I’m using the mydata path which is mapped to the "/UrsRegistrationWizard/dwr/amd/dto" location.  Where is my syntax wrong with this new AMD style loading?  The DWR servlet still succeeds in converting objects that I’ve defined through the <convert> elements in the dwr.xml, but I don’t see how to gain access to those beans explicitly like I’m trying.  What am I missing?

 

 

Thanks,

Gregor Okorn,

 

Reply | Threaded
Open this post in threaded view
|

Re: DWR3 and AMD

gregorcok

I’ve found that in order for the URSAnswer object to be recognized like I’m trying:

 

require(

  ["dwr/engine",

   "myapp/UrsRegWizardDataHandler",

   "mydata/URSAnswer",

    …

    ],

  function(dwr, UrsRegWizardDataHandler, URSAnswer,…) {

     …

      var myAnswer = new URSAnswer

 

 

that I have to set the generateDtoClasses in the web.xml like so:

 

 

    <init-param>

      <param-name>generateDtoClasses</param-name>

      <param-value>dto</param-value>

    </init-param>

 

Is that the only way to have access to the URSAnswer like I’m doing?   I also tried to set the generateDtoClasses to interface and dtoall, but can’t figure out the syntax to then get access to the URSAnswer object.   What am I missing here?

 

Thanks,

Gregor Okorn,

 

From: Mike Wilson [mailto:[hidden email]]
Sent: Wednesday, September 23, 2015 14:29 PM
To: [hidden email]
Subject: [dwr-users] Re: DWR3 and AMD

 

Your question is really about how the Dojo AMD loader works so may be better asked in a Dojo forum. I guess if you manually type the path "/UrsRegistrationWizard/dwr/amd/dto/URSAnswer.js you will get the correct script delivered by DWR, right?

 

All I can say is that different script loaders adhering to the AMD spec may be configured a little differently, and the "packages" feature sometimes has a special meaning.

I have successfully configured the RequireJS AMD loader using the paths option:

    paths: {

        "prefix": "location"

    }

so you should look for this or alternative options to configure your Dojo AMD loader.

 

Best regards

Mike

 

Okorn, Gregor C. wrote:

Hi,

 

I just updated my project to load the DWR engine.js and interface using the AMD loading technique.  Previously I had been using the standard technique with the <script> statements.  Previously I was able to access the beans that were defined by the <convert>s in the dwr.xml file such that in my javascript I could instantiate one.   In my web.xml I have:

 

 

  <!-- specify the module prefix for AMD engine.js, dtoall.js and util.js -->

<init-param>

    <param-name>amdDwrBaseModulePath</param-name>

    <param-value>dwr</param-value>

</init-param>

 

<!-- specify the module prefix for AMD interfaces -->

<init-param>

    <param-name>amdInterfaceBaseModulePath</param-name>

    <param-value>myapp</param-value>

</init-param>

 

<!-- specify the module prefix for AMD dtos -->

<init-param>

    <param-name>amdDtoBaseModulePath</param-name>

    <param-value>mydata</param-value>

</init-param>

 

 

and in my dwr.xml I have these defined:

 

<dwr>

  <allow>

    <create creator="new" javascript="UrsRegWizardDataHandler"

       scope="application">

       <param name="class" value="temp.registration.UrsRegWizardDataHandler" />

    </create>

   

    <convert converter="bean" javascript="URSAnswer" match="temp.services.urs.URSAnswer"/> 

    <convert converter="array" match="[Ltemp.services.urs.URSAnswer"/>

</allow>

</dwr>

 

 

I’ve updated to loading the engine.js and interface and dto through AMD by first updating the dojoConfig to include the dwr, myapp, and mydata paths like so:

 

var map17 = { dojo: "dojo", dijit: "dijit", dojox: "dojox" };

var dojoConfig = {

    tlmSiblingOfDojo: false

    packages: [

        { name: "gridx", location: "/CompassThemesURS/themes/html/commonurs/dojo/gridx-1.3.0" },

        { name: "commonjs", location: "/CompassThemesURS/themes/html/commonurs/js" },

        { name: "commonsizzle", location: "/CompassThemesURS/themes/html/commonurs/sizzle-master" },

        { name: "dojo",  location: "/wps/portal_dojo/v1.7/dojo", packageMap: map17  },

        { name: "dijit",  location: "/wps/portal_dojo/v1.7/dijit", packageMap: map17  },

        { name: "dojox",  location: "/wps/portal_dojo/v1.7/dojox", packageMap: map17  },

        { name: "dwr",  location: "/UrsRegistrationWizard/dwr/amd"},

        { name: "myapp",  location: "/UrsRegistrationWizard/dwr/amd/interface"},

        { name: "mydata",  location: "/UrsRegistrationWizard/dwr/amd/dto"}

    ]   

};

 

 

and then in the javascript module I load the objects and instantiate the URSAnswer bean like so:

 

 

require(

  ["dwr/engine",

   "myapp/UrsRegWizardDataHandler",

   "mydata/URSAnswer",

    …

    ],

  function(dwr, UrsRegWizardDataHandler, URSAnswer,…) {

     …

      var myAnswer = new URSAnswer

 

 

When the page first loads I see in Firebug console that the URSAnswer fails to load:

 

"NetworkError: 404 Not Found - https://localhost:10060/wps/portal_dojo/v1.7/dojo/mydata/URSAnswer.js"

 

I don’t see how it’s prepending the wrong path to the URSAnswer.js file.  It seems clear that I’m using the mydata path which is mapped to the "/UrsRegistrationWizard/dwr/amd/dto" location.  Where is my syntax wrong with this new AMD style loading?  The DWR servlet still succeeds in converting objects that I’ve defined through the <convert> elements in the dwr.xml, but I don’t see how to gain access to those beans explicitly like I’m trying.  What am I missing?

 

 

Thanks,

Gregor Okorn,

 

Reply | Threaded
Open this post in threaded view
|

Re: DWR3 and AMD

Mike Wilson
Administrator
Yes, using generateDtoClasses=dto is the way to go, dtoall and interface are only supported for standard script tag inclusion and don't currently do anything in the AMD integration.
 
Best regards
Mike
 
Okorn, Gregor C. wrote:

I’ve found that in order for the URSAnswer object to be recognized like I’m trying:

 

require(

  ["dwr/engine",

   "myapp/UrsRegWizardDataHandler",

   "mydata/URSAnswer",

    …

    ],

  function(dwr, UrsRegWizardDataHandler, URSAnswer,…) {

     …

      var myAnswer = new URSAnswer

 

 

that I have to set the generateDtoClasses in the web.xml like so:

 

 

    <init-param>

      <param-name>generateDtoClasses</param-name>

      <param-value>dto</param-value>

    </init-param>

 

Is that the only way to have access to the URSAnswer like I’m doing?   I also tried to set the generateDtoClasses to interface and dtoall, but can’t figure out the syntax to then get access to the URSAnswer object.   What am I missing here?

 

Thanks,

Gregor Okorn,

 

From: Mike Wilson [mailto:[hidden email]]
Sent: Wednesday, September 23, 2015 14:29 PM
To: [hidden email]
Subject: [dwr-users] Re: DWR3 and AMD

 

Your question is really about how the Dojo AMD loader works so may be better asked in a Dojo forum. I guess if you manually type the path "/UrsRegistrationWizard/dwr/amd/dto/URSAnswer.js you will get the correct script delivered by DWR, right?

 

All I can say is that different script loaders adhering to the AMD spec may be configured a little differently, and the "packages" feature sometimes has a special meaning.

I have successfully configured the RequireJS AMD loader using the paths option:

    paths: {

        "prefix": "location"

    }

so you should look for this or alternative options to configure your Dojo AMD loader.

 

Best regards

Mike

 

Okorn, Gregor C. wrote:

Hi,

 

I just updated my project to load the DWR engine.js and interface using the AMD loading technique.  Previously I had been using the standard technique with the <script> statements.  Previously I was able to access the beans that were defined by the <convert>s in the dwr.xml file such that in my javascript I could instantiate one.   In my web.xml I have:

 

 

  <!-- specify the module prefix for AMD engine.js, dtoall.js and util.js -->

<init-param>

    <param-name>amdDwrBaseModulePath</param-name>

    <param-value>dwr</param-value>

</init-param>

 

<!-- specify the module prefix for AMD interfaces -->

<init-param>

    <param-name>amdInterfaceBaseModulePath</param-name>

    <param-value>myapp</param-value>

</init-param>

 

<!-- specify the module prefix for AMD dtos -->

<init-param>

    <param-name>amdDtoBaseModulePath</param-name>

    <param-value>mydata</param-value>

</init-param>

 

 

and in my dwr.xml I have these defined:

 

<dwr>

  <allow>

    <create creator="new" javascript="UrsRegWizardDataHandler"

       scope="application">

       <param name="class" value="temp.registration.UrsRegWizardDataHandler" />

    </create>

   

    <convert converter="bean" javascript="URSAnswer" match="temp.services.urs.URSAnswer"/> 

    <convert converter="array" match="[Ltemp.services.urs.URSAnswer"/>

</allow>

</dwr>

 

 

I’ve updated to loading the engine.js and interface and dto through AMD by first updating the dojoConfig to include the dwr, myapp, and mydata paths like so:

 

var map17 = { dojo: "dojo", dijit: "dijit", dojox: "dojox" };

var dojoConfig = {

    tlmSiblingOfDojo: false

    packages: [

        { name: "gridx", location: "/CompassThemesURS/themes/html/commonurs/dojo/gridx-1.3.0" },

        { name: "commonjs", location: "/CompassThemesURS/themes/html/commonurs/js" },

        { name: "commonsizzle", location: "/CompassThemesURS/themes/html/commonurs/sizzle-master" },

        { name: "dojo",  location: "/wps/portal_dojo/v1.7/dojo", packageMap: map17  },

        { name: "dijit",  location: "/wps/portal_dojo/v1.7/dijit", packageMap: map17  },

        { name: "dojox",  location: "/wps/portal_dojo/v1.7/dojox", packageMap: map17  },

        { name: "dwr",  location: "/UrsRegistrationWizard/dwr/amd"},

        { name: "myapp",  location: "/UrsRegistrationWizard/dwr/amd/interface"},

        { name: "mydata",  location: "/UrsRegistrationWizard/dwr/amd/dto"}

    ]   

};

 

 

and then in the javascript module I load the objects and instantiate the URSAnswer bean like so:

 

 

require(

  ["dwr/engine",

   "myapp/UrsRegWizardDataHandler",

   "mydata/URSAnswer",

    …

    ],

  function(dwr, UrsRegWizardDataHandler, URSAnswer,…) {

     …

      var myAnswer = new URSAnswer

 

 

When the page first loads I see in Firebug console that the URSAnswer fails to load:

 

"NetworkError: 404 Not Found - https://localhost:10060/wps/portal_dojo/v1.7/dojo/mydata/URSAnswer.js"

 

I don’t see how it’s prepending the wrong path to the URSAnswer.js file.  It seems clear that I’m using the mydata path which is mapped to the "/UrsRegistrationWizard/dwr/amd/dto" location.  Where is my syntax wrong with this new AMD style loading?  The DWR servlet still succeeds in converting objects that I’ve defined through the <convert> elements in the dwr.xml, but I don’t see how to gain access to those beans explicitly like I’m trying.  What am I missing?

 

 

Thanks,

Gregor Okorn,