HPA.Framework
Methods
addContextObjectToActivity
-
context
-
[silentType]
Adds a context object or objects to an activity. If only one parameter is given, prompts the user to add the objects to either the current activity or to a new one. If an activity is not yet saved, adding to the current activity is disabled. If a second parameter is given (see below for valid values), adds the objects without prompting the user.
Usage Example:
var ctxObj = HPA.Framework.createContextObject( "QCCR1123", "ALM CR", "button doesn't work...");
HPA.Framework.isValidContextObject(ctxObj);
var silentType = "current"; //optional
HPA.Framework.addContextObjectToActivity(ctxObj,silentType);
Parameters:
-
context
Object | ArrayA valid context object or an array of valid context objects. Create valid context objects using the createContextObject factory method. Test existing context objects for validity using the isValidContextObject method. For an invalid object, obtain detailed information using the validateContextObject method.
-
[silentType]
String optionalThis parameter is used by the developer to add a context object without opening the Add Context Object dialog box. The developer determines whether to open a new activity for this context object or to remain in the current activity. This parameter has two valid values:
- "new" - Create a new activity and add the context object to it.
- "current" - Add the context object to the current activity if the activity exists, or, if there is no activity, create a new activity and add the context object to it.
If a different string is given, it will be ignored and the user will be prompted to add to the current activity or to a new one.
createContextObject
-
objectId
-
dataType
-
displayName
-
[metaData]
Creates a valid context object based on the arguments provided. After the object is created, it is validated by calling isValidContextObject. Use this method to create an entry point object, for example, before setting the current context of an app or adding the context object to an activity. A context object represents a business entity that is provided to the HP Anywhere framework by apps. For details, see the User Guide and Events Sample App Cookbook.
Usage Example:
//the following information will be used to extend our context object
var myData = {
submitter: "John",
owner: "Jason"
};
// construct a context object
var contextObject = HPA.Framework.createContextObject('ID', 'DEFECT', 'Login failure', JSON.stringify(myData));
// and an example without extending the context object
var ctxObj = HPA.Framework.createContextObject( "QCCR1123", "ALM CR", "button doesn't work...");
Parameters:
-
objectId
StringID of the context object; globally unique identifier.
-
dataType
StringType of data of this context object.
-
displayName
StringName of the context object. Maximum length: 100 characters.
-
[metaData]
String optionalAn arbitrary string containing extra information. Maximum length: 2000 characters.
Returns:
createEntryPointObject
-
appId
-
entryPointId
-
displayName
Creates a valid entry point object based on the arguments provided. Use this method to create an entry point object, for example, before setting the current context of an app.
An entry point object represents a specific app page that is provided to the HP Anywhere framework by apps. For details, see the User Guide and Events Sample App Cookbook.
Usage Example:
HPA.Framework.createEntryPointObject("DefectManager","defect","open defect");
Parameters:
Returns:
isAppAvailable
-
targetAppId
Use this method for cross-app use cases, for example, before opening a different app using the openEntryPoint method. Checks whether the given app is enabled for the current user.
Usage Example:
HPA.Framework.isAppAvailable("DefectManager");
Parameters:
-
targetAppId
StringID of the required app. The ID of the app containing the entry point (app specific page).
Returns:
isValidContextObject
-
contextObject
Use this utility method to make sure that a given object is a valid context object for the HPA framework. Validate that the context object is in the correct structure. This method returns a boolean value. If an object is invalid, use the validateContextObject method to get detailed information.
Usage Example:
var ctx = { objectId: objectId,
dataType: dataType,
displayName: displayName,
metaData: metaData || '' };
HPA.Framework.isValidContextObject(ctx);
Parameters:
-
contextObject
ObjectContext object to be tested for validity.
Returns:
openEntryPoint
-
targetAppId
-
entryPoint
-
[contextObjects]
-
[callback]
-
[scope]
-
[reuse]
Opens a specific entry point in a specific app with optional context objects. Use this method for cross-app use cases (for example, to open an entry point (app specific page) in the same app, or to open a different entry point (app page) in another app).
Usage example:
var ctxObj = HPA.Framework.createContextObject( "QCCR1123", "ALM CR", "button doesn't work...");
HPA.Framework.openEntryPoint("DefectManager", "open", [ ctxObj ]);
Important: This method is different from the global openEntryPoint() method.
Important: Ajax server requests are asynchronous, and this call will return before the response has been received. Process any returned data in a callback function.
Parameters:
-
targetAppId
StringTarget app ID. The ID of the app containing the entry point (app specific page).
-
entryPoint
StringEntry point ID. The ID of the actual entry point (app specific page).
-
[contextObjects]
Array optionalAn array of context objects. An array of valid context objects. Create valid context objects using the createContextObject factory method; test existing context objects for validity using the isValidContextObject method; for an invalid object, obtain detailed information using the validateContextObject method.
-
[callback]
Function optionalCallback function to be called when the entry point opens.
-
[scope]
Object optionalThe scope ('this' reference) in which the callback function is executed.
-
[reuse]
Boolean optional[Desktop Edition] Whether to reuse the existing app instance.
openInnerPoint
-
displayName
-
callback
-
scope
-
[params]
-
[validationCallback]
-
[removeCallback]
[Desktop Edition]
Mark the user state of the current app as an internal navigation point, so that the end-user can return to this point via the drop-down navigation menu.
Important: Ajax server requests are asynchronous, and this call will return before the response has been received. Process any returned data in a callback function.
Parameters:
-
displayName
StringName to be displayed in the drop-down navigation menu.
-
callback
FunctionCallback function to be called when the navigation point is selected, if the validation callback did not return False.
-
scope
ObjectThe scope ('this' reference) in which the callback functions are executed.
-
[params]
Object optionalParameters to be passed as arguments when the callbacks are called.
-
[validationCallback]
Function optionalCallback function to be called just before switching to this page. If the function returns False, navigation to this page is canceled.
-
[removeCallback]
Function optional[since HP Anywhere 10.01] Callback function to be called after this page is removed.
saveState
-
state
Persist an object representing the current app state. There is no restriction on the object format; maximum size is 100kB (102,400 bytes). The state is saved per user, per activity, per app instance. When the user enters the app in the activity again, the last saved state is provided to the app, via its openEntryPoint method, params argument.
Parameters:
-
state
AnyAn object in arbitrary format.
setActions
-
hideActions
Hide or show the Action bar.
Parameters:
-
hideActions
BooleanTrue to hide the Action bar, false to show it.
setCurrentContext
-
[context]
-
[entryPointObject]
Notify the HP Anywhere framework of the current context of the app. If the user adds a post in the timeline, objects in the current context that are not in the current activity are automatically added to the activity (no objects are deleted or updated).
Usage Example:
// the following information will be used to extend our context object.
var myData = {
submitter: "John",
owner: "Jason"
};
// construct a context object
var contextObject = HPA.Framework.createContextObject('ID', 'DEFECT', 'Login failure', JSON.stringify(myData));
// notify HPA framework that the context of our app instance has changed.
// (upon user collaboration e.g. post,adding participant, this object will be silently added to activity's context.
HPA.Framework.setCurrentContext([contextObject]);
// create an entry point object which represents "defect list" page of DefectManger app
var entryPointObject = HPA.Framework.createEntryPointObject('DefectManager', 'DEFECT_LIST', 'defects list');
// notify HPA framework that the context of our app instance has changed.
// (upon user collaboration e.g. post,adding participant, this object will be silently added to activity's context.
HPA.Framework.setCurrentContext([], entryPointObject);
Parameters:
-
[context]
Object | Array optionalA valid context object or an array of valid context objects. Create valid context objects using the factory method. Test existing context objects for validity using the isValidContextObject method. For an invalid object, obtain detailed information using the validateContextObject method.
-
[entryPointObject]
Object optionalA valid entry point object. Create valid entry point objects using the createEntryPointObject factory method.
setReady
-
readyState
Notify the HPA framework that the app is ready to accept entry point requests. This method must be called by the app developer whenever the app is loaded.
Usage example:
HPA.Framework.setReady(true);
Parameters:
-
readyState
Boolean | Object[Object is deprecated since HP Anywhere 10.02; use True and see below for alternatives.] Either an object with the properties listed below, describing the relevant app capabilities, or simply the boolean True.
-
[hasDefaultAction]
Boolean optional[Deprecated since HP Anywhere 10.02, use setActions to modify buttons.] [Smartphone Edition] Show an integrated default Action button in the Actions bar. The app needs to handle the DefaultAction entry point.
-
[moreActions]
Array optional[Deprecated since HP Anywhere 10.02, use setActions to modify buttons.] [Smartphone Edition] Show integrated menu items in the More menu. The app needs to handle the MoreActions entry point.
-
[hasAutoContext]
Boolean optional[Deprecated since HP Anywhere 10.02, use setCurrentContext to auto-inject context.] Support auto-injection of context objects. The app needs to handle the GetContextObjects entry point.
-
validateContextObject
-
contextObject
Use this utility method to retrieve an array of messages that explains why a given object is not a valid context object for the HPA framework. Note: Messages are always returned in English.
Usage Example:
var ctxObj = HPA.Framework.createContextObject( "QCCR1123", "ALM CR", "button doesn't work...");
HPA.Framework.validateContextObject(ctxObj);
Parameters:
-
contextObject
ObjectContext object to be tested for validity.