BBjspPageContext::contains (Deprecated)

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

Description

In BBj 16.0 and higher, this method returns a boolean indicating whether the named attribute has been set within this BBjspPageContext.

Syntax

Return Value

Method

boolean

contains(string name)

Parameters

Variable

Description

name

the name of the header

Return Value

a boolean where 0 = not set and 1 = set.

Remarks

None.

Example

This example demonstrates how this works in a BBJSP widget

REM ===
REM === A BBjspWidget that counts page-visits for the user.
REM ===

class public PageCounterWidget implements BBjspWidget

  method public void open(BBjspPageContext context!)

    declare BBjspWebRequest request!
    declare BBjspWebSession session!
    declare BBjspSessionData data!
    declare BBjspLogger logger!
    declare BBjspHashMap visitMap!

    request! = context!.getRequest()
    session! = context!.getSession()
    data! = context!.getBBjspSession()
    logger! = context!.getLogger()

    url$ = request!.getRequestURL()
    
    if !data!.contains("PAGE_VISITS") then
      data!.setAttribute("PAGE_VISITS",BBjAPI().makeBBJSP().makeBBjspHashMap())
    endif
    
    visitMap! = data!.getAttribute("PAGE_VISITS")
    
    ct = 0

    if visitMap!.containsKey(url$) then
      ct = num(visitMap!.get(url$))
    endif

    ct = ct + 1
    visitMap!.put(url$,str(ct))
    
    logger!.log(url$ + " VISIT COUNTER : " + str(ct))
    
    context!.saveBBjspSession()
    
  methodend

classend

See Also

BBJSP

BBjspPageContext

BBjspHashMap (Deprecated)