BBjspPageContext

 

Description

In BBj 16.0 and higher, this class provides core functionality to BBJSP Widgets and is used internally by all BBJSP Page files.

A BBjspPageContext instance is available to BBJSP BBJSP Pages and Code Tags through the public field #PageContext! and is passed to all BBJSP Widget objects used on BBJSP pages. The BBjspPageContext instance provides access to attributes within the scope of either PAGE or SESSION and the BBJSPLogging module. which can be used by page developers to output specific information into the context's log files. BBJSP Widget developers are likely to need this class's methods as attributes set by a BBJSP Widget are available directly to a BBJSP Page through the BBJSP Expression Language.

Methods of BBjspPageContext

Return Value

Method

boolean

contains(string name)

void

flush()

Object

getAttribute(string name)

Object

getAttribute(string name, int scope)

BBjVector

getAttributeNames()

BBjVector

getAttributeNamesInScope(int scope)

BBjspSessionData

getBBjspSession()

string

getContextName()

BBjJettyContext

getJettyContext()

BBjspLogger

getLogger()

BBjspWebRequest

getRequest()

BBjspWebResponse

getResponse()

BBjspWebSession

getSession()

void

removeAttribute(string name)

void

removeAttribute(string name, int scope)

void

runPipelineByName(string name)

void

saveBBjspSession()

void

setAttribute(string name, Object object)

void

setAttribute(string name, Object object, int scope)

Remarks

The examples demonstrate how a BBJSP Widget can place data into the BBjspPageContext that can be accessed during page processing.

Constants

1

PAGE_SCOPE

2

SESSION_SCOPE

3

APPLICATION_SCOPE

Example

This example demonstrates how this works in a BBJSP widget

REM ===
REM === A simple BBjspWidget that puts a BBjVector in the BBjspPageContext.
REM ===

class public SimpleWidget implements BBjspWidget

    field public BBjVector MyVector!
    field public BBjString Test$="Test Widget"

    method public void open(BBjspPageContext context!)
        #MyVector!=BBjAPI().makeVector()
        #MyVector!.add("Hello World")
        #MyVector!.add("This in a Vector")
    methodend

classend

This example demonstrates how this works in a BBJSP web-page

<%@ taglib uri='/WEB-CFG/tld/core.tld' prefix='c' %>
<bbj:widget id='myWidget' source='widgets/SimpleWidget.bbj' class='SimpleWidget' />
<html>
  <body>
    <h1>Hello from BBJSP</h1>
    <ul>
      <c:iterate data='${myWidget["MyVector"]}' id="name">
        <li><b>${name}</b>
      </c:iterate>
    </ul>
    ${myWidget["Test"]}
  </body>
</html>

See Also

BBJSP

BBJSP Page

Logging

BBJSP Expression Language

BBjJettyContext

BBjspWebRequest

BBjspWebResponse

BBjspWebSession

BBjspSessionData