PropertyEventMethodIndex
WebSquare.uiplugin.widgetContainer - 5.0_4.4547B.20211124.201933

WidgetContainer. Creates and manages widgets. Includes widgets and manages interactions among the widgets. The end user can relocate and resize widgets through drag-and-drop. The WidgetContainer is based on a two-dimensional map. The unit width is the width of the WindowContainer divided by the cols setting. The unit height is unitHeightPixel. The end user can relocate and resize the widgets within the two-dimensional map. Information of the widgets can be collected into JSON data so they can be restored. In other words, saving certain page status with widgets is possible.

Type

uiplugin

Property Summary

class
Same as the class property in HTML. The class defined in the CSS file or style block can be applied. Multiple classes can be defined with being divided by blank space.
cols
[default: 1] Number of the columns in the WidgetContainer
horizontalMargin
Horizontal margin between the widgets.
id
Component ID
maxUnitHeight
Maximum unit height of the widget
maxUnitHeight
Maximum unit height of the widget
maxUnitWidth
Maximum unit width of the widget
minUnitHeight
Minimum unit height of the widget
minUnitWidth
[default: 1] Minimum unit width of the widget
mode
[default: pushpull] Basic operation mode for the interactions among the widgets
params
User-defined data stored in the widget object
preventMaximizeByTitle
[default: false] Maximizes the widget upon the end user’s double-clicking the title on the widget.
threshold
If the width of the WidgetContainer is smaller than the threshold, widgets will be placed on a single column.
unitHeightPixel
[default: 25] Unit height of the WidgetContainer in pixels.
verticalMargin
Vertical margin between the widgets.
widgetMove
[default:true] Allows moving of the widgets.
widgetResize
[default:true] Allows resizing of the widgets.

Event Summary

onafterwidgetclose
Triggered after a widget is closed by closeWidget.
onbeforewidgetclose
Triggerd before a widget is closed by closeWidget. If the event handler returns false, closing of the widget will be cancelled.
onclickcustombtn
Triggered upon the end user’s clicking the customized button.
onload
Triggered after all widgets contained in the WidgetContainer are loaded.
onwidgetfix
Triggered after the widget is fixed by setFixed.
onwidgetload
Triggered upon all widgets contained in the WidgetContainer are completely loaded.
onwidgetmaximize
Triggered after the widget is maximized by toggleMaximized.
onwidgetminimize
Triggered after the widget is minimized by toggleminimized.
onwidgetmove
Triggered upon a widget being moved by an API or end user’s action.
onwidgetresize
Triggered upon a widget being resized by an API or end user’s action.
onwidgetrestore
Triggered upon a minimized or maximized widget being restored.

Method Summary

addClass( className )
Adds a CSS class to the component.
addWidgets( option )
Adds a new widgets based on the options object or option object array of the widget received.
bind( eventType , function )
Dynamically allocate an event and the handler function to the component.
changeClass( oldClassName , newClassName )
Changes the class currently applied to the corresponding WebSquare component. (Supported in all WebSquare components.)
enableWidgetMove( isMovable )
Sets moving of the widget within the WidgetContainer.
enableWidgetResize( isResizable )
Allows resizing of the widget contained in the WidgetContainer.
enableWidgetTitle( showTitle )
Controls the title bars of all widgets in the WidgetContainer.
exportWidget( widgetId )
Returns the widget of the specified ID among the widgets contained in the WidgetContainer.
exportWidgets( )
REturns current widget information in the WidgetContainer as JSON data.
focus( )
Focuses the WebSquare component.
getDisabled( )
Returns the current value of the disabled property.
getGenerator( )
In case generated by the Generator component, returns the parent Generator object that created the component itself.
getID( )
Returns the ID of the WebSquare component.
getInitStyle( CSS )
Returns the initial style of the WebSquare component.
getOpacity( )
Returns the opacity of the WebSquare component. (Supported in all WebSquare components.)
getOriginalID( )
Returns the originalID of the WebSquare component. (Supported in all WebSquare components.)
getPluginName( )
Returns the name of the WebSquare component.
getPosition( positionName )
Returns the position (left and top) of the WebSquare component. (Supported in all WebSquare components.)
getReadOnly( )
Returns the current value of the readOnly property.
getScope( )
For the child component of a scope="true" WFrame, returns the parent WFrame object. (Supported in all WebSquare components.)
getScopeWindow( )
For the child component of a scope="true" WFrame, returns the parent WFrame object. (Supported in all WebSquare components.)
getSize( sizeName )
Sets the size (width and height) of the WebSquare component. (Supported in all WebSquare components.)
getStyle( propertyName )
Returns the CSS setting of the WebSquare component.
getStyleValue( style )
[deprecated]
getTitle( )
Returns the title of the WebSquare component.
getUdcHome( )
Returns the path of the UDC file including the file name in which the UDC object is defined. (Supported in all WebSquare components.)
getUdcRoot( )
Returns the path of the UDC file in which the UDC object is defined. (Supported in all WebSquare components.)
getUserData( key )
Returns the value set by setUserData or directly defined by the user in the XML file.
getWidgetById( id )
Returns the widget object of the corresponding widget ID.
getWidgetByTitle( id )
Returns the widget object of the corresponding widget title. If there is no corresponding widget, null will be returned.
hasClass( className )
Checks whether the WebSquare component has a certain class.
hide( )
Hides the WebSquare component. (Supported in all WebSquare components.)
importWidget( id , jsonObj )
Obtains information of a single widget currently existing as JSON and adds it to the WidgetContainer.
importWidgets( jsonArr , clearFlag )
Imports multiple widgets currently not existing to the WidgetContainer based on the received JSON data.
isValidPos( x , y , unitWidth , unitHeight )
Returns the validity of the location based on the received informaiton.
moveWidget( widgetId , newX , newY )
Moves the widget of the corresponding ID to the specified location (newX, newY).
redraw( )
Renders the widgets in the WidgetContainer accordingly.
removeClass( className )
Removes a class from the WebSquare component. (Supported in all WebSquare components.)
removeTitleClass( id , className )
Removes the class from the title according to the titleClass property.
removeWidgets( widgetIds )
Removes widgets of the specified IDs.
resizeWidget( widgetId , newWidth , newHeight , options )
Resizes the widget of the specified ID into the new size (newWidth, newHeight).
setCols( cols )
Sets the number of the columns in the two-dimensional map based on which the widgets are placed.
setDisabled( disabled )
Sets the disabled property of the WebSquare component.
setEventPause( evList , flag )
Pauses the event.
setInitStyle( property )
Restores the initial style of the WebSquare component.
setOpacity( value )
Sets the opacity in the WebSquare component. (Supported in all WebSquare components.)
setPosition( left , top , mode )
Sets the position (left, top) of the WebSquare component.
setReadOnly( readOnly )
Sets the readOnly proprety of the WebSquare component.
setSize( width , height )
Sets the size (width, height) of the WebSquare component.
setStyle( propertyName , value )
Sets the CSS of the WebSquare component.
setTitleClass( id , className )
Adds a class to the title based on the titleClass property.
setUserData( key , value )
Sets random data in the WebSquare component. (Supported in all WebSquare components.)
show( displayType )
Shows the WebSquare component on the page. (Supported in all WebSquare components.)
toggleClass( className )
Adds or removes a CSS class to or from a WebSquare component. (Supported in all WebSquare components.)
trigger( type , array )
Triggers the specified event in the WebSquare component.
unbind( type , function )
Removes the specified event from the WebSquare component.
visible( flag )
[deprecated]

Property Detail

class
Same as the class property in HTML. The class defined in the CSS file or style block can be applied. Multiple classes can be defined with being divided by blank space.
WebSquare5 Engine applies different classes to different components. By defining a common class, the common class can be applied to multiple components.
cols
[default: 1] Number of the columns in the WidgetContainer. The WidgetContainer divides its width by the numer of the columns to determine the unit width.
horizontalMargin
Horizontal margin between the widgets. (Unit: pixels) [default: 0]
id
Component ID
The component ID is allocated as a global object. The script can access each object through the component ID.
maxUnitHeight
Maximum unit height of the widget
maxUnitHeight
Maximum unit height of the widget
maxUnitWidth
Maximum unit width of the widget
minUnitHeight
Minimum unit height of the widget
minUnitWidth
[default: 1] Minimum unit width of the widget
mode
[default: pushpull] Basic operation mode for the interactions among the widgets
pushpull : Pulls up as may widgets as possible. Conflicting widgets will be pulled down.
switch : Tries to switch with the conflicting widget. However, switching is possible only with a smaller widget.
params
User-defined data stored in the widget object
Can be redefined by setParams during runtime, and can be obtained by getParams.
Moreover, this value will be extracted as ‘params’ by getWidgetInfo or exportWidgets.
preventMaximizeByTitle
[default: false] Maximizes the widget upon the end user’s double-clicking the title on the widget.
threshold
If the width of the WidgetContainer is smaller than the threshold, widgets will be placed on a single column.
Moreover, upon the threshold being crossed, moving and resizing will not be allowed.
Designed for mobile environment. If not set, the widgets will be rendered in original locations although the size of the WidgetContainer gets smaller.
unitHeightPixel
[default: 25] Unit height of the WidgetContainer in pixels. The unitHeightPixel will become the actual height of the widget with height === 1.
verticalMargin
Vertical margin between the widgets. (Unit: pixels) [default: 0]
widgetMove
[default:true] Allows moving of the widgets.
widgetResize
[default:true] Allows resizing of the widgets.

Event Detail

onafterwidgetclose
Triggered after a widget is closed by closeWidget.
Parameter
nametypedescription
idStringID of the executed widget
Sample
<script ev:event="onafterwidgetclose(id)"><![CDATA[ alert("[onafterwidgetclose] " + id); ]]></script>
onbeforewidgetclose
Triggered before a widget is closed by closeWidget. If the event handler returns false, closing of the widget will be canceled.
Parameter
nametypedescription
idStringID of the tried widget
Sample
<script ev:event="onbeforewidgetclose(id)"><![CDATA[ alert("[onbeforewidgetclose] " + id); ]]></script>
onclickcustombtn
Triggered upon the end user’s clicking the customized button.
Parameter
nametypedescription
idStringWidget ID.
btnIdStringButton ID.
Sample
<script ev:event="onclickcustombtn(id, btnId)"><![CDATA[ alert("[onclickcustombtn widgetId:] " + id); alert("[onclickcustombtn btnId:] " + btnId); ]]></script>
onload
Triggered after all widgets contained in the WidgetContainer are loaded. Triggered after onwidgetload of all widgets occur.
Sample
onwidgetfix
Triggered after the widget is fixed by setFixed.
Parameter
nametypedescription
idStringID of the executed widget
Sample
<script ev:event="onwidgetfix(id)"><![CDATA[ alert("[onwidgetfix] " + id); ]]></script>
onwidgetload
Triggered upon all widgets contained in the WidgetContainer are completely loaded.
Parameter
nametypedescription
idStringWidget ID.
Sample
onwidgetmaximize
Triggered after the widget is maximized by toggleMaximized.
Parameter
nametypedescription
idStringID of the executed widget
Sample
<script ev:event="onwidgetmaximize(id)"><![CDATA[ alert("[onwidgetmaximize] " + id); ]]></script>
onwidgetminimize
Triggered after the widget is minimized by toggleminimized.
Parameter
nametypedescription
idStringID of the executed widget
Sample
<script ev:event="onwidgetminimized(id)"><![CDATA[ alert("[onwidgetminimized] " + id); ]]></script>
onwidgetmove
Triggered upon a widget being moved by an API or end user’s action.
Parameter
nametypedescription
idStringWidget ID
newRectObjectLocation information object of the widget after moving <Number> newRect.x X value of the widget after moving <Number> newRect.y Y value of the widget after moving <Number> newRect.unitWidth uitWidth of the widget after moving <Number> newRect.unitHeight unitHeight of the widget after moving
oldRectObjectLocation information object of the widget before moving <Number> oldRect.x X value of the widget before moving <Number> oldRect.y Y value of the widget before moving <Number> oldRect.unitWidth unitWidth of the widget before moving <Number> oldRect.unitHeight unitHeight of the widget before moving
Sample
<script ev:event="onwidgetmove(id, newRect, oldRect)"><![CDATA[ alert("[onbeforewidgetclose newPos:] " + id, newRect.x, newRrect.y, newRrect.unitWidth, newRrect.unitHeight); alert("[onbeforewidgetclose oldPos:] " + id, oldRect.x, oldRrect.y, oldRrect.unitWidth, oldRrect.unitHeight); ]]></script>
onwidgetresize
Triggered upon a widget being resized by an API or end user’s action.
Parameter
nametypedescription
idStringWidget ID
newRectObjectLocation information object of the widget after resizing <Number> newRect.x X value of the widget after resizing <Number> newRect.y Y value of the widget after resizing <Number> newRect.unitWidth unitWidth of the widget after resizing <Number> newRect.unitHeight unitHeight of the widget after resizing
oldRectObjectLocation information object of the widget before moving <Number> oldRect.x X value of the widget before resizing <Number> oldRect.y Y value of the widget before resizing <Number> oldRect.unitWidth unitWidth of the widget before resizing <Number> oldRect.unitHeight unitHeight of the widget before resizing
Sample
<script ev:event="onwidgetresize(id, newRect, oldRect)"><![CDATA[ alert("[onbeforewidgetclose newPos:] " + id, newRect.x, newRrect.y, newRrect.unitWidth, newRrect.unitHeight); alert("[onbeforewidgetclose oldPos:] " + id, oldRect.x, oldRrect.y, oldRrect.unitWidth, oldRrect.unitHeight); ]]></script>
onwidgetrestore
Triggered upon a minimized or maximized widget being restored.
Parameter
nametypedescription
idStringWidget ID.
Sample
<script ev:event="onwidgetrestore(id)"><![CDATA[ alert("[onwidgetrestore] " + id); ]]></script>

Method Detail

addClass( className )
Adds a CSS class to the component. (Supported in all WebSquare components.)
Parameter
nametyperequireddescription
classNameStringYName of the class to add
Sample
// (Example) // Add oddClass to input1 component. input1.addClass("oddClass");
addWidgets( option )
Adds a new widgets based on the options object or option object array of the widget received.
In case an error occurs during widget creation, all creation will be cancel-led and rolled back.
Parameter
nametyperequireddescription
optionObjectYOptions for widget creation
<Number:N> options.x : [default:0] X value <Number:N> options.y : [default:0] Y value <Number:N> options.unitWidth : [default:1] unitWidth <Number:N> options.unitHeight : [default:1] unitHeight <String:N> options.id : [default:""] Widget ID <String:N> options.title : [default:""] Title of the widget <Boolean:N> options.hasTitleBar : [default:true] Title bar rendering status of the widget <String:N> options.src : [default:""] XML to run inwide the WFrame of the widget <Boolean:N> options.scope : [default:false] scope setting for the WFrame in the widget <String:N> options.className : [default:""] className to be applied to the widget. <Object:N> options.params : [default:undefined] User-define data to store in the widget object. <Boolean:N> options.fixed : [default:false] Fixing status of the widget. Toggling is possible by API or button input during runtime. <Boolean:N> options.resized : [default:false] Resizing of the widget. Toggling is possible by API during runtime. <Boolean:N> options.minimized : [default:false] of Minimizing of the widget Toggling is possible by API or button input during runtime. <String:N> options.maximizeFormatter : [default:null] Function or the name of the function to return the widget maximizing setting <String:N> options.buttonFormatter : [default:null] Function or the name of the function to return the button settings on the upper-right corner of the widget
Return
typedescription
Array:YArray of the added widgets
Sample
// Create a single widget. var options = {id : "widget1", title : "widget1", titleClass : "w2widget_blue", src : null, scope : true, x : 0, y : 1, unitWidth : 1, unitHeight : 1}; var newWidget = widgetContainer1.addWidgets(options); // Create multiple widgets at the same time. var optionsArr = []; optionsArr[0] = {id : "widget0", title : "widget0", src : "widget.xml", scope : true, x : 0, y : 0, unitWidth : 1, unitHeight : 1}; var newWidgets = widgetContainer1.addWidgets(optionsArr);
bind( eventType , function )
Dynamically allocate an event and the handler function to the component. (Supported in all WebSquare components.)
Parameter
nametyperequireddescription
eventTypeStringYEvent to allocate
functionFunctionYHandler function of the event
Sample
// (Example 1) // Define a function for the onclick event of input1. input1.bind("onclick", function(e){ alert(input1.getValue();})); // (Example 2) // Define commObj.ev_click function in advance. var commObj = {}; commObj.ev_click = function(e){ alert("click :: "+this.id); }; // Dynamically allocate onclick event and the handler function to input1 component. input1.bind("onclick", commObj.ev_click );
changeClass( oldClassName , newClassName )
Changes the class currently applied to the corresponding WebSquare component. (Supported in all WebSquare components.)
Only the classes added by addClass can be changed.
In order to remove classes directly defined in the class propert of the WebSquare component, add the following in config.xml. // Add the following in config.xml.
Parameter
nametyperequireddescription
oldClassNameStringYClass to change
newClassNameStringYClass to newly use
Sample
// The class is directly defined in the inputBox component. <xf:input id="input1" style="position: relative;width: 144px;height: 21px;" class="tmpInputClass"></xf:input> // Add the following in config.xml. <style> <removeDefaultClass value="true" /> </style> // Change the class. // Change tmpInputClass class to tmpInputWarninClass. input1.changeClass("tmpInputClass","tmpInputWarninClass");
enableWidgetMove( isMovable )
Sets moving of the widget within the WidgetContainer.
Parameter
nametyperequireddescription
isMovableBooleanYWhether to allow moving or not.
enableWidgetResize( isResizable )
Allows resizing of the widget contained in the WidgetContainer.
Parameter
nametyperequireddescription
isResizableBooleanYWhether to allow resizing or not.
enableWidgetTitle( showTitle )
Controls the title bars of all widgets in the WidgetContainer.
Parameter
nametyperequireddescription
showTitleBooleanYShows the title.
Sample
// Hide the title of all widgets in the WidgetContainer. widgetContainer1.enableWidgetTitle(false);
exportWidget( widgetId )
Returns the widget of the specified ID among the widgets contained in the WidgetContainer.
If no ID is given, null will be returned.
Related Function: exportWidgets can return information of all widgets currently contained in the WidgetContainer.
Parameter
nametyperequireddescription
widgetIdStringYWidget ID
Return
typedescription
ObjectWidget object
Sample
// Save a certain widget information using exportWidget(). var jsonObj = widgetContainer1.exportWidget('widget1'); var jsonObj2 = widgetContainer1.exportWidget('widgetContainer1_widget1'); // Output the saved JSON. console.log(jsonObj); console.log(jsonObj2);
exportWidgets( )
REturns current widget information in the WidgetContainer as JSON data.
Return
typedescription
Object[]Array of the widget objects
Sample
// Save current widgets information in jsonArr using exportWidgets(). var jsonArr = widgetContainer1.exportWidgets(); // Output the saved JSON. console.log(jsonArr);
focus( )
Focuses the WebSquare component. (Supported in all WebSquare components.)
getDisabled( )
Returns the current value of the disabled property. (Supported in all WebSquare components.)
Return
typedescription
BooleanValue of the disabled property
Sample
// (Example) Check the current value of the disabled property. var returnValue = componentId.getDisabled(); // (Return Example) false
getGenerator( )
In case generated by the Generator component, returns the parent Generator object that created the component itself. (Supported in all WebSquare components.)
Return
typedescription
ObjectParent Generator object
Sample
// (Example) The Generator (parent) create a Trigger (child). <w2:generator id="generator1"> <w2:trigger id="trigger1" ev:onclick="scwin.trigger1_onclick"></w2:trigger></w2:generator> // In the example below, upon the end user’s clicking the Trigger 1, the generator1 object will be displayed on the console. scwin.trigger1.onclick = function(){ console.log(this.getGenerator());}
getID( )
Returns the ID of the WebSquare component. (Supported in all WebSquare components.)
Return
typedescription
StringWebSquare component ID
Sample
// Upon dynamically receiving a WebSquare component, the ID can be checked as shown below. function fn_validCheck(tmpObj){ var compID = tmpObj.getID(); } // If the tmpObj in the above example has "input1" ID. // (Return) "input1"
getInitStyle( CSS )
Returns the initial style of the WebSquare component. (Supported in all WebSquare components.)
Parameter
nametyperequireddescription
CSSStringNProperty (If not specified, all properties will be displayed.)
getOpacity( )
Returns the opacity of the WebSquare component. (Supported in all WebSquare components.)
The Engine returns the opacity value of the CSS.
Return
typedescription
IntegerOpacity
Sample
// Apply the opacity CSS to the InputBox component. <xf:input id="input1" style="position: relative;width: 144px;height: 21px;opacity:0.2;"></xf:input> // Return the opacity of the InputBox. var returnValue = input1.getOpacity(); // A real number between 0 and 1 will be returned. // (Return) "0.2"
getOriginalID( )
Returns the originalID of the WebSquare component. (Supported in all WebSquare components.)
The originalID is valid when the scope function is in use.
For scope="true" WFrame, component IDs inside the WFrame is changed with the prefix(wframeID + "_") being added before the ID given by the user (originalID).
The originalID means the ID before the prefix being added.
Return
typedescription
StringoriginalID of the component
Sample
// An example of multi-WFrame page // Main page with a WFrame (main.xml) <w2:wframe id="wframe1" src="text.xml" scope="true"/> // Source page to be contained in the WFrame (text.xml) <w2:textbox id="textbox1"/> // (Example) Check the Id and the original ID in the script of text.xml // Run getID. textbox1.getID(); // "wframe1_textbox1" is returned. // Run getOriginalID. textbox1.getOriginalID(); // "textbox1" is returned.
getPluginName( )
Returns the name of the WebSquare component. (Supported in all WebSquare components.)
Return
typedescription
StringName of the WebSquare component (pluginName)
Sample
// When a common function dynamically receives a WebSQuare object as shown below, different actions can be made for each component type. var commObj = {}; commObj.fn_makeReqData = function(tmpObj){ var tmpID = tmpObj.getID(); // Component ID var tmpCompType = tmpObj.getPluginName(); // Component name if(tmpCompType == "input"){ //..Logic.. }else if(tmpCompType == "gridView"){ //..Logic .. }else{ //..Logic.. } };
getPosition( positionName )
Returns the position (left and top) of the WebSquare component. (Supported in all WebSquare components.)
When the position is set in 0%, the value will be converted into %.
Parameter
nametyperequireddescription
positionNameStringY[left, top] Position type
Return
typedescription
NumberPosition of the component
Sample
// CSS margin is applied to the Input component as shown below. <xf:input id="input1" style="position: relative;width: 144px;height: 21px;margin:10px;"></xf:input> // (Example) Check the top value of the InputBox. var returnValue = input1.getPosition("top"); // Position value in pixels will be returned. // (Return) 10
getReadOnly( )
Returns the current value of the readOnly property. (Supported in all WebSquare components.)
Return
typedescription
BooleanThe current setting of the readOnly property
Sample
// Example to check the readOnly setting of the component. var returnValue = componentId.getReadOnly(); // (Return Example) false
getScope( )
For the child component of a scope="true" WFrame, returns the parent WFrame object. (Supported in all WebSquare components.)
For scope="true" WFrame, null will be returned.
Return
typedescription
ObjectWFrame object or null
Sample
// (Example) // The main page has wframe1 which contains wframe1 which also contains wframe11. // The source page of wframe11 has textbox1. textbox1.getScope(); // (Return Example) wframe11 object
getScopeWindow( )
For the child component of a scope="true" WFrame, returns the parent WFrame object. (Supported in all WebSquare components.)
If not a child of a scope="true" WFrame, a global window object will be returned.
Return
typedescription
ObjectScope object of the WFrame or a global window object
Sample
// (Example) // The main page has wframe1 which contains wframe1 which also contains wframe11. // The source page of wframe11 has textbox1. var scope = textbox1.getScopeWindow(); scope.wframe11 === textbox1.getScope(); // true
getSize( sizeName )
Sets the size (width and height) of the WebSquare component. (Supported in all WebSquare components.)
If set in %, values will be converted into pixels.
Parameter
nametyperequireddescription
sizeNameStringYSize types. For calculation of each size type, see the below:
height : element.clientHeight innerHeight : element.clientHeight + padding outerHeight : element.clientHeight + padding + border outerMarginHeight : element.clientHeight + padding + border + margin width : element.clientWidth innerWidth : element.clientWidth + padding outerWidth : element.clientWidth + padding + border outerMarginWidth : element.clientWidth + padding + border + margin
Return
typedescription
NumberSize of the component
Sample
var returnValue = componentId.getSize("width"); // (Return Example) 100 // Values are in pixels. // If set in %, values will be converted into pixels.
getStyle( propertyName )
Returns the CSS setting of the WebSquare component. (Supported in all WebSquare components.)
Parameter
nametyperequireddescription
propertyNameStringYCSS property to return
Return
typedescription
StringCSS value
Sample
// Define an Input component. <xf:input id="input1" style="position: relative;width: 144px;height: 21px;"></xf:input> // (Example) Check the width of the InputBox above. var returnValue = input1.getStyle("width"); // (Return) "144px"
getStyleValue( style )
[deprecated]
Use getStyle instead.
Returns the current CSS applied to the WebSquare component.
Parameter
nametyperequireddescription
styleStringYCSS property to return
Return
typedescription
StringCSS value (Colors are returned in HexCode.)
getTitle( )
Returns the title of the WebSquare component. (Supported in all WebSquare components.)
Return
typedescription
StringTitle
Sample
// In the following example, the Title is “Input Name”. <xf:input id="input1" style="position: relative;width: 144px;height: 21px;" title="이름 입력"></xf:input> var tmpTitle = input1.getTitle(); // (Return Example) “Enter your name.”
getUdcHome( )
Returns the path of the UDC file including the file name in which the UDC object is defined. (Supported in all WebSquare components.)
The file name includes .xml. In order to get the file path without .xml, use getUdcRoot.
When called by a WebSquare component, not a UDC object, “undefined” will be returned.
Return
typedescription
StringUDC file path (For others than the UDC, undefined will be returned.)
Sample
// Example // UDC file path is /a/b/udc.xml. // Page XML is /a/c/main.xml. // UDC ID is udc1. udc1.getUdcHome(); // (Result) /a/b/udc.xml
getUdcRoot( )
Returns the path of the UDC file in which the UDC object is defined. (Supported in all WebSquare components.)
Not contains the file name. In order to get a path including the file name, use getUdcHome.
When called by a WebSquare component, not a UDC object, “undefined” will be returned.
Return
typedescription
StringUDC file path (For others than the UDC, undefined will be returned.)
Sample
// Example // UDC file path is /a/b/udc.xml. // Page XML is /a/c/main.xml. // UDC ID is udc1. udc1.getUdcHome(); // (Execution Result) /a/b/
getUserData( key )
Returns the value set by setUserData or directly defined by the user in the XML file. (Supported in all WebSquare components.)
Parameter
nametyperequireddescription
keyStringYData key
Return
typedescription
StringValue for the given key
Sample
// (Example) Setting the user property (setTest) in the InputBox <xf:input id="input1" style="position: relative;width: 144px;height: 21px;" setTest="Hello"></xf:input> // Returns the value of the setTest property. input1.getUserData("setTest"); // (Return) "Hello" // Set 'valueTest' (key) and 'WebSquare' (data) through setUserData. input1.setUserData("valueTest","WebSquare"); // Returns the value of the setTest property. input1.getUserData("WebSquare"); // (Return) "WebSquare"
getWidgetById( id )
Returns the widget object of the corresponding widget ID. If there is no corresponding widget, null will be returned.
Parameter
nametyperequireddescription
idStringYWidget ID
Return
typedescription
ObjectWidget of the corresponding ID
Sample
// Save a widget object of which ID is 'widget0' in the widget parameter. var widget = widgetContainer1.getWidgetById('widget0'); // If no corresponding widget is found, null will be returned. widgetContainer1.getWidgetById('NoSuchId') === null; // true;
getWidgetByTitle( id )
Returns the widget object of the corresponding widget title. If there is no corresponding widget, null will be returned.
If the widget is overlapping, the first-fund widget will be returned.
Parameter
nametyperequireddescription
idStringYWidget ID
Return
typedescription
ObjectWidget of the corresponding ID
Sample
// Save a widget object of which title is 'widget0' in the widget parameter. var widget = widgetContainer1.getWidgetByTitle('widget0'); // If no corresponding widget is found, null will be returned. widgetContainer1.getWidgetByTitle('NoSuchTitle') === null; // true;
hasClass( className )
Checks whether the WebSquare component has a certain class. (Supported in all WebSQuare components.)
Parameter
nametyperequireddescription
classNameStringYName of the class to check
Return
typedescription
BooleanWhether the class exists or not
Sample
// The class is directly defined in the inputBox component. <xf:input id="input1" style="position: relative;width: 144px;height: 21px;" class="tmpInputClass"></xf:input> var returnValue = input1.hasClass("tmpInputClass"); // (Return) true
hide( )
Hides the WebSquare component. (Supported in all WebSquare components.)
display:none; or visibility:hidden; CSS is applied.
Sample
// (Example) Hide the component. componentId.hide();
importWidget( id , jsonObj )
Obtains information of a single widget currently existing as JSON and adds it to the WidgetContainer.
The internal operation is to remove the widget of the corresponding ID and to render it again. However, the ID is maintained.
Related Function: importWidgets is to add multiple widgets not existing currently to the WidgetContainer.
Parameter
nametyperequireddescription
idStringYWidget ID
jsonObjObjectYArray of widget objects
Return
typedescription
BooleanExecution status
importWidgets( jsonArr , clearFlag )
Imports multiple widgets currently not existing to the WidgetContainer based on the received JSON data.
If the clearFlag is true, all existing widgets will be removed and a new widget will be added.
Parameter
nametyperequireddescription
jsonArrObject[]YArray of widget objects
clearFlagBooleanYWhether to remove existing widgets or not
Return
typedescription
Object[]Array of the imported widget objects
Sample
// Save jsonArr of the current widgets using exportWidgets(). var jsonArr = widgetContainer1.exportWidgets(); // Display the widgets of the jsonArr after removing the existing widgets. widgetContainer1.importWidgets(jsonArr, true);
isValidPos( x , y , unitWidth , unitHeight )
Returns the validity of the location based on the received information.
However, conflict among the widgets will not be checked. Only, the boundary and min/max limits will be checked.
Parameter
nametyperequireddescription
xNumberYX value of the widget
yNumberYY value of the widget
unitWidthNumberYunitWidth of the widget
unitHeightNumberYunitHeight of the widget
Return
typedescription
BooleanValidity of the location
Sample
//x === -1 is not a valid location so result === false will be returned. var result = isValidPos(-1, 3, 2, 3);
moveWidget( widgetId , newX , newY )
Moves the widget of the corresponding ID to the specified location (newX, newY).
If newX or newY is not valid, the existing widget will be maintained.
Rolled back to the previous status and tries again.
If successful after resolving of the conflicts, commit will be executed. Otherwise, rollback will be executed.
Upon successful moving, true will be returned. Otherwise, false will be returned.
Parameter
nametyperequireddescription
widgetIdStringYID of the widget to control.
newXNumberNNew X value of the widget
newYNumberNNew Y value of the widget
Return
typedescription
BooleanExecution result
Sample
// Move the widget0 to (2,2). widgetContainer1.moveWidget('widget0', 2, 2);
redraw( )
Renders the widgets in the WidgetContainer accordingly.
Called upon execution completion of the API. In case drag&drop is used, called upon changes in real-time locations of the widgets.
All rendering operations including oneColumn, maximize, minimize, and ghost are made by calling _renderWithRect.
removeClass( className )
Removes a class from the WebSquare component. (Supported in all WebSquare components.)
Only the classes added by addClass can be removed.
In order to remove classes directly defined as a property of the component, add the following in config.xml. // Add the following in config.xml. <style><removeDefaultClass value="true" /></style>
Parameter
nametyperequireddescription
classNameStringYName of the class to remove
Sample
// If the class is directly defined as an InputBox property. <xf:input id="input1" style="position: relative;width: 144px;height: 21px;" class="tmpInputClass"></xf:input> // In the config.xml file, add the following. <style> <removeDefaultClass value="true" /> </style> // Classes can be removed by removeClass. input1.removeClass("tmpInputClass");
removeTitleClass( id , className )
Removes the class from the title according to the titleClass property.
Related Property: titleClass
Parameter
nametyperequireddescription
idStringYWidget ID
classNameStringYName of the class to remove from the widget
Sample
Dynamically remove the class ("w2widget_disable") applied to the title of the widget ("widget1"). widgetContinerID.removeTitleClass("widget1","w2widget_disable");
removeWidgets( widgetIds )
Removes widgets of the specified IDs.
The internal operation is to call _removeWidgets to actually remove the widgets. Upon successful removal, array of the deleted widget IDs will be returned.
A widget object or an array of the widget objects will enable widget removal. However, ID or ID array is recommended.
Parameter
nametyperequireddescription
widgetIdsString | String[]YArray of the widget IDs to remove
Return
typedescription
String[]Array of the removed widget IDs
Sample
var ids = ['widget0', 'widget1', 'widget2']; // Remove widgets of which IDs are widget0, widget1, and widget2. widgetContainer1.removeWidgets(ids); widgetContainer1.getWidgetById('widget0') === null // true;
resizeWidget( widgetId , newWidth , newHeight , options )
Resizes the widget of the specified ID into the new size (newWidth, newHeight).
If newWidth or newHeight is not valid, the current widget status will be maintained.
Rolled back to the previous status and tries again.
If successful after resolving of the conflicts, commit will be executed. Otherwise, rollback will be executed.
Upon successful resizing, true will be returned. Otherwise, false will be returned.
Parameter
nametyperequireddescription
widgetIdStringYID of the widget to control.
newWidthNumberNNew unitWidth of the widget
newHeightNumberNNew unitHeight of the widget
optionsObject | Object[]YOther options
Return
typedescription
BooleanExecution result
Sample
// Resize widget1 into (2,2). Even when resizeWidget is false, forced resizing is possible. widgetContainer1.resizeWidget("widget1", 2, 2, {"force" : true});
setCols( cols )
Sets the number of the columns in the two-dimensional map based on which the widgets are placed. However, the number of the columns must be the same with or larger than the current widget width.
Parameter
nametyperequireddescription
colsStringYColumns to newly set in the WidgetContainer
Sample
// The following functions when the widget width is 1, 2, 3, or 4. If the widget width is larger than 4, the following example will not function. widgetContainer1.setCols(4);
setDisabled( disabled )
Sets the disabled property of the WebSquare component. (Supported in all WebSquare components.)
Parameter
nametyperequireddescription
disabledBooleanYDisabled status
true: Disabled. false: Not disabled.
Sample
// Sets the disabled property in the component. componentId.setDisabled(true);
setEventPause( evList , flag )
Pauses the event. (Supported in all WebSquare components.)
Parameter
nametyperequireddescription
evListStringNList of the events to pause. (in case of null, all events of the corresponding WebSquare component is paused or restarted.)
flagBooleanYWhether to pause the event or not.
true: Pause. false: Not pause.
Sample
// (Example 1) // Pause the onclick event. input1.setEventPause("onclick", true); // (Example 2) // Restart the onfocus and the onblur events. input1.setEventPause("onfocus,onblur", false); // (Example 3) // Pause all events registered in input1. input1.setEventPause(null, true);
setInitStyle( property )
Restores the initial style of the WebSquare component. (Supported in all WebSquare components.)
Parameter
nametyperequireddescription
propertyStringNCSS property (If not spcified, all properties will be restored.)
Sample
// (Example) group1.setInitStyle();
setOpacity( value )
Sets the opacity in the WebSquare component. (Supported in all WebSquare components.)
The engine sets the opacity property (of CSS).
Parameter
nametyperequireddescription
valueNumberYOpacity (Real number between 0 and 1)
Sample
// (Example) Set the opacity as 0.45. componentId.setOpacity(0.45);
setPosition( left , top , mode )
Sets the position (left, top) of the WebSquare component. (Supported in all WebSquare components.)
Parameter
nametyperequireddescription
leftNumberYLeft position value or null
topNumberYTop position value or null
modeStringNPosition setting method. [default: absolute, delta]
absolute: The inputted value becomes the position. delta: The inputted value is added to the current position.
Sample
// (Example) Set the top position as 100px. componentId.setPosition(null, 100);
setReadOnly( readOnly )
Sets the readOnly proprety of the WebSquare component. (Supported in all WebSquare components.)
Parameter
nametyperequireddescription
readOnlyBooleanYSetting of the readOnly property. (“true”: Used. “false”: Not used.)
Sample
// Set the readOnly property as true. componentId.setReadOnly(true);
setSize( width , height )
Sets the size (width, height) of the WebSquare component. (Supported in all WebSquare components.)
Parameter
nametyperequireddescription
widthNumberYWidth of the component or null.
heightNumberYHeight of the component or null.
Sample
// (Example) Set the height of the component as 100px. componentId.setSize(null,100);
setStyle( propertyName , value )
Sets the CSS of the WebSquare component. (Supported in all WebSquare components.)
Parameter
nametyperequireddescription
propertyNameStringYCSS property to set.
valueStringYValue to set as the specified CSS property
Sample
// (Example 1) Set the width as 200px. componentId.setStyle("width", "200px"); // (Example 2) Set the background as olive. componentId.setStyle("background-color","olive");
setTitleClass( id , className )
Adds a class to the title based on the titleClass property.
Related Property: titleClass
Parameter
nametyperequireddescription
idStringYWidget ID
classNameStringYName of the class to apply to the widget
Sample
Dynamically apply a new class ("w2widget_disable") to the title area of the widget ("widget1"). widgetContinerID.setTitleClass("widget1","w2widget_disable");
setUserData( key , value )
Sets random data in the WebSquare component. (Supported in all WebSquare components.)
Enter key values supported by the component. In case a key value not supported by the component is entered, corresponding logs will be displayed.
Parameter
nametyperequireddescription
keyStringYData key to set
valueStringYDefined data value
Sample
// Set 'data' key and 'WebSquare' value in the component. componentId.setUserData("data", "WebSquare"); // The key must be supported in the component. componentId.setUserData("title", "WebSquare"); // Following logs will be displayed. // !!!WARNING - [title] can't be defined as UserData.
show( displayType )
Shows the WebSquare component on the page. (Supported in all WebSquare components.)
Sets the display property as specified and applies "visibility: show;" CSS.
Parameter
nametyperequireddescription
displayTypeStringNCSS display setting to apply.
block : Uses “display: block;”. (Default) inline : display: inline; none : display: none; "" : Restores to the previous display setting.
Sample
// (Example) display: block; componentId.show(); // (Example) Restore the previous display setting. componentId.show("");
toggleClass( className )
Adds or removes a CSS class to or from a WebSquare component. (Supported in all WebSquare components.)
Removes the class from the WebSquare component.
If the WebSquare component does not have the specified class, adds the class.
Only the classes added by addClass can be removed.
In order to remove classes directly defined as a property of the component, add the following in config.xml. // Add the following in config.xml. <style><removeDefaultClass value="true" /></style>
Parameter
nametyperequireddescription
classNameStringYClass to add or remove
Sample
// The class is directly defined in the inputBox component. <xf:input id="input1" style="position: relative;width: 144px;height: 21px;" class="tmpInputClass"></xf:input> // Add the following in config.xml. <style> <removeDefaultClass value="true" /> </style> // Remove tmpInputClass class. input1.toggleClass("tmpInputClass"); // Add the (previously removed) tmpInputClass. input1.toggleClass("tmpInputClass");
trigger( type , array )
Triggers a certain event in the component. (Supported in all WebSquare components.)
Parameter
nametyperequireddescription
typeStringYEvent to trigger
arrayArrayNArray of parameters to send to the event handler
Sample
// (Example 1) // Trigger the onclick event in input1 component. input1.trigger("onclick"); // (Example 2) // Trigger the onviewchange event in input1, and send (1, 2) parameter to the handler function. input1.trigger("onviewchange", [1,2]);
unbind( type , function )
Removes the event from the component. (Supported in all WebSquare component.)
Parameter
nametyperequireddescription
typeStringNEvent to remove. (If not specified, all events of the component will be removed.)
functionFunctionNHandler function of the event to remove. (If not specified, all handler functions of the event will be removed.)
Sample
// (Example 1) // Remove all events registered in the input1 component. input1.unbind(); // (Example 2) // Remove all handler functions for the onviewchange event of the input1 component. input1.unbind("onviewchange"); // (Example 3) // Remove func1 for the onviewchange event of the input1 component. input1.unbind("onviewchange", func1);
visible( flag )
[deprecated]
Use show/hide or setStyle instead.
The Engine sets the CSS visibility property.
Parameter
nametyperequireddescription
flagBooleanYCSS visibility setting
true : visibility: visible; false : visibility: hidden;