Topic
5 replies Latest Post - ‏2009-05-26T20:13:09Z by SystemAdmin
SystemAdmin
SystemAdmin
181 Posts
ACCEPTED ANSWER

Pinned topic Context root problem

‏2009-05-05T23:40:20Z |
Hello,
I'm using LWF 1.0.1 to create a widget which I export from LWF using Properties -> 'Build War for Production deployment' function.
The production war file is subsequently used to get the widget added into the MushupHub catalog (via 'Upload Widget' -> iWidget Package (.war)) and then added to the Lotus Mashups using 'Add to Lotus Mashups' function. The process works fine in that the widget becomes available in Mashups. However, I'm running into issues with the context root that my application (i.e. widget) is deployed under in WAS.
The Add to Lotus Mashups function seems to be deploying applications with "/widgets/" in the first part of the context root name.
This causes problems in the Client JavaScript builder code that is part of my LWF model. My JavaScript code references some resources (image files and such) that are packaged in the war file. When I add the "production" widget to a page in Lotus Mashups, the JavaScript can't find those resources and it fails. When I manually update the model in the deployed application to add "/widgets/" in front of the file path used to locate these resources and restart the application then it works.
This problem is only happening when the 'Add to Mashups' is used to deploy my production war file.
I can test (i.e. Run) the model from within LWF designer using my local Mashups Center without any problems. It also works fine when the 'Publish Widgets to Lotus Mashups toolbox' is used to publish the widget locally.
This issue forces me to maintain two versions of the javascript code, one for the local and one for the remote (production) deployment as described above.
What's the best way of resolving this issue?

Jan
Updated on 2009-05-26T20:13:09Z at 2009-05-26T20:13:09Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    181 Posts
    ACCEPTED ANSWER

    Re: Context root problem

    ‏2009-05-06T13:49:00Z  in response to SystemAdmin
    J2EE web applications (including LWF widgets) should not be written to be dependent on their application context path. This is especially important in the Mashups world: the collaborative nature of such a platform makes it very likely that you will not be able to count on a specific app context (even if you could request a specific context, that may have already been allocated to some other component, etc.)

    When I've had to deal with something like this, I've parameterized my script's knowledge of the context path, computed it in Java/JSP code, and passed the result to the script. I've attached an example of one way to do this.
    • SystemAdmin
      SystemAdmin
      181 Posts
      ACCEPTED ANSWER

      Re: Context root problem

      ‏2009-05-06T15:57:40Z  in response to SystemAdmin
      Thanks! Yes, I definitely agree. I was looking for some tips to handle the context root in scenarios where javascript needs to be aware of it. You answered my question. Thanks again.
      • SystemAdmin
        SystemAdmin
        181 Posts
        ACCEPTED ANSWER

        Re: Context root problem

        ‏2009-05-26T20:07:47Z  in response to SystemAdmin
        Hi,
        I am having the same problem...

        I am creating an iWidget for Business Spaces...

        I just want to display an image without hardcoding the contentroot in the src attribute e.g.

        <img id="_IWID_image" src="/MYCONTEXT/images/myimage.gif">

        I tried using a class of "iw-RewriteURI" e.g.

        <img id="_IWID_image" src="images/myimage.gif" class="iw-RewriteURI">

        but it didn't work.
        There must be a way to do this in markup, anyone know???
        From the iWidget Primer...
        "The specification provides two means for requesting assistance in rewriting URIs:
        1. An optional method is defined (iContext.io.rewriteURI) that accepts a URI as a parameter and returns a URI that can be used
        to access the underlying resource.
        2. A class of "iw-RewriteURI" can be placed on any element and the iContext replaces the value of the URI-oriented attribute
        of that element (for example the "src" attribute on an tag or the "href" attribute of an tag) with what would have
        been returned if the optional method iContext.io.rewriteURI had been called. If this method is not implemented, the value of
        the URI is left unchanged."
        • jasonCornell
          jasonCornell
          7 Posts
          ACCEPTED ANSWER

          Re: Context root problem

          ‏2009-05-26T20:10:53Z  in response to SystemAdmin
          Hi barrybevel.

          At this time Widget Factory provides no support for Business Spaces and supports deployment to IBM Mashup Center only.

          Thanks

          Jason