BBjspCommandResult::addError (Deprecated)

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

Description

In BBj 16.0 and higher this method adds an error message to this BBjspCommandResult which will be available to other BBJSPPages that renders after the command was executed.

Syntax

Return Value

Method

void

addError(string key, string message)

Parameters

Variable

Description

key

the key

message

the message

Return Value

None.

Remarks

None.

Example

class public LogonCommand

    field public BBjspWebRequest request!
    field public BBjspWebResponse response!
    field public BBjspWebSession session!

    method public BBjspCommandResult execute(BBjspCommandContext context!)

        declare BBjspCommandResult result!
        #request! = context!.getRequest()
        #response! = context!.getResponse()
        #session! = request!.getSession()

        result! = context!.getResult()
        result!.setForward("fail")

        action$ = Request!.getParameter("action")

        if ("logon" = action$) then
            username$ = Request!.getParameter("userName")
            password$ = Request!.getParameter("password")

            if (password$ = "admin123") then
                #session!.setAttribute("USER_NAME",username$)
                result!.setForward( "logon_success" )
            else
                result!.addError("logonForm","Incorrect Username or Password")
            endif
        endif

        if ("logoff" = action$) then
            #session!.invalidate()
            result!.setForward( "logoff_success" )
            result!.addMessage("logonForm","User logged-off")
        endif

        context!.getJettyContext().getLogger().log("LogonCommand : " + result!.getForward())

        methodret result!
    methodend

classend

See Also