Java

The Java API v0.2

Introduction

This is the draft of the coming new Java API*.

See also the Java API overview.

info.q37.atlas.Atlas class

Static functions

headUp

public void headUp( String head )

If this function is needed, has to be called before the first setLayout[XSL](...) call.

This puts the content of html (string) in the head section of the application's HTML main page. You can put here the link to CSS files.

launch

void launch(String newSessionAction, Type type)

Launches the server. newSessionAction is the value returned by below info.q37.atlas.DOM.getAction(...) function when a new session is launched.

type can be:

  • info.q37.atlas.Atlas.Type.DEFAULT to launch the default interface (desktop one),
  • info.q37.atlas.Atlas.Type.DESKTOP to launch the desktop interface,
  • info.q37.atlas.Atlas.Type.WEB to launch the web interface.

NOTA: in some examples, a launch function with extraneous parameters is used. For your own developments, you don't need to give this extraneous parameters.

Abstract functions

handle

public void handle(q37.info.atlas.DOM dom, String action, String id)

This is the function you have to implement. It is called each time the user performs an action. You get :

  • dom, which is an info.q37.atlas.DOM object, detailed below, to manipulate the DOM,
  • action, which is the action tag defined for the corresponding event in the data-xdh-onevent(s) attribute for the element which receives the event,
  • id, the id of this element.

info.q37.atlas.DOM class

This class contains the data for each users' session, and functions to manipulate the DOM displayed by the web browser.

Global

DOM constructor

Takes no parameter.

alert

void alert(String message)

Displays an alert box with the string message as message.

confirm

boolean confirm(String message)

Displays a confirmation dialog box with message as message. The returned value is true when the user clicks the OK button, and false when the user clicks the cancel button.

focus

void focus(String id)

Gives the focus to element of id id.

Attribute

getAttribute

String getAttribute(String id, String name)

Returns the value of the attribute named name of the element of id id.

removeAttribute

void removeAttribute(String id, String name)

Removes attribute named name from element of id id.

setAttribute

void setAttribute(String id, String name, String value)

Set value as value for the attribute named name of the element of id id.

Class

Following methods allows to handle classes (the CSS related class attributes of HTML tags), by respectively add, remove or toggle (i.e. adds if not present, otherwise removes) a class to elements identified by their ids (the content of the id attribute from HTML tags).

idsAndClasses must have following form:

{
    { "id1", "class1" },
    { "id2", "class2" },
    { "id3", "class3" },
    ...
}

addClass

void addClass(String id, String class)

addClasses

void addClasses(String[][] idsAndClasses)

removeClass

void removeClass(String id, String class)

removeClasses

void removeClasses(String[][] idsAndClasses)

toggleClass

void toggleClass(String id, String class)

toggleClasses

void toggleClasses(String[][] idsAndClasses)

Content

getContent

String getContent(String id)

Retrieve the content of the element of id id.

getContents

String[] getContents(String[] ids)

Retrieves the content of the elements of ids ids in the same order.

setContent

void setContent(String id, String content)

Set the content of element of id id to value.

setContents

void setContents(String[][] idsAndContents)

Set the content of all element which id are in idsAndContents to corresponding content.

idsAndContents must have following form:

{
    { "id1", "content1"},
    { "id2", "content2"},
    { "id3", "content3"},
    ...
}

Element

enableElement

void enableElement(String id)

Enable element of id id.

enableElements

void enableElements(String[] ids)

Enable element of ids ids.

disableElement

void disableElements(String[] ids)

Disable element of if id.

disableElements

void disableElements(String[] ids)

Disable element of ids ids (array of strings).

Layout

setLayout

void setLayout(String id, String html)

Replaces the content of element with string id as id with the content of html (string).

If id is an empty string, the content of the entire document is replaced by the resulting transformation.

The content of html can be generated with the template engine of your choice. For XSL(T), you can used the dedicated method setLayoutXSL(...).

setLayoutXSL

public void setLayoutXSL(String id, String xml, String xslFilename)

Replaces the content of element with string id as id with the result of the transformation of the XSL file with name xslFilename applied to the content of xml, which must be valid XML.

If id is an empty string, the content of the entire document is replaced by the resulting transformation.

Property

getProperty

String getProperty(String id, String name)

Returns the value of property named name of the element of id id.

setProperty

void setProperty(String id, String name, String value)

Set value as value for the property named name of the element of id id.

Widget

dressWidgets

void dressWidgets(String id)

Create the widget for each elements which are children of the element of id id and which have a data-xdh-widget attribute.

If id is an empty string, the entire document is handled.