OverviewSingleDeprecatedPropertiesEventsXSL Parameters

jsx3.gui

class Template.Block

Object
->jsx3.lang.Object
  ->jsx3.app.Model
    ->jsx3.gui.Painted
      ->jsx3.gui.Block
        ->jsx3.gui.Template.Block

All Implemented Interfaces:

jsx3.gui.Interactive, jsx3.util.EventDispatcher

class Template.Block
extends jsx3.gui.Block
Provides base class for creating custom GUI classes. Example usage:

//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);
    };
     
});

Since:

3.6

Constructor Summary
void
init(strName : ?, vntLeft : ?, vntTop : ?, vntWidth : ?, vntHeight : ?)
instance initializer
Method Summary
void
clearBoxProfile(bRecurse : boolean)
Deletes the existing boxprofile for the object.
HTMLElement
getRenderedBox(strId : String, objRoot : 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
Forces the template engine to recalculate the box profile for the instance.
void
setProperty(strName : String, strValue : String)
Sets a property on the instance.
void
setPropertyGUI(objGUI : HTMLElement, strName : String, strValue : String)
Similar to setProperty, except that the target GUI element can be specified as the first parameter.
void
syncProperty(strPropName : String | Array<String>, VIEW : Object, objGUI : HTMLElement)
Synchronize value(s) on the model to value(s) in the view (the view template).
Methods Inherited From jsx3.gui.Block
getBackground, getBackgroundColor, getBorder, getCDFAttribute, getCDFId, getCSSOverride, getClassName, getColor, getCursor, getDimensions, getDisplay, getFontName, getFontSize, getFontWeight, getHeight, getIndex, getLeft, getMargin, getOverflow, getPadding, getRelativePosition, getTagName, getText, getTextAlign, getTip, getTop, getVisibility, getWidth, getZIndex, hideMask, paint, setBackground, setBackgroundColor, setBorder, setCDFAttribute, setCDFId, setCSSOverride, setClassName, setColor, setCursor, setDimensions, setDisplay, setFontName, setFontSize, setFontWeight, setHeight, setIndex, setLeft, setMargin, setOverflow, setPadding, setRelativePosition, setTagName, setText, setTextAlign, setTip, setTop, setVisibility, setWidth, setZIndex, showMask
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.app.Model
adoptChild, assembleFromXML, doClone, findAncestor, findDescendants, getAncestorOfName, getAncestorOfType, getChild, getChildIndex, getChildren, getDescendantOfName, getDescendantsOfType, getDynamicProperty, getFirstChild, getFirstChildOfType, getHelpId, getId, getLastChild, getLoadType, getMetaValue, getNS, getName, getNextSibling, getParent, getPersistence, getPreviousSibling, getServer, getUriResolver, insertBefore, load, loadAndCache, loadXML, onAfterAssemble, onAfterAttach, onBeforeAssemble, onChangeServer, onChildAdded, onDestroy, onRemoveChild, onSetChild, onSetParent, removeChild, removeChildren, selectDescendants, setChild, setDynamicProperty, setHelpId, setLoadType, setMetaValue, setName, setPersistence, toString, toXML, toXMLDoc, toXMLElm
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

init

void init(strName : ?, vntLeft : ?, vntTop : ?, vntWidth : ?, vntHeight : ?)
instance initializer

Parameters:

strName
vntLeft
vntTop
vntWidth
vntHeight
Method Detail

clearBoxProfile

void clearBoxProfile(bRecurse : boolean)
Deletes the existing boxprofile for the object. This is useful when a given template definition defines various (dynamic) DOMs. If a given value will result in the template needed to generate a different DOM, then this method should be called to ensure that the cached DOM is not used.

Parameters:

bRecurseif true, the profile for all descendants is also deleted. Typically, a left/top adjustment would pass false for this param, while all other adjustments that affect descendant structures would pass true.

getRenderedBox

HTMLElement getRenderedBox(strId : String, objRoot : HTMLElement)
Returns the HTML element (the view) corresponding to the box (model) defined by the uniqe identifier, strId

Parameters:

strIdID assigned to the box in the declarative markup
objRootThe root HTML element corresponding to the root box for the given GUI object instance; if not provided, this will be resolved via getRendered.

Returns:

 

getTemplateXML

String | jsx3.xml.Document getTemplateXML()
Returns the XML template definition for the class. When authoring your own GUI class, this method should return the XML for the transormation template.

Returns:

a string of XML or an instance of jsx3.xml.Document  

recalc

void recalc()
Forces the template engine to recalculate the box profile for the instance. This updates both the cached model and the on-scren view. Note that authoring a template with the attribute, 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>


setProperty

void setProperty(strName : String, strValue : String)
Sets a property on the instance. Triggers an update to synchronize model and view. This method may be called with a variable number of arguments, which are interpreted as name/value pairs, i.e.: obj.setProperty(n1, p1, n2, p2);. For example, the following two statements are equivalent:

obj.setProperty("jsxbgcolor","red");
obj.setBackgroundColor("red",true);

Parameters:

strNamethe name of the attribute.
strValuethe value of the attribute. If null, the attribute is removed.

setPropertyGUI

void setPropertyGUI(objGUI : HTMLElement, strName : String, strValue : String)
Similar to 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.

Parameters:

objGUIthe rendered native object.
strNamethe name of the attribute.
strValuethe value of the attribute. If null, the attribute is removed.

See Also:

setProperty()

syncProperty

void syncProperty(strPropName : String | Array<String>, VIEW : Object, objGUI : HTMLElement)
Synchronize value(s) on the model to value(s) in the view (the view template). Ensures a complete feedback loop from model to view. This method is different from 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");

Parameters:

strPropNameOne or more properties reflecting what was changed. For example, "jsxbgcolor" or ["jsxexecute","color"]
VIEWConfiguration object. Passing null is the same as passing true.

  • true Update the paintable model and then update the corresponding implementations of that property in the view
  • false Only update the paintable model. If any updates affect a box property (i.e., left, border, etc), the box profile will be set to 'dirty'.
  • {drawspace} Update the paintable model and then update the corresponding implementations of that property in the view. The object being passed will be used to seed any box updates. For example, passing {left:10}, would result in the box being moved to the pixel position, 10, regardless of what property updates get triggered.

objGUIOptional; if passed, this instance will be used; if not passed, objGUI will be resolved via [instance].getRendered()

See Also:

setProperty()