Packagecom.j2flex.core
Classpublic dynamic class J2FlexService
InheritanceJ2FlexService Inheritance mx.rpc.remoting.RemoteObject

The J2FlexService class gives you access to the J2Flex Service Java class using Action Message Format (AMF) encoding. You can use the J2FlexService class in ActionScript and as a MXML tag.

ActionScript Example
Using the J2FlexService class in ActionScript:

  private var service:J2FlexService;
  
  private function init():void
  {
      service = new J2FlexService();
      service.destination = "Destination";
      service.showBusyCursor = true;
  }
  

MXML Example
You can also using the J2FlexService class as a MXML tag, with the following namespace: xmlns:j2flex="http://www.j2flex.com/j2flex". The <j2flex:J2FlexSerivce/> tag inherits all the attributes of its superclass mx.rpc.remoting.RemoteObject and adds the following tag attributes:

  <j2flex:J2FlexService
    Properties
    id="No default."
    showBusyCursor="false|true"
  
    Events
    fault="No default."
    result="No default."
  />
  

See also

mx.rpc.remoting.RemoteObject.


Public Properties
 PropertyDefined by
  consumerClientId : String
[read-only] Client generated id for point-to-point messaging between J2Flex and Flex clients.
J2FlexService
  domain : String
[read-only] Domain from the current Flex session.
J2FlexService
  domainInfo : DomainInfo
[read-only] Domain info for the current domain.
J2FlexService
  langId : int
[read-only] The language id for the current Flex session.
J2FlexService
  roles : Array
[read-only] Array with all groups for the current user.
J2FlexService
  session : String
[read-only] The id of the current Flex session.
J2FlexService
  showBusyCursor : Boolean
If true, a busy cursor is displayed while the J2FlexService is executing.
J2FlexService
  userId : int
[read-only] The id of the user for the current Flex session.
J2FlexService
Public Methods
 MethodDefined by
  
Creates a new J2FlexService.
J2FlexService
  
addUserToRole(userId:int, groupId:int, roleManager:Boolean = false):AsyncToken
Adds a user to a specified group.
J2FlexService
  
createObject(object:Object):AsyncToken
Creates new object of the given type.
J2FlexService
  
deleteObject(object:Object, deleteLinked:Boolean = false):AsyncToken
Deletes a object with given obj_type and obj_id.
J2FlexService
  
getAllRights(object:Object):AsyncToken
Returns all rights that users and groups have to this object.
J2FlexService
  
getArticle(artUUID:String, withRights:Boolean = true, showLong:Boolean = true):AsyncToken
Returns details of the article with the given UUID.
J2FlexService
  
getArticles(menuUUID:String, withRights:Boolean = true):AsyncToken
Returns all articles connected with the given menu.
J2FlexService
  
getContainers(menuUUID:String, withRights:Boolean = true):AsyncToken
Return containers that are located on the given menu.
J2FlexService
  
getDomain():AsyncToken
Gets the domain for the Flex session.
J2FlexService
  
getDomainInfo():AsyncToken
Returns the domain info for the current domain.
J2FlexService
  
getLangId():AsyncToken
Returns the actual language for the Flex session, or the default language if it was not set.
J2FlexService
  
getMenuPath(menuId:int, showRoot:Boolean = true, withRights:Boolean = true):AsyncToken
Returns a RecordSet with all the ancestors of the given menu, the root ancestor at the top.
J2FlexService
  
getMenus(showRoot:Boolean = true, withRights:Boolean = true, openedIds:String = null):AsyncToken
Returns menus, sorted in the same order as they are located in the tree.
J2FlexService
  
getObjectRights(object:Object):AsyncToken
Returns the right that the current user has to this object.
J2FlexService
  
getObjects(sql:String, collection:ListCollectionView = null, withRights:Boolean = true, params:Array = null, treeOptions:TreeOptions = null):AsyncToken
Executes the query and returns the data as a RecordSet value object.
J2FlexService
  
getRoles():AsyncToken
Returns an array with all groups for the current user.
J2FlexService
  
getRootMenuPath(menuId:int, rootId:int, showRoot:Boolean = true, withRights:Boolean = true):AsyncToken
Returns a Recordset with all the ancestors of the given menu, the root ancestor at the top.
J2FlexService
  
getRootMenus(rootId:int, showRoot:Boolean = true, withRights:Boolean = true, openedIds:String = null):AsyncToken
Returns menus, sorted in the same order as the are located in the tree.
J2FlexService
  
getSession():AsyncToken
Returns the id of the current Flex session.
J2FlexService
  
getUserId():AsyncToken
Returns the current user id for the Flex session.
J2FlexService
  
isUserInRole(groupIdOrName:Object):AsyncToken
Checks if the current user belongs to the group with the given id or the given name.
J2FlexService
  
loginUser(username:String, password:String, clientId:String = null):AsyncToken
Logs the user in.
J2FlexService
  
logoutUser():AsyncToken
Logs the user out.
J2FlexService
  
removeUserFromRole(userId:int, groupId:int):AsyncToken
Remove a user from a group.
J2FlexService
  
setConsumerClientId(clientId:String = null):AsyncToken
Stores the client generated id used for point-to-point messaging between J2Flex and Flex clients.
J2FlexService
  
setDomain(domain:String):AsyncToken
Saves domain for the Flex session.
J2FlexService
  
setLang(langId:int):AsyncToken
Sets the current language id for the Flex session.
J2FlexService
  
setRoleRight(objType:int, objId:int, groupId:int, right:int):AsyncToken
Sets group right on the object.
J2FlexService
  
setUserRight(objType:int, objId:int, userId:int, right:int):AsyncToken
Sets user right on the object.
J2FlexService
  
updateObject(object:Object):AsyncToken
Updates the object.
J2FlexService
Events
 EventSummaryDefined by
   Dispatched when an J2FlexService call fails.J2FlexService
   Dispatched when an J2FlexService call returns successfully.J2FlexService
Property detail
consumerClientIdproperty
consumerClientId:String  [read-only]

Client generated id for point-to-point messaging between J2Flex and Flex clients.

Implementation
    public function get consumerClientId():String
domainproperty 
domain:String  [read-only]

Domain from the current Flex session.

Implementation
    public function get domain():String
domainInfoproperty 
domainInfo:DomainInfo  [read-only]

Domain info for the current domain.

Implementation
    public function get domainInfo():DomainInfo
langIdproperty 
langId:int  [read-only]

The language id for the current Flex session.

Implementation
    public function get langId():int
rolesproperty 
roles:Array  [read-only]

Array with all groups for the current user.

Implementation
    public function get roles():Array
sessionproperty 
session:String  [read-only]

The id of the current Flex session.

Implementation
    public function get session():String
showBusyCursorproperty 
showBusyCursor:Boolean  [read-write]

If true, a busy cursor is displayed while the J2FlexService is executing.

The default value is false.

Implementation
    public function get showBusyCursor():Boolean
    public function set showBusyCursor(value:Boolean):void
userIdproperty 
userId:int  [read-only]

The id of the user for the current Flex session.

Implementation
    public function get userId():int
Constructor detail
J2FlexService()constructor
public function J2FlexService()

Creates a new J2FlexService.

Method detail
addUserToRole()method
public function addUserToRole(userId:int, groupId:int, roleManager:Boolean = false):AsyncToken

Adds a user to a specified group.

Parameters
userId:int — The id of the user.
 
groupId:int — The id of the group.
 
roleManager:Boolean (default = false) — Indicates if the user is a group manager.

Returns
AsyncToken — AsyncToken which can be used to respond to the success or failure of the operation.
createObject()method 
public function createObject(object:Object):AsyncToken

Creates new object of the given type.

Parameters
object:Object — The object to create. The object must contain the obj_type and obj_id properties. The obj_type property must be set to a valid object type.

Returns
AsyncToken — AsyncToken which can be used to respond to the success or failure of the operation.

Throws
— If the object argument has no obj_type or obj_id property.
deleteObject()method 
public function deleteObject(object:Object, deleteLinked:Boolean = false):AsyncToken

Deletes a object with given obj_type and obj_id.

Parameters
object:Object — The object to delete. The object must contain the obj_type and obj_id properties.
 
deleteLinked:Boolean (default = false) — If true, linked objectes will be deleted too.

Returns
AsyncToken — AsyncToken which can be used to respond to the success or failure of the operation.

Throws
— If the object argument has no obj_type or obj_id property.
getAllRights()method 
public function getAllRights(object:Object):AsyncToken

Returns all rights that users and groups have to this object.

Parameters
object:Object — The object to get rights for. The object must contain the obj_type and obj_id properties.

Returns
AsyncToken — AsyncToken which can be used to respond to the success or failure of the operation.

Throws
— If the object argument has no obj_type or obj_id property.
getArticle()method 
public function getArticle(artUUID:String, withRights:Boolean = true, showLong:Boolean = true):AsyncToken

Returns details of the article with the given UUID.

Parameters
artUUID:String — The UUID of the article.
 
withRights:Boolean (default = true) — Indicates if the rights are checked or not.
 
showLong:Boolean (default = true) — Show the long text of the article or not.

Returns
AsyncToken — AsyncToken which can be used to respond to the success or failure of the operation.

Throws
— If the artUUID argument is null or a empty string.
getArticles()method 
public function getArticles(menuUUID:String, withRights:Boolean = true):AsyncToken

Returns all articles connected with the given menu.

Parameters
menuUUID:String — The UUID of the menu.
 
withRights:Boolean (default = true) — Indicates if the rights are checked or not. Return only readable articles for the current user.

Returns
AsyncToken — AsyncToken which can be used to respond to the success or failure of the operation.

Throws
— If the menuUUID argument is null or a empty string.
getContainers()method 
public function getContainers(menuUUID:String, withRights:Boolean = true):AsyncToken

Return containers that are located on the given menu.

Parameters
menuUUID:String — The UUID of the menu.
 
withRights:Boolean (default = true) — Indicates if the rights are checked or not. Return only readable containers for the current user.

Returns
AsyncToken — AsyncToken which can be used to respond to the success or failure of the operation.

Throws
— If the menuUUID argument is null or a empty string.
getDomain()method 
public function getDomain():AsyncToken

Gets the domain for the Flex session. If the operation call returns successfully the domain property will be set.

Returns
AsyncToken — AsyncToken which can be used to respond to the success or failure of the operation.
getDomainInfo()method 
public function getDomainInfo():AsyncToken

Returns the domain info for the current domain. If the operation call returns successfully the domainInfo property will be set.

Returns
AsyncToken — AsyncToken which can be used to respond to the success or failure of the operation.

See also

getLangId()method 
public function getLangId():AsyncToken

Returns the actual language for the Flex session, or the default language if it was not set. If the operation call returns successfully the langId property will be set.

Returns
AsyncToken — AsyncToken which can be used to respond to the success or failure of the operation.
getMenuPath()method 
public function getMenuPath(menuId:int, showRoot:Boolean = true, withRights:Boolean = true):AsyncToken

Returns a RecordSet with all the ancestors of the given menu, the root ancestor at the top. The method uses the root menu of the current domain as the root of hierarchy. If the domain is unknown, it takes the menu with id=0.

Parameters
menuId:int — The id of the menu.
 
showRoot:Boolean (default = true) — Indicates if the root menu is returned or not.
 
withRights:Boolean (default = true) — Indicates if the rights are checked or not.

Returns
AsyncToken — AsyncToken which can be used to respond to the success or failure of the operation.
getMenus()method 
public function getMenus(showRoot:Boolean = true, withRights:Boolean = true, openedIds:String = null):AsyncToken

Returns menus, sorted in the same order as they are located in the tree. The method uses the root menu of the current domain as the root of hierarchy. If the domain is unknown, it takes the menu with id=0.

Parameters
showRoot:Boolean (default = true) — Indicates if the root menu is returned or not.
 
withRights:Boolean (default = true) — Indicates if the rights are checked or not.
 
openedIds:String (default = null) — Comma-separeted string with the IDs of open nodes in the tree.

Returns
AsyncToken — AsyncToken which can be used to respond to the success or failure of the operation.
getObjectRights()method 
public function getObjectRights(object:Object):AsyncToken

Returns the right that the current user has to this object.

Parameters
object:Object — The object to get rights for. The object must contain the obj_type and obj_id properties.

Returns
AsyncToken — AsyncToken which can be used to respond to the success or failure of the operation.

Throws
— If the object argument has no obj_type or obj_id property.
getObjects()method 
public function getObjects(sql:String, collection:ListCollectionView = null, withRights:Boolean = true, params:Array = null, treeOptions:TreeOptions = null):AsyncToken

Executes the query and returns the data as a RecordSet value object. The query uses the current user (when withRights is true) and the current languageId. When a collection is passed to the function, it will be automatically filled with data, when the operation call returns successfully.

Parameters
sql:String — The query. Can contain parameter, with parameter use '?' as placeholders.
 
collection:ListCollectionView (default = null) — Collection to fill with result data.
 
withRights:Boolean (default = true) — Indicates if the rights are checked or not. Return only readable objects for the current user.
 
params:Array (default = null) — An array with parameter values. The size of the array must be equal to the number of the placeholders in the query.
 
treeOptions:TreeOptions (default = null) — Various options of getting information from the tree structure.

Returns
AsyncToken — AsyncToken which can be used to respond to the success or failure of the operation.

Throws
— If the sql argument is null or a empty string.

See also

com.j2flex.vo.RecordSet
com.j2flex.vo.TreeOptions
mx.collections.ListCollectionView
getRoles()method 
public function getRoles():AsyncToken

Returns an array with all groups for the current user. If the operation call returns successfully the roles property will be set.

Returns
AsyncToken — AsyncToken which can be used to respond to the success or failure of the operation.
getRootMenuPath()method 
public function getRootMenuPath(menuId:int, rootId:int, showRoot:Boolean = true, withRights:Boolean = true):AsyncToken

Returns a Recordset with all the ancestors of the given menu, the root ancestor at the top.

Parameters
menuId:int — The id of the menu.
 
rootId:int — The id of the root ancestor.
 
showRoot:Boolean (default = true) — Indicates if the root menu is returned or not.
 
withRights:Boolean (default = true) — Indicates if the rights are checked or not.

Returns
AsyncToken — AsyncToken which can be used to respond to the success or failure of the operation.
getRootMenus()method 
public function getRootMenus(rootId:int, showRoot:Boolean = true, withRights:Boolean = true, openedIds:String = null):AsyncToken

Returns menus, sorted in the same order as the are located in the tree.

Parameters
rootId:int — The root of the tree structure.
 
showRoot:Boolean (default = true) — Indicates if the root menu is returned or not.
 
withRights:Boolean (default = true) — Indicates if the rights are checked or not.
 
openedIds:String (default = null) — Comma-separeted string with the IDs of open nodes in the tree.

Returns
AsyncToken — AsyncToken which can be used to respond to the success or failure of the operation.
getSession()method 
public function getSession():AsyncToken

Returns the id of the current Flex session. If the operation call returns successfully the session property will be set.

Returns
AsyncToken — AsyncToken which can be used to respond to the success or failure of the operation.
getUserId()method 
public function getUserId():AsyncToken

Returns the current user id for the Flex session. If the operation call returns successfully the userId property will be set.

Returns
AsyncToken — AsyncToken which can be used to respond to the success or failure of the operation.
isUserInRole()method 
public function isUserInRole(groupIdOrName:Object):AsyncToken

Checks if the current user belongs to the group with the given id or the given name.

Parameters
groupIdOrName:Object — The id or a name of a group.

Returns
AsyncToken — AsyncToken which can be used to respond to the success or failure of the operation.

Throws
— If the groupIdOrName argument is not a integer or a string. If the groupIdOrName argument is a empty string.
loginUser()method 
public function loginUser(username:String, password:String, clientId:String = null):AsyncToken

Logs the user in. Sets the username and password as credentials for the J2FlexService. Set the parameters user_id (int), logged_in (Boolean) and u_tech_name (String) for the Flex session. Returns true if the authentication was successful, false otherwise.

Parameters
username:String — The username.
 
password:String — The password.
 
clientId:String (default = null) — The client generated id.

Returns
AsyncToken — AsyncToken which can be used to respond to the success or failure of the operation.

Throws
— If the username and/or password is null or a ampty string.
logoutUser()method 
public function logoutUser():AsyncToken

Logs the user out. Removes the parameters user_id, logged_id and u_tech_name from the Flex session. Prefers also a logout on the J2FlexSerivce.

Returns
AsyncToken — AsyncToken which can be used to respond to the success or failure of the operation.
removeUserFromRole()method 
public function removeUserFromRole(userId:int, groupId:int):AsyncToken

Remove a user from a group.

Parameters
userId:int — The id of a user.
 
groupId:int — The id of the group to remove a user from.

Returns
AsyncToken — AsyncToken which can be used to respond to the success or failure of the operation.
setConsumerClientId()method 
public function setConsumerClientId(clientId:String = null):AsyncToken

Stores the client generated id used for point-to-point messaging between J2Flex and Flex clients. If no clientId or an empty string is passed to the function, a new clientId will be created by using the UIDUtil class.

Parameters
clientId:String (default = null) — A client generated id.

Returns
AsyncToken — AsyncToken which can be used to respond to the success or failure of the operation.

See also

mx.utils.UIDUtil;
setDomain()method 
public function setDomain(domain:String):AsyncToken

Saves domain for the Flex session. The domain property will be set to the new value.

Parameters
domain:String — The domain to set.

Returns
AsyncToken — AsyncToken which can be used to respond to the success or failure of the operation.

Throws
— If the domain argument is null or a empty string.
setLang()method 
public function setLang(langId:int):AsyncToken

Sets the current language id for the Flex session. The langId property will be set to the new value.

Parameters
langId:int — The id of language to set.

Returns
AsyncToken — AsyncToken which can be used to respond to the success or failure of the operation.
setRoleRight()method 
public function setRoleRight(objType:int, objId:int, groupId:int, right:int):AsyncToken

Sets group right on the object.

Parameters
objType:int — The type of the object.
 
objId:int — The id of the object.
 
groupId:int — The id of the group.
 
right:int — The rights to set to the group.

Returns
AsyncToken — AsyncToken which can be used to respond to the success or failure of the operation.

See also

setUserRight()method 
public function setUserRight(objType:int, objId:int, userId:int, right:int):AsyncToken

Sets user right on the object.

Parameters
objType:int — The type of the object.
 
objId:int — The id of the object.
 
userId:int — The id of the user.
 
right:int — The rights to set to the group.

Returns
AsyncToken — AsyncToken which can be used to respond to the success or failure of the operation.

See also

updateObject()method 
public function updateObject(object:Object):AsyncToken

Updates the object.

Parameters
object:Object — A object to update. The object must contain the obj_type and obj_id properties.

Returns
AsyncToken — AsyncToken which can be used to respond to the success or failure of the operation.

Throws
— If the object argument has no obj_tyoe or obj_id property.
Event detail
faultevent 
Event object type: com.j2flex.events.J2FlexFaultEvent

Dispatched when an J2FlexService call fails.

resultevent  
Event object type: com.j2flex.events.J2FlexResultEvent

Dispatched when an J2FlexService call returns successfully.