Results 1 to 4 of 4

Thread: Globally Available Objects

  1. #1
    Join Date
    Jan 2011
    Posts
    2

    Default Globally Available Objects

    Is there way to set a variable in a webscript that all other webscripts have access to within a page?

    Here's my situation. I want to pull down some content from and instance of Alfresco based on the incomming URL. This one call to Alfresco will contain 90% of what I need for that page. However, there will be that 10% I have to use other webscripts for. Here's the rub: these other webscripts will need to call other information based on what comes down with that main content.

    Is there a way to set this main content into a variable that is available to every webscript that is used within the page object? This data does not need to live beyond the life of the page. It seems a rather large waste of overhead for me to have to slice up the url and figure out what I need within every webscript. I'd rather just do that once.

  2. #2

    Default

    Yes we do this kind of technique in Alfresco Share to cache common remote API calls for a page render but to continue to keep component isolation.

    Example:

    In earliest component:

    Code:
          context.setValue("site-title", siteTitle);
    In later component:

    Code:
          var siteTitle = context.properties["site-title"];
          if (siteTitle == null)
          {
             //... do the call ourselves as value not cached yet
          }
    Hope this helps,

    Kev

  3. #3
    Join Date
    Dec 2008
    Posts
    3

    Default

    Great tip.

    Thanks!

  4. #4
    Join Date
    Jan 2011
    Posts
    2

    Default

    Thanks so much! Great tip. I actually needed to cache some stuff so I wrote an interceptor that captures the data I needed before it hit surf, then inserted it via java. However, as I'll be using surf for several more projects your tip will be very useful.

    Much thanks!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •