Visual
Mashup
Builder
|
AppliBuilder
User Documentation
|
|
AppliBuilder Function Library
AppliBuilder supports import of functions from the function library,
which is an extensible library of functions to make it easier to script
pages. It is a convenient catalog of functions you can import and use
on your page.
The library import takes care of
importing the files required to use
a function, but the rest is up to you. One the function is imported, it
can be used anywhere on the page where you use Javascript. You will
need to invoke these library functions from your widget events or from
your own functions.
Catalog of Functions
The function library is designed to be a growing collection of reusable
functions. The following types of functions are provided.
Global
Functions
The following global functions are always present in generated pages,
loaded from imported Javascript files present in every AppliBuilder
page.
- getWidgetContainerByName(element_name) This function returns
the DOM node for the container DIV node that wraps every widget. Use this to
perform styling or scripting operations on the node enclosing all the widget
contents.
- getInputValue(element_name) This function returns
the value of the input element with the given name on the current
page. Returns a value string in case of: textbox, textarea,
radiobutton. Returns an Array of strings in case of: select,
checkbox.
- getInputNode(element_name) This function returns
the DOM node for the input element with the given name on the current
page. For a checkbox, it returns an array of checked input nodes.
For a select element, it returns an array of selected options.
- setWidgetValue(element_name,
value) Use this function to set the value of a named
widget and reload the widget so the new value is displayed. It
applies only to widgets where a value can be set, including basic HTML
input elements, form elements, date input, etc.
- getElementObjectByName(element_name)
Use this function to get a reference to the Javascript object which controls the widget. Required to
access widget-specific functions or any attributes which are not handled by the framework functions.
- getElementForEvent(element_name, event_name)
Use this function to attach an event handler to a widget at run-time. This returns the appropriate DOM node for the given event within
the given widget.
- reloadWidget(element_name)
Use this function to completely re-render the widget. This is used after making changes to the
widget.
Core
Functions
The following core functions are always present in generated pages,
loaded from imported Javascript files present in every AppliBuilder
page.
- AppliLoader(): (AJAX
Loader) new
AppliLoader(url,onload,method,params,contentType): Use this
function to load files and data from URLs, from any server on the web.
- getURLParameters()
Use this function to get the URL parameters from a page. The
parameters are returned as an object with attributes, where each
attribute name is a parameter name.
- positionElementVisible():
To ensure an overlay popup frame is within the visible window of the
browser.
- xmlRESTService(svcurl, params,
callback) Used to invoke remote web
services and return a response as XML data. The svcurl is the
URL of the remote web service. params are the
list of parameters to be passed to the service as a URL parameter
string. callback
if the name of your callback function to handle the results.
- htmlRESTService(svcurl, params, xslurl,
callback) Used to invoke remote web
services and return a response as HTML or other text data. This is
typically used along with an XSL transform on the server.
Arguments are (). You can use the
File Manager to create an XSL file on the server, and use that XSL file
for your transformation. The svcurl is the
URL of the remote web service. params are the
list of parameters to be passed to the service as a URL parameter
string. xslurl is
the URL of the XSL Transform to be supplied if XSL transformation on
the server is desired. callback if the
name of your callback function to handle the results.
- getXMLColumnValue(rowNode,
columnTag, separator): This
is a convenience function to help in processing the XML document
returned
with a web services call. This is useful when rendering a page,
see the Amazon book search example. This method searches the
sub-tree under the rowNode
DOM
node, and picks up all values for the columnTag, and
concatenates them using the specified separator.
It returns a string value.
Basic Functions
Dont ask us to define the
difference between core and basic
functions. But
here are additional functions that aree commonly needed. In this
case, functions must be imported via the function library before they
can be used on a page.
- popupPage(page_path,
popup_header, width, height): Open
Another Page in a Popup Inline Frame
Use this function to bring up another page (or any URL for that matter)
as an Inline frame that looks like a dialog. Use the following
steps
- Import the popupPage function from the function library
- In your function or widget event action, use the following to
bring up
the IFrame
new
Applibase.Basic().popupPage('your_page_path', "My Frame
Header", 300, 400);
where the last two arguments are optional width and height parameters.
- openUrlInPopup(url,x,y,callbackfn,
header): Use this
function to open the content of a URL in an overlay div that can be
positioned. In this case, the content cannot be a complete page,
rather it must be only an HTML snippet, without headers. Use new
Applibase.Basic().openUrlInPopup(...) to execute the function.
- openUrlInIFrame(url,x,y,callbackfn,
header, wid, ht): Use this function to open the content of a URL
in an overlay Inline Frame, with specified posiion and width and
height. In this case, the content may be an independent and
complete HTML page with headers. Use new Applibase.Basic().openUrlInIFrame(...) to
execute the function.
Database Functions
Database functions are found in the
dbfunctions.js file, which is
imported when you choose any of the following functionf from the
function library.
- Named Query:
query(named_query_name, , parameters, isAsync, callback):
This method is used to execute named queries on the server. A
Named Query is an SQL statement or server-side Jython script,
which
is setup on the server via the AppliBuilder online interface. The
browser Javascript invokes the query by name, limiting what queries can
be executed by the browser client. You setup named queries and
use them from the browser Javascript, much like SQL prepared
statements. Use new Applibase.db.AjaxDb().query(...) to execute the
function.
- SQL Query: sqlquery(query_string, isAsync, callback):
Using arbitrary SQL queries from the browser is normally
disabled. irect SQL access is useful for development and testing,
and
possibly a few other situations where data security is not a concern.
This access can only be turned on for authenticated users of your
applications. Use new Applibase.db.AjaxDb().sqlquery(...) to execute
the function.
- Display Query Result: renderResultTable(resultSet, container): This is a convenience
function is provided to display the resuls of a query
table. The container is optional, and can be any HTML element to which
a table can
be added, e.g. a HTML Block Element. Don't specify a container to
display the results of a query at the end of your page. Use new
Applibase.db.AjaxDb().renderResultTable(...)
to execute the function.