I am able to connect to alfresco and I’m trying to return a list of users from three groups, but it seems that I don’t quite understand how callbacks work, because it’s returning all three groups to my function at once, rather than having the function return the result of each set of users from their respective groups.
Expand|Select|Wrap|Line Numbers
- // returns Group[]
- public function EditUser_GetUserGroups() : Array
- {
- var wsl : WebScriptLoader = WebScriptLoader.Load(
- "service/d3/person/groups",
- {
- alf_method: "GET",
- alf_ticket: alfrescoTicket,
- username: this.userName
- },
- after_getUserGroups
- );
- wsl.userCallback = pullHandler();
- return undefined;
- }
- private function after_getUserGroups(wsl : WebScriptLoader) : void
- {
- wsl.userCallback(wsl.responseData.children());
- EditUser_GetUserGroup(wsl.responseData.children());
- }
- public function EditUser_GetUserGroup(groupName) : Array
- {
- groupName = gotUserGroups2(groupName);
- var wsl : WebScriptLoader = WebScriptLoader.Load(
- "service/d3/person/group",
- {
- alf_method: "GET",
- alf_ticket: alfrescoTicket,
- groupname: groupName
- },
- after_getUserFromGroup
- );
- wsl.userCallback = pullHandler();
- trace("groupName :"+groupName);
- return undefined;
- }
- private function gotUserGroups2(x : XMLList ) : XMLListCollection
- {
- var items : Array = [];
- for each(var e : XML in x)
- {
- items.push("<group name='"+groupNameFunction2(e)+"'><users/></group>");
- }
- // items[items.length] = "<groups>";
- items.sort();
- var myXml:String = "<groups>";
- for(var a:int = 0; a<items.length; a++)
- {
- myXml += items[a];
- }
- //myXml = myXml.substring(4, myXml.length);
- myXml += "</groups>";
- //trace(myXml);
- var groupsXML:XML = new XML(myXml);
- //trace(groupsXML);
- var groupData:XMLListCollection = new XMLListCollection(groupsXML.group.@name);
- return groupData;
- }
- private function groupNameFunction2(item:Object):String
- {
- var s : String = item.name;
- s = s.replace("/sys:system/sys:authorities/", "");
- s = s.replace(new RegExp("usr:GROUP_", "g"), "");
- s = s.replace("/", " ");
- s=s.replace(new RegExp("_x\\d+_", "g"), " ");
- return s;
- }
- private function after_getUserFromGroup(wsl : WebScriptLoader) :void
- {
- var x : XMLList = wsl.responseData.children();
- // var uifg : UserInfoFromGroups = new UserInfoFromGroups(x.userName[0].toString());
- wsl.userCallback(x);
- }
How can I have the function process each group separately as Developers followed by Group1, then TestGroup?
Is there a way to delay a callback until it’s complete? I’ve tried ws1.onComplete.
Any suggestions would be helpful and thanx n advance