Skip to main content

code organization in glue.js

2 replies [Last post]
moizd
Offline
Joined: 2004-09-15
Points: 0

Hello,

I am attempting to build a management UI for our product using jmaki. From what I have read up so far, code that links up different widgets on the ui is written in glue.js.

We have a UI with a tabMenu-like menu that controls the contents of a dcontainer below it. That means the browser url doesn't change.

I have put all the glue code for all the different pages in the dcontainer in separate .js files, but have them all loaded globally. I have tried to use wildcards on the glue includes as outlined in https://ajax.dev.java.net/glue.html, so that I only include the javascript code related to the page being displayed. However, it appears that the page specific code gets loaded/executed only when included globally. As a test I included a .js file with a single statement: jmak.log("JAVASCRIPT LOADED" ). This shows up in the logger div, only when the javascript is loaded globally, without url filtering.

Here's my example:

{
  'config': {
    'version': '1.8',
    'glue' : {
         'includes': [''/glue.js', '/resources/system-glue.js',
            { url : '/app/table.jsp', lib : '/app/apptest.js' }
         ]
       },
    'globalTheme': 'nocsstheme'
    }
}

/app/table.jsp is loaded on a setInclude event to a dcontainer. I want to load /app/apptest.js only when /app/table.jsp is loaded in to the dcontainer.

/app/apptest.js contains the following line:
jmaki.log("**** apptest.js LOADED ****");

I see this log in the logger window only when apptest.js is loaded without url filtering:

{
  'config': {
    'version': '1.8',
    'glue' : {
         'includes': [''/glue.js', '/resources/system-glue.js', '/app/apptest.js'
         ]
       },
    'globalTheme': 'nocsstheme'
    }
}

What I am doing wrong?

Thanks.

Message was edited by: moizd

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
moizd
Offline
Joined: 2004-09-15
Points: 0

Thank you for your response. I did not get a chance to work on this for sometime. I did try out what you had suggested and it worked then. Maybe I should have tried flushing the browser cache.

Thanks again.

gmurray71
Offline
Joined: 2003-07-31
Points: 0

Hi Moizd,

I just verified that I could use full file names for resource inclusion using the format:

{"config": {
"version": "1.0",
"globalTheme": "ocean",
"glue" : {
"includes": [
{ url : "/containers/ads-blogs.jsp", lib : "/greg2.js" }
]
}
}
}

One caveat is that you need to have a component or a jmaki "resources" tag in the included page to make sure jMaki renders the script references:

Like the following:

<%@ taglib prefix="a" uri="http://jmaki/v1.0/jsp" %>

If you have jmaki widgets in the page you don't need to use the resources tag.

I suspect this is your issue.

Please let me know if things still don't work.

One thing you might also want to do is put an alert("appletest.js loaded"); instead of the jmaki.log. That will make sure the javascript execution context is stopped.

Let me know what happens either way.

Regards,

Greg