Previous Topic: JavaScript Business Logic Task Handlers

Next Topic: Default Installed Handlers

JavaScript Method Reference

A JavaScript handler implements the same methods as the Java BLTHAdapter class:

handleStart(BLTHContext ctx)
handleSetSubject(BLTHContext ctx)
handleValidation(BLTHContext ctx)
handleSubmission(BLTHContext ctx)

Example:

// This sample illustrates BLTH implemented in java script
// It verifies that a tag specified in the task is unique in 
// the environment function 

handleValidation(blthContext, errorMsg) {
    var taskTag = null;
    var currentTask = blthContext.getAdminTask();
    if(currentTask != null) {
        taskTag = blthContext.getAdminTask().getTaskTag();
    }

    if(taskTag == null) {
        errorMsg.reference = "Failed to get the task tag";
        return false;
    }
    try {
        task = blthContext.getAdminTaskProvider().findByTag(taskTag);
    } catch(exception) {
        // there is no task with this tag
        return true;
    }

    if (!currentTask.equals(task)) {
        errorMsg.reference = "Tag must be unique: " + taskTag;
        return false;
    } else {
        // the same task
    }

    return true;
}

IMSAPI Class References

The following code samples demonstrate how to reference imsapi classes:

Sample 1:

function handleValidation(BlthContext, errorMessage) {
   var imsapi = Packages.com.netegrity.llsdk6.imsapi
   var expr = new imsapi.search.SearchExpression("uid",
      imsapi.type.OperatorType.EQUALS,"bhanu")
   return true
}

Sample 2:

function handleValidation(BlthContext, errorMessage) {
   var searchPackage = Packages.com.netegrity.llsdk6.imsapi.search
   var typePackage = Packages.com.netegrity.llsdk6.imsapi.type
   var expr = new searchPackage.SearchExpression("uid",
      typePackage.OperatorType.EQUALS, "bhanu")
   return true
}

Sample 3:

function handleValidation(BlthContext, errorMessage) {
   var expr = new
   Packages.com.netegrity.llsdk6.imsapi.search.SearchExpression("uid",
      Packages.com.netegrity.llsdk6.imsapi.type.OperatorType.EQUALS, "bhanu")
   return true
}


Copyright © 2009 CA. All rights reserved.