BUI logoDWC logoBBjWebManager::setAttribute

Description

In BBj 22.03 and higher, this method sets a component attribute on the web page.

Note:

In BBj 22.03 and higher, BBjWebManager is an alias for BBjBuiManager.

Syntax

Return Value Method

void

setAttribute(String attribute, String value)
void setAttribute(String attribute, String value, String selector)

Parameters

Parameter Description
attribute Specifies an attribute to be set on the web page.
value Specifies the value of that attribute.
selector By default, setAttribute applies to the document element on the web page. If a selector is specified, it selects a descendant element within the document to set this attribute. If a specified selector doesn't return any elements, the default document element is used.

Return Value

None.

Remarks

This functionality is primarily intended for setting low-level BUI element attributes or DWC component attributes. When running in GUI, the attributes do not affect the control itself, but may be used by the developer.

Example

rem ' BBjWebManager::setAttribute

attribute$ = "lang"
value$ = "en-US"
selector$ = ""

sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()

title$ = "BBjWebManager::setAttribute"
window! = sysgui!.addWindow(25,25,600,275,title$,$00090083$)
window!.setCallback(window!.ON_RESIZE,"resize")
window!.setCallback(window!.ON_CLOSE,"eoj")

window!.addStaticText(101,5,25,90,25,"Attribute:",$8000$)
attribute! = window!.addEditBox(102,100,25,475,25,attribute$,$$)

window!.addStaticText(103,5,75,90,25,"Value:",$8000$)
value! = window!.addEditBox(104,100,75,475,25,value$,$$)

window!.addStaticText(105,5,125,90,25,"Selector:",$8000$)
selector! = window!.addEditBox(106,100,125,475,25,selector$,$$)

setAttribute! = window!.addButton(1,100,175,475,25,"setAttribute",$$)
setAttribute!.setCallback(setAttribute!.ON_BUTTON_PUSH,"setAttribute")

getAttribute! = window!.addButton(2,100,225,475,25,"getAttribute",$$)
getAttribute!.setCallback(getAttribute!.ON_BUTTON_PUSH,"getAttribute")

browser! = bbjapi().getWebManager(err=oops)
browser!.getUrl(err=oops)

process_events

oops:
i = msgbox("This functionality is only supported in browser environments.")

eoj:
release

resize:
    event! = sysgui!.getLastEvent()
    width = event!.getWidth()
    height = event!.getHeight()
    attribute!.setSize(width-125,25)
    value!.setSize(width-125,25)
    selector!.setSize(width-125,25)
    setAttribute!.setSize(width-125,25)
    getAttribute!.setSize(width-125,25)
return

setAttribute:
    attribute$ = attribute!.getText()
    value$ = value!.getText()
    selector$ = selector!.getText()
    browser!.setAttribute(attribute$, value$, selector$)
return

getAttribute:
    attribute$ = attribute!.getText()
    selector$ = selector!.getText()
    value$ = browser!.getAttribute(attribute$, selector$)
    value!.setText(value$)
return

See Also

BBjAPI

BBjSysGui

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.