Announcement Announcement Module
Collapse
No announcement yet.
Globally Available Objects Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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

    Comment


    • #3
      Great tip.

      Thanks!

      Comment


      • #4
        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!

        Comment

        Working...
        X