Runtime tools : Presentation components : Rich Client Infrastructure : Tasks : Controlled Embedded Browser
  
Controlled Embedded Browser
Controlled Embedded Browser is a SWT (standard widget toolkit) widget that wraps org.eclipse.swt.browser.Browser. It enables the interaction between application and web pages in the browser and can inspect the browser status. Controlled embedded browser contains the following functions:
Display and hide the tool bar or status bar of the Browser
Controlled Embedded Browser provides API to display and hide the address bar, forward and backward buttons, refresh and stop buttons, and status bar of the Browser. Perform the following procedure to display and hide the tool bar or status bar of the Browser:
Set the Browser attribute to include Browser.TOOLBAR to display the address bar, forward and backward buttons, and refresh and stop buttons in the Browser.
Example: new Browser(composite,Browser.TOOLBAR)
Set the Browser attribute to include Browser.STATUSBAR. If the application setShowStatusLine is true, the status information is displayed in the status bar.
Example: new Browser(composite,Browser.STATUSBAR)
Set the Browser attribute to include SWT.NONE to hide the address bar, forward and backward buttons, refresh and stop buttons, and status bar in the Browser.
Note In this case, the status information is not displayed even if the application setShowStatusLine is true.
Block the user interaction
Controlled Embedded Browser provides API to forbid the user interaction. Perform the following procedure to enable or disable the user interaction:
Set the setEnable parameter of this function to be true, the user can NOT perform any operation on the web pages in the browser.
Example: setEnabled(true)
Set the setEnable parameter of this function to be false, the user can perform the operation on the web pages in the browser.
Set the web page address for the Browser according to the URL
Controlled Embedded Browser provides API to set the web page address for the Browser according to the URL.
Set a URL for this function, the web page of the URL is displayed in the Browser Widget.
Example: browser.setURL("http://btt.cn.ibm.com/")
Set the web page for the Browser according to the HTML text
Controlled Embedded Browser provides API to set the web page for the Browser according to the HTML text.
Set the HTML text for this function, the HTML information is parsed and displayed in the Browser Widget.
Example: browser.setHTML("<html><head><title>BTT Browser</title></head></html>)
Set the element value for the Browser
Controlled Embedded Browser provides API to set the value for the Browser.
Set an element ID and the ID value for this function, if the element ID exists in the web pages of the Browser, the ID value is changed accordingly; otherwise, exception is thrown. The following example sets the value of the button element to Button.
Example: browser.setValue("buttonid", "Button")
Get the element value from the Browser
Controlled Embedded Browser provides API to get the element value from the Browser.
Set a given element ID of the web pages in the Browser for this function, the value of the element is returned. The value of the buttonid is returned in the following example.
Example: browser.getValue("buttonid")
Get the DOM information from the web page in the Browser
Controlled Embedded Browser provides API to get the DOM information from the web page in the Browser.
Set the ID of a given DOM object for this function, the DOM information is returned in the web page of the Browser. The information about the text object is returned in the following example.
Example: browser.getDOM("textid")
Invoke the object method in the Browser
Controlled Embedded Browser provides API to invoke the object method in the Browser. Follow the instructions in this section to preform different operations on the object method:
Set the ID of a given element and the method name in the browser.invoke parameter, if the method is valid for the element, the method is invoked in the Browser; otherwise, error message occurs in the console.
Example: browser.invoke("textid", "focus")
Set the ID of a given element in the browser.select parameter, if the method is valid for the element, the select method is invoked in the Browser; otherwise, error message occurs in the console.
Example: browser.select("textid")
Set the ID of a given element in the browser.forceFocus parameter, if the method is valid for the element, the focus method is invoked in the Browser; otherwise, error message occurs in the console.
Example: browser.forceFocus("buttonid")
Set the ID of a given element in the browser.click parameter, if the method is valid for the element, the click method is invoked in the Browser; otherwise, error message occurs in the console.
Example: browser.click("buttonid")
Go up to
Tasks