BBjspCommandResult (Deprecated)

The BBJSP system is deprecated. For new development, use BBxServlet.

Description

In BBj 16.0 and higher, this class provides a mechanism for a BBjspCommand to control the flow from the command's execution. When a BBjspCommand is executed by the BBJSP framework, the BBjspCommandContext is passed as a parameter to the BBjspCommand::execute method from which a BBjspCommandResult can be obtained.

Creation

BBJSP > BBjspCommandContext > BBjspCommandResult

The BBjspCommandResult is created through the following BBjspCommandContext method:

Return Value

Method

BBjspCommandResult

getResult()

Methods of BBjspCommandResult

Return Value

Method

void

addError(string key, string message)

void

addMessage(string key, string message)

void

addParameter(string name, string value)

string

getForward()

void

setForward(string forward)

Example

rem '=== This is a basic BBJSP Command.
rem '=== It must implement the BBjspCommand interface and have the execute method.
rem '===

class public MyCommand implements BBjspCommang

    rem '===
    rem '=== This method is defined in the BBjspCommand interface
    rem '===

    method public BBjspCommandResult execute(BBjspCommandContext context!)

        declare BBjspWebRequest request!
        declare BBjspWebResponse response!
        declare BBjspSessionData data!
        declare BBjJettyContext jettyContext!
        declare BBjspLogger logger!

        request! = context!.getRequest()
        response! = context!.getResponse()
        data! = context!.getBBjspSession()
        jettyContext! = context!.getJettyContext()
        logger! = context!.getLogger()

        logger!.log("Executing 'MyCommand'")

        rem '=== Get a BBjspCommandResult from the BBjspCommand Context
        result! = context!.getResult()

        rem '===
        rem '=== INSERT BUSINESS LOGIC
        rem '===
        rem '=== Set the outcome policy to 'success'
        result!.setForward("success")

        rem '=== Save any changes to the BB
        context!.saveBBjspSession()

        jettyContext!.getLogger().log("Completed execution of MyCommand in context "+context!.getContextName())

        methodret result!
    methodend

classend

See Also

BBJSP

BBjspCommandContext