Loading ...
Sorry, an error occurred while loading the content.

Problem using the directory-based approach

Expand Messages
  • Tommi Forsström
    Hey! We re evaluating AJILE for use on a project as it seems like just the thing we need but ran across a problem at the very beginning: We can t get the
    Message 1 of 4 , Feb 21 11:44 PM
    • 0 Attachment
      Hey!

      We're evaluating AJILE for use on a project as it seems like just the
      thing we need but ran across a problem at the very beginning: We can't
      get the directory-based approach to work!

      I'm running my HelloWorld-type app on IIS 5.1 and my directory tree is
      like this:

      c:\inetpub\wwwroot\:

      -index.html
      -engine.js
      +ajile
      --com.iskitz.ajile.js
      --index.js
      ++com
      +++testing
      ++++namespace
      -----test.js

      The contents of my own files are like this:

      ----/index.html begin----
      <html><head>
      <script type="text/javascript" src="ajile/com.iskitz.ajile.js" />
      <script type="text/javascript" src="engine.js" />
      </head><body onload="init();"></body></html>
      ----/index.html end----


      ----/engine.js begin----
      Import("com.testing.namespace.Test");
      function init(){
      var t = new Test();
      t.sayit("test");
      }
      ----/engine.js end----


      ----/ajile/com/testing/namespace/Test.js begin----
      Namespace("com.testing.namespace");

      com.testing.namespace.Test = function(){
      Test.prototype.prop = 1;
      this.sayit = function sayit(testi){
      alert(testi + "\n" + this.prop);
      };

      };
      ----/ajile/com/testing/namespace/Test.js end----


      For one reason or other, this just doesn't work. Firebug gives me the
      js-error of "Test is not defined". If I move and rename the file
      /ajile/com/testing/namespace/Test.js to
      /ajile/com.testing.namespace.Test.js, it starts working nicely!

      Any help / info on this? It would surely be appreciated as we'd very
      much like to use this lib in our project.

      Tommi Forsström
    • mikeizworkin
      Hey Tommi, The simplest solution is to change your Import line in engine.js to the following: Import( com.testing.namespace.Test , null, / ); If you plan to
      Message 2 of 4 , Feb 22 7:11 AM
      • 0 Attachment
        Hey Tommi,
        The simplest solution is to change your Import line in engine.js to the
        following:

        Import("com.testing.namespace.Test", null, '/');

        If you plan to use the directory style approach throughout your project
        it makes more sense to simply place Ajile in a directory structure as
        follows:

        <script ... src="ajile/com/iskitz/ajile.js" />

        Ajile uses it's own location and packaging style (directory/filename) as
        the default for all import/include operations that don't explicitly
        specify either. So using the directory style approach for Ajile itself
        will allow you to keep engine.js as is. In general if you mix directory
        style and filename style packaging here's the order of precedence:

        1: Import ("your.namespaced.Module", null, "/");

        2: Namespace ("your.namespace", null, "/");

        3: <script ... src="ajile/com/iskitz/ajile.js" />

        One other note. If you renamed engine.js to index.js you won't need to
        explicitly include it in your page, Ajile will automatically load and
        execute it whenever the page (index.html) is loaded.

        Let me know if you have anymore questions.

        Good luck!


        --- In ajile@yahoogroups.com, Tommi Forsström <tommi@...> wrote:
        >
        > Hey!
        >
        > We're evaluating AJILE for use on a project as it seems like just the
        > thing we need but ran across a problem at the very beginning: We can't
        > get the directory-based approach to work!
        >
        > I'm running my HelloWorld-type app on IIS 5.1 and my directory tree is
        > like this:
        >
        > c:\inetpub\wwwroot\:
        >
        > -index.html
        > -engine.js
        > +ajile
        > --com.iskitz.ajile.js
        > --index.js
        > ++com
        > +++testing
        > ++++namespace
        > -----test.js
        >
        > The contents of my own files are like this:
        >
        > ----/index.html begin----
        > <html><head>
        > <script type="text/javascript" src="ajile/com.iskitz.ajile.js" />
        > <script type="text/javascript" src="engine.js" />
        > </head><body onload="init();"></body></html>
        > ----/index.html end----
        >
        >
        > ----/engine.js begin----
        > Import("com.testing.namespace.Test");
        > function init(){
        > var t = new Test();
        > t.sayit("test");
        > }
        > ----/engine.js end----
        >
        >
        > ----/ajile/com/testing/namespace/Test.js begin----
        > Namespace("com.testing.namespace");
        >
        > com.testing.namespace.Test = function(){
        > Test.prototype.prop = 1;
        > this.sayit = function sayit(testi){
        > alert(testi + "\n" + this.prop);
        > };
        >
        > };
        > ----/ajile/com/testing/namespace/Test.js end----
        >
        >
        > For one reason or other, this just doesn't work. Firebug gives me the
        > js-error of "Test is not defined". If I move and rename the file
        > /ajile/com/testing/namespace/Test.js to
        > /ajile/com.testing.namespace.Test.js, it starts working nicely!
        >
        > Any help / info on this? It would surely be appreciated as we'd very
        > much like to use this lib in our project.
        >
        > Tommi Forsström
        >



        [Non-text portions of this message have been removed]
      • strukturgewitter
        Hi, im digging up this post because i experience a very similar problem. My file structure is like this: /var/www/test/index.html
        Message 3 of 4 , Mar 16, 2010
        • 0 Attachment
          Hi, im digging up this post because i experience a very similar problem.
          My file structure is like this:
          /var/www/test/index.html
          /var/www/test/com/iskitz/ajile.js (to activate directory base approach)
          /var/www/test/index.js
          /var/www/test/com/testsite/page/sidebar/Test.js
          /var/www/test/com/testsite/page/sidebar/Test2.js

          File contains:
          ------index.js------
          Include('com.testsite.page.sidebar.Test2');
          Ajile.AddImportListener('com.tessite.page.sidebar.Test2', function(name) {
          com.testsite.page.sidebar.Test2();
          });
          ------Test.js------
          Namespace('com.testsite.page.sidebar');

          com.testsite.page.sidebar.Test = function() {
          alert("Hello World");
          }
          ------Test2.js------
          Namespace('com.testsite.page.sidebar');

          com.testsite.page.sidebar.Test2 = function() {
          Include('com.testsite.page.sidebar.Test');
          Ajile.AddImportListener('com.testsite.page.sidebar.Test', function(name) {
          com.testsite.page.sidebar.Test();
          });
          }
          ------index.html------
          <html>
          <head>
          <script src="com/iskitz/ajile.js?cloakoff?mvcoff" type="text/javascript"></script>
          </head>
          <body>Test</body>
          </html>
          ----------------------

          When i load my page, nothing happens (i also know why [see below])

          This is what firebug gives me:
          <html>
          <head>
          <meta http-equiv="Powered by Ajile 1.2.1" content="ajile.iskitz.com :: Smart scripts that play nice ">
          <script title="index" type="text/javascript" src="http://localhost/test/index.js"></script>
          <script title="com.testsite.page.sidebar.Test2" type="text/javascript" src="http://localhost/test/com.testsite.page.sidebar.Test2.js"></script>
          <script title="com.testsite.page.sidebar.Test2" type="text/javascript">ImportAs("com.testsite.page.sidebar.Test2", "com.testsite.page.sidebar.Test2");</script>
          </head>
          <body>Test</body>
          </html>

          The Problem is the following line:
          http://localhost/test/com.testsite.page.sidebar.Test2.js

          This not a directory based approach.. i assume

          Is there any way around this _without_ using
          Namespace('my.space', null, '/');
          ?
        • mikeizworkin
          Hi, Thanks for providing so much info about the problem you ve run into. Before I go into a full explanation, the short answer for your specific code is to
          Message 4 of 4 , Mar 16, 2010
          • 0 Attachment
            Hi,

            Thanks for providing so much info about the problem you've run into. Before I go into a full explanation, the short answer for your specific code is to make the following changes:

            //------index.html------
            ... src = "com/iskitz/ajile.js?cloakoff,mvcshareoff" ...

            //------index.js------
            Include ("com.testsite.page.sidebar.Test2", null, '/');


            The above line will cause the "com.testsite.page.sidebar" namespace to default to directory-based loading for that and all subsequent Include, Import, and ImportAs of modules using that namespace. After the line above executes any of the following will trigger directory-based loading:


            Include ("com.testsite.page.sidebar.Test");
            Include ("com.testsite.page.sidebar.more.nesting.SomeModule");


            More detail. Namespace, Import, ImportAs, and include can all be used to define the loading style (directory or file) for a given namespace.

            The third parameter in the following statement indicates which character Ajile should use to translate the specified Namespace from dot-notation to its file-system representation.


            Namespace ("your.name.space", "/optional/location/", '/');

            Import ("your.Module", "/optional/location/", '/');

            ImportAs ("Module", "your.Module", "/optional/location/", '/'); // fourth parameter here

            Include ("your.Module", "/optional/location/", '/');


            Using Include, Import or ImportAs with any module within the same or a nested namespace will cause it to be loaded from: /optional/location/your/name/space/

            Substituting '.' for '/' is equivalent to file-based loading using dot-notation.

            For details see:

            http://ajile.net/docs/api/Directives.htm#Import
            http://ajile.net/docs/api/Directives.htm#ImportAs
            http://ajile.net/docs/api/Directives.htm#Include
            http://ajile.net/docs/api/Directives.htm#Namespace


            You might also find it useful to use the "debug" load-time option to get more information about Ajile's operations. When working in an environment that supports console.* (i.e. Firebug) you'll be able to observe Ajile's sequence of actions. This also works with WebKit's console. In environments without console support you can explicitly use Ajile.ShowLog() to display information about Ajile's operations. Ajile.ShowLog() requires pop-up blocking to be disabled.

            To use multiple load-time options use the following syntax:

            ... src = "com/iskitz/ajile.js?option1,option2,option3" ...

            The following will cause Ajile to disable module cloaking, enable debugging (console.*), and disable automatically loading an index.js file from the same location as com.iskitz.ajile.

            ...src="com/iskitz/ajile.js?cloakoff,debug,mvcshareoff"...

            For more load-time option info see:

            http://ajile.net/docs/api/Options.htm


            Hope that helps. Definitely post any further questions or additional issues you run into.


            -Michael


            --- In ajile@yahoogroups.com, "strukturgewitter" <strukturgewitter@...> wrote:
            >
            > Hi, im digging up this post because i experience a very similar problem.
            > My file structure is like this:
            > /var/www/test/index.html
            > /var/www/test/com/iskitz/ajile.js (to activate directory base approach)
            > /var/www/test/index.js
            > /var/www/test/com/testsite/page/sidebar/Test.js
            > /var/www/test/com/testsite/page/sidebar/Test2.js
            >
            > File contains:
            > ------index.js------
            > Include('com.testsite.page.sidebar.Test2');
            > Ajile.AddImportListener('com.tessite.page.sidebar.Test2', function(name) {
            > com.testsite.page.sidebar.Test2();
            > });
            > ------Test.js------
            > Namespace('com.testsite.page.sidebar');
            >
            > com.testsite.page.sidebar.Test = function() {
            > alert("Hello World");
            > }
            > ------Test2.js------
            > Namespace('com.testsite.page.sidebar');
            >
            > com.testsite.page.sidebar.Test2 = function() {
            > Include('com.testsite.page.sidebar.Test');
            > Ajile.AddImportListener('com.testsite.page.sidebar.Test', function(name) {
            > com.testsite.page.sidebar.Test();
            > });
            > }
            > ------index.html------
            > <html>
            > <head>
            > <script src="com/iskitz/ajile.js?cloakoff?mvcoff" type="text/javascript"></script>
            > </head>
            > <body>Test</body>
            > </html>
            > ----------------------
            >
            > When i load my page, nothing happens (i also know why [see below])
            >
            > This is what firebug gives me:
            > <html>
            > <head>
            > <meta http-equiv="Powered by Ajile 1.2.1" content="ajile.iskitz.com :: Smart scripts that play nice ">
            > <script title="index" type="text/javascript" src="http://localhost/test/index.js"></script>
            > <script title="com.testsite.page.sidebar.Test2" type="text/javascript" src="http://localhost/test/com.testsite.page.sidebar.Test2.js"></script>
            > <script title="com.testsite.page.sidebar.Test2" type="text/javascript">ImportAs("com.testsite.page.sidebar.Test2", "com.testsite.page.sidebar.Test2");</script>
            > </head>
            > <body>Test</body>
            > </html>
            >
            > The Problem is the following line:
            > http://localhost/test/com.testsite.page.sidebar.Test2.js
            >
            > This not a directory based approach.. i assume
            >
            > Is there any way around this _without_ using
            > Namespace('my.space', null, '/');
            > ?
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.