//step 1) require the template engine (and all used interfaces)
jsx3.require("jsx3.gui.Template");
//step 2) define the new class
jsx3.lang.Class.defineClass(
"my.custom.Widget", //fully qualified name
jsx3.gui.Template.Block, //super class
[], //interface(s)
function(WIDGET, widget) { //class alias, prototype alias
//step 3) define the init method
widget.init = function(strName) {
this.jsxsuper(strName);
};
//step 4) define the MODEL defaults
WIDGET.XYZ = 'xyz'; //CLASS defaults
widget.xyz = 'xyz'; //prototype defaults
//step 5) define the VIEW template
widget.getTemplateXML = function() {
return ['<transform version="1.0" ' ,
' xmlns="http://gi.tibco.com/transform/" ' ,
' xmlns:u="http://gi.tibco.com/transform/user">' ,
' <template>' ,
' <div onclick="{onclick}" ' ,
' style="position:{$position};left:{$left};background:{bg|red};">' ,
' <text>{mytext|some default text}</text>' ,
' </div>' ,
' </template>' ,
'</transform>'].join("");
};
//6) define the CONTROLLER methods
widget.onclick = function(objEvent, objGUI) {
//show random information
alert(objEvent.clientX() + objGUI.id + WIDGET.XYZ + this.bg);
};
widget.setBG = function(strBG) {
this.setProperty("bg",strBG);
};
widget.setText = function(strText) {
this.setProperty("mytext",strText);
};
});
| Constructor Summary | |
|---|---|
| void | instance initializer
|
| Method Summary | |
|---|---|
| void | clearBoxProfile(bRecurse : boolean) Deletes the existing boxprofile for the object. |
| HTMLElement | Returns the HTML element (the view) corresponding to the box (model) defined by the uniqe identifier, strId
|
| String | jsx3.xml.Document | Returns the XML template definition for the class. |
| void | recalc() Forces the template engine to recalculate the box profile for the instance. |
| void | Sets a property on the instance. |
| void | Similar to setProperty, except that the target GUI element can be specified as the first parameter. |
| void | Synchronize value(s) on the model to value(s) in the view (the view template). |
| Methods Inherited From jsx3.gui.Interactive |
|---|
| doEvent, getCanDrag, getCanDrop, getCanMove, getCanSpy, getEvent, getEvents, getMenu, hasEvent, registerHotKey, removeEvent, removeEvents, setCanDrag, setCanDrop, setCanMove, setCanSpy, setEvent, setMenu, setSpyStyles, showSpy |
| Methods Inherited From jsx3.gui.Painted |
|---|
| focus, getAbsolutePosition, getAttribute, getAttributes, getRendered, insertHTML, onAfterPaint, onAfterRestoreView, paintChild, paintChildren, recalcBox, removeAttribute, removeAttributes, repaint, setAttribute |
| Methods Inherited From jsx3.util.EventDispatcher |
|---|
| publish, subscribe, unsubscribe, unsubscribeAll |
| Methods Inherited From jsx3.lang.Object |
|---|
| clone, equals, eval, getClass, getInstanceOf, getInstanceOfClass, getInstanceOfPackage, instanceOf, isInstanceOf, isSubclassOf, jsxmix, jsxsuper, jsxsupermix, setInstanceOf |
| Constructor Detail |
|---|
| Method Detail |
|---|
strId
getRendered.recalc="true", will cause realc to be called each time
the instance is painted. This means the following two template statements are equivalent:
<template recalc="true">...</template> - or - <template onpaint="this.recalc()">...</template>
obj.setProperty(n1, p1, n2, p2);.
For example, the following two statements are equivalent:
obj.setProperty("jsxbgcolor","red");
obj.setBackgroundColor("red",true);
null, the attribute is removed.
setProperty, except that the target GUI element can be specified as the first parameter. This is useful for repeated
UI updates since it saves the system from resolving objGUI.null, the attribute is removed.setPropery in that setProperty is used to both update
the model and view at the same time. For example, the following two examples are equivalent:
//example 1
obj.setProperty("jsxbgcolor","red");
//example 2
obj.jsxbgcolor = "red";
obj.syncProperty("jsxbgcolor");
[instance].getRendered()