BBjJettyContext::getAttributeNames

Description

In BBj 15.00 and higher, this method returns a BBjVector containing the name of configured attributes within the context.

Syntax

Return Value

Method

BBjVector

getAttributeNames()

Parameters

None.

Return Value

A BBjVector containing the names of the attributes.

Remarks

The BBjJettyContext provides a repository for run-time attributes which are stored as a name - value pair.

Example

declare BBjServletData data!
data! = BBjAPI().getServletData()
declare MyServlet myServlet!
myServlet! = new MyServlet()
data!.setCallback(data!.ON_WEB_CONNECTION, myServlet!, "myMethod")
process_events
class public MyServlet
    field private BBjNumber chan
    field private BBjHttpSession session!
    field private BBjHttpRequest request!
    field private BBjHttpResponse response!
    field private BBjJettyContext context!

    method public void myMethod(BBjServletEvent p_event!)
        #chan = UNT
        #request! = cast(BBjHttpRequest,p_event!.getHttpRequest())
        #session! = cast(BBjHttpSession,#request!.getSession())
        #context! = cast(BBjJettyContext,#session!.getContext())

        #response! = p_event!.getHttpResponse()
        #response!.setContentType("text/html")
        open (#chan)"JSERVLET"

        print (#chan)"<html>"
        print (#chan)"<body>"
        print (#chan)"<h1>>BBj Context Test</h1>"
        print (#chan)"<h3>Running in context<b>"
        print (#chan)#context!.getContextName()
        print (#chan)"</b></h3>"
        print (#chan)"<hr>"
        #renderAttributes()
        print (#chan)"</body>"
        print (#chan)"</html>"
        close (#chan)
    methodend
    method public void renderAttributes()
        vectAttribNames! = #context!.getAttributeNames()
        print (#chan)"<table>"
        print (#chan)"<tr>"
        print (#chan)"<td>Attribute Name</td>"
        print (#chan)"<td> </td>"
        print (#chan)"<td>value</td>"
        print (#chan)"</tr>"
        if (vectAttribNames!.size()) then
            for i = 0 to vectAttribNames!.size() -1
                n$ = vectAttribNames!.get(i)
                o! = #context!.getAttribute(n$)
                isMyClass = 0
                mc! = cast(MyClass,o!, err = *next); isMyClass = 1
                if (isMyClass) then
                    v$ = mc!.getFirstName() + " " + mc!.getLastName()
                else
                    v$ = str(o!)
                endif
                print (#chan)"<tr>"
                print (#chan)"<td>" + n$ + "</td>"
                print (#chan)"<td />"
                print (#chan)"<td>" + v$ +"</td>"
                print (#chan)"</form>"
                print (#chan)"</tr>"
            next i
        endif
        print (#chan)"</form>"
        print (#chan)"</table>"
    methodend
classend

See Also

BBjAPI

BBxServletContext

BBjJettyContext