views:

57

answers:

1

I'm working with Extjs 2.2.1 with Alfresco 3.2 enterprise.

I would like to update the ticket that handles authentication to the alfresco server on components that have been loaded during login. This ticket expires after a set time and this is why I will need to update the ticket.

Options that do not seem viable for me(but please let me know if I'm wrong):

  1. Reload the components to reload the call parameters - I can't do this because it resets whatever the user was previously working on (ie. Tree panel gets reloaded, grid filters reset, etc). The actual webpage never reloads as everything uses ajax calls to update things on the page.

  2. Create a global variable that stores the ticket and attach it as a call parameter with any ajax calls - Any components that were loaded during login will still use the original ticket to make calls to the server.

A: 

Try something like this

Ext.onReady(function() {
  var token = new Ext.util.MixedCollection();
  token.add('id', 'THE_TOKEN_ID');
  Ext.ComponentMgr.register('token', token);
});

Attach event listeners to the MixedCollection that updates any components that care about the token.

// now you need all the event listeners
var token = Ext.getCmp('token');
var component = Ext.getCmp('some_component_that_needs_ajax');
token.on('replace', function(key, value, original) {
  if(key == 'id') {
    component.params.token_id = value; // update the new value
  }
});

Whenever the token needs updating, do

var token = Ext.getCmp('token');
token.replace('id', 'THE_NEW_TOKEN_ID');

What's going on here is:

  1. You create a MixedCollection to contain information about your token.
  2. Any components which need to be updated when there is a new token should be updated in the handler for the replace listener for the token MixedCollection.
  3. When you get a new token id, use MixedCollection.replace to update the id key with the new token id.
  4. The replace handler will fire, and the listeners which updates all dependent components.
Jesse Dhillon