Version:\n _$version$_\n ( Detecting new version...)\n
\n
\n
\n
_$lic$_
\n
\n
\n
Powerful rapid application development and runtime platform
\n
\n
\n
Server Code: _$serverCode$_
\n
\n
\n
\n \n
\n
\n
\n \n
Buy WebBuilder
\n
\n WebBuilder is released under commercial license, and unauthorized commercial use is illegal. \n Buy Now: https://www.geejing.com/buy \n If you have any question please contact our sales team: contact@geejing.com\n
\n \n
Development Team
\n
\n
\n
Amy Liu
\n
Andy Williams
\n
Bing Xia
\n
Brian Galvin
\n
Changxing Chen
\n
Duncan Soman
\n
Eric Kane
\n
Fred Gibson
\n
Fuming Guo
\n
Hongyu Zhang
\n
Jiadong Wu
\n
Jie Chen
\n
Kevin Zhao
\n
Lindsey Su
\n
Ming Zhao
\n
Muran Xiao
\n
Olinda Ray
\n
Owen Wang
\n
Rena Jiang
\n
Ruiyang Li
\n
Sariya Diamond
\n
Terry Sam
\n
Tianen Wang
\n
Wenhao Jin
\n
Wilt Austin
\n
\n
\n \n
System Requirements
\n
\n
\n
Items
\n
Requirements
\n
\n
\n
Operating System
\n
Windows, Linux, MacOS
\n
\n
\n
Web Application Servers
\n
Any Standard Server(Tomcat, Jetty, Resin, WebLogic etc.)
\n
\n
\n
Memory
\n
800 MB
\n
\n
\n
Disk Space
\n
1 GB(Contains JRE and Tomcat)
\n
\n
\n
Desktop & Mobile Browser
\n
Modern Browsers(Chrome, Edge, Firefox, WebView etc.)
\n
\n
\n \n
The Third Party Software
\n
WebBuilder requires these third-party software, all of which use friendly licenses and are open source and free.\n
\n
\n
\n
Software Name
\n
License
\n
\n
\n
Apache Softwares
\n
Apache
\n
\n
\n
GraalVM
\n
UPL
\n
\n
\n
JSON.org
\n
Public
\n
\n
\n
SLF4J
\n
MIT
\n
\n
\n
Quartz
\n
Apache
\n
\n
\n
Terser
\n
BSD
\n
\n
\n
Javascript Obfuscator
\n
BSD 2-Clause
\n
\n
\n
CSSO
\n
MIT
\n
\n
\n
Monaco Editor
\n
MIT
\n
\n
\n
X6
\n
MIT
\n
\n
\n
Quill
\n
BSD 3-Clause
\n
\n
\n \n
Warning: WebBuilder has legal copyright registrations in the world. Unauthorized use will result in severe civil\n and criminal penalties and will be prosecuted to the maximum extent possible under the law.
\n\n`;\n return html;\n}\n/**\n * Get news items list.\n * @param {Number} count Items count.\n * @param {String} lang Page language.\n * @param {Boolean} wrapMode Whether auto wrap items.\n * @return {Object} News object with lastModified and content.\n */\nfunction createNews(count, lang, wrapMode) {\n let i = 0, frs, rs, html, time = 0, summary;\n\n html = '';\n frs = Wb.sqlRS({\n sql: 'select url,title,last_modified,html_content from wb_cms where is_news=1 and lang={?lang?} order by sdate desc',\n params: { lang }\n });\n try {\n rs = frs.resultSet;\n while (rs.next()) {\n i++;\n if (i > count)\n break;\n time = Math.max(time, rs.getTimestamp(3).getTime());\n html += '';\n html += '
This example demonstrates how a component's \"visible\" property bind to a specified module. If the module\n is accessible, it is visible, otherwise it is hidden.
\n
\n
addBtn is binded to example/crud/dict-edit-dialog/add.xwl
\n
editBtn is binded to example/crud/dict-edit-dialog/edit.xwl
\n
delBtn \"disabled\" property is binded to \"delDisabled\" which set in serverScript.
\n This example demonstrates that there is no default container (usually a tab card) when the module is displayed, and\n the\n entire module is automatically destroyed when the main window is closed.\n
\n
\n The module has parameters: {container: false}.\n Please click the [Properties] button to view the module parameters on the IDE.\n
Applications built with WebBuilder are high-performance, and the client-applications and\n server-applications can be deployed separately as independent applications or merged into a single application.
\n
Client applications:
\n
\n
Efficient algorithms and refined code are used in JavaScript.
\n
The construction of the page uses effective methods to prevent page redraw and reflow.
\n
Only uses the native CSS on the page layout without using JavaScript to calculate the layout.
\n
Advanced component library allows users to experience smooth and live effects.
\n
Modern JS and CSS are used in the client application.
\n
\n
Server applications:
\n
\n
Efficient algorithms and refined code enable programs to run faster with fewer resources.
\n
JavaScript on the sytem leverages the compiler to provided unparalleled performance.
\n
The system caches multiple optimized and preloaded execution contexts to support high concurrency.
\n
Share data and code with other languages like Java, Ruby, Python, LLVM, R, and others.
\n
JavaScript compatible with the latest ECMAScript specification.
Select container control that requires visual design, such as click viewport1 node.
\n
Click the [UI Designer] button on the toolbar to launch the visual layout designer.
\n
Drag the control(or double click/Ctrl + double click) from the control tree to the designer.
\n
Drag the control to adjust its position.
\n"
}
}
]
}
]
}
# example/basic/vue-el.xwl
Title: vue-el
```json
{
"title": "",
"icon": "",
"img": "",
"tags": "",
"hideInMenu": "false",
"text": "module",
"cls": "Wb.Module",
"properties": {
"cid": "module",
"links": "[\n 'https://unpkg.com/element-ui/lib/theme-chalk/index.css',\n 'https://unpkg.com/vue@2/dist/vue.js',\n 'https://unpkg.com/element-ui/lib/index.js'\n]"
},
"_icon": "module",
"_expanded": true,
"events": {
"initialize": "Cls['My.Select'] = class mySelect extends Wb.Control {\n /** @property {Element} selectEl Select dom element. */\n /** @property {Object} vue Vue object. */\n /***/\n init(configs) {\n let me = this;\n super.init(configs);\n me.selectEl = me.addEl('w-flex w-fit').addEl();\n me.vue = new Vue({\n el: me.selectEl,\n template: `\n \n \n `,\n data: {\n multiple: false,\n clearable: false,\n items: [],\n value: ''\n },\n methods: {\n handleVisibleChange(visible) {\n if (visible) {\n // ElementUI PopupManager may read zindex from Globals.zIndex++\n setTimeout(f => this.$refs.select.popperElm.style.zIndex = Globals.zIndex++);\n }\n }\n }\n });\n }\n /***/\n destroy() {\n super.destroy();\n this.vue.$destroy();\n }\n /** @property {String} - The value of the select control. */\n set value(value) {\n this.vue.value = value;\n }\n /***/\n get value() {\n return this.vue.value;\n }\n /** @property {Array} - Dropdown option list. @key */\n set items(value) {\n this.vue.items = value;\n }\n /***/\n get items() {\n return this.vue.items;\n }\n /** @property {Boolean} - Whether to include a clear button. */\n set clearable(value) {\n this.vue.clearable = value;\n }\n /***/\n get clearable() {\n return this.vue.clearable;\n }\n}"
},
"items": [
{
"_icon": "viewport",
"text": "viewport1",
"cls": "Wb.Viewport",
"properties": {
"cid": "viewport1",
"layout": "grid1"
},
"_expanded": true,
"items": [
{
"_icon": "label",
"text": "mainLabel",
"cls": "Wb.Label",
"properties": {
"cid": "mainLabel",
"text": "Use Vue Element UI",
"cls": "w-title3"
}
},
{
"_icon": "label",
"text": "descLabel",
"cls": "Wb.Label",
"properties": {
"cid": "descLabel",
"text": "This example demonstrates how to use third-party components, such as vue element UI. We strongly recommend that you use WebBuilder components, this example is only for demonstration purposes."
}
},
{
"_icon": "title",
"text": "tplTitle",
"cls": "Wb.Title",
"properties": {
"cid": "tplTitle",
"title": "Element Select"
}
},
{
"_icon": "component",
"text": "selectComp",
"cls": "Wb.Component",
"properties": {
"cid": "selectComp",
"cls": "w-fit"
},
"events": {
"ready": "let comp = this;\n\ncomp.vue = new Vue({\n el: comp.el.addEl(),\n template: `\n \n \n `,\n data() {\n return {\n options: [{\n value: 'option1',\n label: 'Golden Cake'\n }, {\n value: 'option2',\n label: 'Chocolate'\n }, {\n value: 'option3',\n label: 'Cookie'\n }, {\n value: 'option4',\n label: 'Noodles'\n }, {\n value: 'option5',\n label: 'Beef'\n }],\n value: ''\n }\n }\n});"
}
},
{
"_icon": "button",
"text": "setValueBtn",
"cls": "Wb.Button",
"properties": {
"cid": "setValueBtn",
"text": "Set Value",
"justifySelf": "start"
},
"events": {
"click": "app.selectComp.vue.value = 'option4';"
}
},
{
"_icon": "button",
"text": "getValueBtn",
"cls": "Wb.Button",
"_expanded": true,
"properties": {
"cid": "getValueBtn",
"text": "Get Value",
"justifySelf": "start"
},
"events": {
"click": "let vue = app.selectComp.vue, value = vue.value;\nWb.tip('Select value is: ' + vue.options.find(opt => opt.value == value)?.label);"
}
},
{
"_icon": "title",
"text": "encapsulateToClassTitle",
"cls": "Wb.Title",
"properties": {
"cid": "encapsulateToClassTitle",
"title": "Encapsulate into a class as a WebBuilder control"
}
},
{
"_icon": "button",
"text": "addSelectBtn",
"cls": "Wb.Button",
"_expanded": true,
"properties": {
"cid": "addSelectBtn",
"text": "Add Select Component",
"justifySelf": "start"
},
"events": {
"click": "let comp;\n\napp.selectIndex ??= 1;\ncomp = app.selectContainer.add({\n cname: 'mySelect',\n text: 'Select ' + app.selectIndex,\n value: 'value2',\n clearable: true,\n items: [{\n value: 'value1',\n text: 'Golden Cake'\n }, {\n value: 'value2',\n text: 'Chocolate'\n }, {\n value: 'value3',\n text: 'Cookie'\n }]\n});\ncomp.focus();\ncomp.highlight();\napp.selectIndex++;"
}
},
{
"_icon": "container",
"text": "selectContainer",
"cls": "Wb.Container",
"properties": {
"cid": "selectContainer",
"layout": "grid2",
"height": "10em"
},
"_expanded": true
},
{
"_icon": "label",
"text": "sourceLabel",
"cls": "Wb.Label",
"properties": {
"cid": "sourceLabel",
"text": "Source code of the class"
}
},
{
"_icon": "edit",
"text": "codeEditor1",
"cls": "Wb.CodeEditor",
"properties": {
"cid": "codeEditor1",
"value": "// Defined in module.initialize event\nCls['My.Select'] = class mySelect extends Wb.Control {\n /** @property {Element} selectEl Select dom element. */\n /** @property {Object} vue Vue object. */\n /***/\n init(configs) {\n let me = this;\n super.init(configs);\n me.selectEl = me.addEl('w-flex w-fit').addEl();\n me.vue = new Vue({\n el: me.selectEl,\n template: `\n \n \n `,\n data: {\n multiple: false,\n clearable: false,\n items: [],\n value: ''\n },\n methods: {\n handleVisibleChange(visible) {\n if (visible) {\n // ElementUI PopupManager may read zindex from Globals.zIndex++\n setTimeout(f => this.$refs.select.popperElm.style.zIndex = Globals.zIndex++);\n }\n }\n }\n });\n }\n /***/\n destroy() {\n super.destroy();\n this.vue.$destroy();\n }\n /** @property {String} - The value of the select control. */\n set value(value) {\n this.vue.value = value;\n }\n /***/\n get value() {\n return this.vue.value;\n }\n /** @property {Array} - Dropdown option list. @key */\n set items(value) {\n this.vue.items = value;\n }\n /***/\n get items() {\n return this.vue.items;\n }\n /** @property {Boolean} - Whether to include a clear button. */\n set clearable(value) {\n this.vue.clearable = value;\n }\n /***/\n get clearable() {\n return this.vue.clearable;\n }\n}",
"readonly": "true",
"height": "25em"
},
"_expanded": true
}
]
}
]
}
# example/basic/wizard.xwl
Title: wizard
```json
{
"title": "",
"icon": "",
"img": "",
"tags": "",
"hideInMenu": "false",
"text": "module",
"cls": "Wb.Module",
"properties": {
"cid": "module"
},
"_icon": "module",
"events": {
"initialize": "Wb.apply(app, {\n /**\n * Set buttons disabled.\n */\n setButtons() {\n let ct = app.cardCt1, activeIndex = ct.activeIndex;\n\n app.prevBtn.disabled = activeIndex == 0;\n app.nextBtn.disabled = activeIndex >= ct.items.length - 1;\n }\n});"
},
"_expanded": true,
"items": [
{
"_icon": "viewport",
"text": "viewport1",
"cls": "Wb.Viewport",
"properties": {
"cid": "viewport1",
"layout": "middle",
"autoScroll": "true",
"background": "true"
},
"_expanded": true,
"items": [
{
"_icon": "win-restore",
"text": "cardCt1",
"cls": "Wb.CardCt",
"properties": {
"cid": "cardCt1",
"buttonAlign": "center",
"width": "40em",
"height": "20em",
"title": "Application wizard",
"icon": "database",
"padding": "true",
"minButtonWidth": "8em",
"frame": "true",
"cls": "w-limit-width"
},
"events": {
"ready": "app.setButtons();"
},
"_expanded": true,
"items": [
{
"_icon": "container",
"text": "container1",
"cls": "Wb.Container",
"properties": {
"cid": "container1",
"text": "Step1"
}
},
{
"_icon": "container",
"text": "container2",
"cls": "Wb.Container",
"properties": {
"cid": "container2",
"text": "Step2"
}
},
{
"_icon": "container",
"text": "container3",
"cls": "Wb.Container",
"properties": {
"cid": "container3",
"text": "Step3"
}
},
{
"_icon": "container",
"text": "container4",
"cls": "Wb.Container",
"properties": {
"cid": "container4",
"text": "Step4"
}
},
{
"cls": "Wb.Array",
"properties": {
"cid": "buttons"
},
"text": "buttons",
"_expanded": true,
"_icon": "array",
"items": [
{
"cls": "Wb.Button",
"events": {
"click": "app.cardCt1.activeIndex--;\napp.setButtons();"
},
"properties": {
"cid": "prevBtn",
"text": "Previous",
"icon": "left4"
},
"text": "prevBtn",
"_expanded": true,
"_icon": "button"
},
{
"cls": "Wb.Button",
"events": {
"click": "app.cardCt1.activeIndex++;\napp.setButtons();"
},
"properties": {
"cid": "nextBtn",
"text": "Next",
"icon": "right4",
"iconAlign": "right"
},
"text": "nextBtn",
"_expanded": true,
"_icon": "button"
}
]
}
]
}
]
}
]
}
# example/coding/client-js/common-usage.xwl
Title: common-usage
```json
{
"title": "",
"icon": "",
"img": "",
"tags": "",
"hideInMenu": "false",
"text": "module",
"cls": "Wb.Module",
"properties": {
"cid": "module"
},
"_icon": "module",
"_expanded": true,
"items": [
{
"_icon": "edit",
"text": "codeEditor1",
"cls": "Wb.CodeEditor",
"_expanded": true,
"properties": {
"cid": "codeEditor1",
"full": "true",
"value": "//This example demonstrates the general usage of client JavaScript programming\n//For more resources, please visit: https://developer.mozilla.org/en-US/docs/Web/JavaScript\n\n//Open/Run modules, open windows and submit forms\nWb.open('m?xwl=admin/dbe'); //Open the database explorer module\nWb.open({ url: 'dbe', params: { foo: 'bar' }, method: 'POST' }); //Pass parameters and set method\nWb.openNormal('dbe'); //Open the database explorer module and allow the page to refresh\nWb.run({ url: 'dbe', params: { foo: 'bar' }, container: app.panel1 }); //Runs the module and displays it in the specified container\n//Run the module and dynamically add it's viewport1 to panel1 in the callback function. Owner means that viewport1 in dbe owns the\n//entire module, and destroys the entire module when viewport1 is destroyed\nWb.run({ url: 'dbe', owner: 'viewport1', success(scope) { app.panel1.add(scope.viewport1) } });\nWb.openWin('https://developer.mozilla.org/'); //Opens MDN in a new window\n//Set the parameters and method and open into the specified iframe\nWb.openWin({ url: 'dbe', params: { foo: 'bar' }, method: 'POST', target: 'myIframe' });\n//Submit the form with parameters\nWb.submit('https://www.geejing.com', { p1: 'foo', p2: new Date() });\n//Browse URL in Tab card(Wb.Tab.mainTab)\nWb.browse('https://www.geejing.com');\n\n//Download\nWb.download('m?xwl=foo/bar', { param1: 'abc' }); //Download url with parameters\nWb.downloadBlob(file1, 'myFile.txt'); //Download blob\nWb.downloadBase64(base64Text, 'myFile.dat'); //Download the Base64-encoded string as a file\n\n//Displays a dialog box containing the specified controls\nWb.prompt('My Dialog', [{ text: 'Your Name', cid: 'name' }], (values, win) => {\n Wb.tip(values.name);\n win.close();\n});\n\n//Show message\nWb.info('Hello'); //Show info\nWb.info('Hello', f => { Wb.tip('click ok') }, true); //Show HTML info\nWb.succ('Hello'); //Show succ\nWb.warn('Hello'); //Show warn\nWb.error('Hello'); //Show error\n//Displays a confirmation dialog box with OK and Cancel buttons\nWb.confirm('Are you sure you want to delete?', f => doSomething());\n//Displays a confirmation dialog box with Yes, No, and Cancel buttons\nWb.choose('Are you sure you want to save?', button => Wb.info(button));\nWb.tip('Hello'); //Show tip that is automatically close with a delay\nWb.tip('Hello', true); //Show HTML tip\nWb.tipAt('Hello', 200, 30); //Show tip at the specified location\nWb.tipSucc('Hello'); //Show succ tip\nWb.tipWarn('Hello'); //Show warn tip\nWb.tipError('Hello'); //Show error tip\nWb.toast('Hello'); //Show single tip that is automatically close with a delay in the center of the window\nWb.toast('Hello', true); //Show HTML toast\nWb.toastSucc('Hello'); //Show succ toast\nWb.toastWarn('Hello'); //Show warn succ\nWb.toastError('Hello'); //Show error succ\nWb.tipSelect(); //Show \"Please select a valid item\" tip in the local language\n\n//Load JS/MJS/CSS files\nWb.load('foo/bar.js', f => doSomething()); //Load js file\n//Load CSS/JS in a specific way\nWb.load(['file.css', 'file.js', { url: 'foo/bar', async: true, type: 'js', reload: true, autoRemove: true }], callback);\nWb.loadx('foo/bar.js').then(f => doSomething()); //Promise version of Wb.load\nWb.loadModule('wb/js/my.mjs', module => module.MyCls.doSomething()); //Load mjs module file\n\n//Access elements as components\nWb.get(div).tip = 'message'; //Gets the Wb.Component object of the specified element and sets the property\nWb.fly('my-div').hide(); //Gets a shared Wb.Component object for the specified element and makes a method call\n\n//Access, setting, and validation values\nvalues = Wb.getValue(panel1); //Get the values of all components in panel1\nvalues = Wb.getValue([panel1, viewport1], true); //Get the values of all components in panel1, viewport1\nWb.setValue(container1, { text1: 'foo', number1: 123 }); //Set the values in container1\n///Set the values to the specific component in container1, panel1\nWb.setValue([container1, panel1], { text1: 'foo', number1: 123 }, true, true);\nWb.reset(panel1); //Resets the values of all components in panel1\nWb.reset([panel1, text1], true); //Resets the values of specific components in panel1 and text1\nWb.clear(panel1); //Clears the values of all components in panel1\nWb.clear([panel1, text1], true); //Clears the values of specific components in panel1 and text1\nif (Wb.verify(panel1)) return; //Verify the values of all components in panel1\nWb.verify([panel1, date1], true, true); //Verify the values of specific components in panel1 and date1\n\n//Send requests\n//Send GET request with parameters\nWb.ajax({ url: path, params: { p1: 'abc', p2: 123 }, method: 'GET', success(resp) { doSuccess(); } });\n//Send POST request with parameters, file and blob\nWb.ajax({ url: path, params: { p1: 'abc', p2: 123, p3: file, p4: blob } });\n//Send request with form, comps and params\nWb.ajax({ url: path, form: myForm, comps: [panel1, file1], params: { foo: 'bar' } });\n//Send request with object and array parameters\nWb.ajax({ url: path, params: { object: { foo: 'bar' }, array: [1, 'abc', new Date()] } });\n//Send request with multiple parameters with the same name\nWb.ajax({ url: path, params: { myParam: Wb.markParams([1, 'abc', new Date()]) } });\n//Send request with payload data and specific header\nWb.ajax({ url: path, data: bigDataContent, header: { 'Content-Type': 'text/html;charset=utf-8' } });\n//Download file in ajax mode\nWb.ajax({ url: path, download: true });\n//Send request with object that can be auto deserialized in server side\nWb.ajax({ url: path, object: { foo: 'bar', num: 123, date: new Date() } });\n//Promise version of Wb.ajax\nWb.fetch({ url: path, params: { p1: 'abc', p2: 123 } }).then(\n result => {\n if (result.ok)\n console.log(result.response);\n else\n console.warn('failed');\n }\n);\n\n//Set the style and class of documentElement\nWb.addCls('w-cls'); //Add class\nWb.removeCls('w-cls'); //Remove class\nWb.setCls(true, 'w-cls'); //Add or remove class\nWb.toggleCls('w-cls'); //Toggle class\n\n//Some getter properties of Wb\nWb.activeComp; //The component that currently has focus\nWb.activeWindow; //The window that currently has focus\n\n//The properties and methods of Event\ne.stopEvent(); //Prevents default and stops the propagation of event\ne.stopSpread(); //Alias for Event.prototype.stopImmediatePropagation\ne.hasAssistKey; //Whether to press any of the Ctrl, Shift, Alt, or Meta keys\n\n//The methods of Function\nWb.info.delay(Wb, 1000, 'Hello'); //Show info with delay\nWb.info.delay(Wb, 1000, 'Hello World'); //Cancel pending delay and show info with delay again\nWb.warn.delays(Wb, 1000, 'Hello'); //Show warn with delay without cancel pending delay\nWb.tip.delay(Wb, 1000, 'tip'); //Show tip with delay\nWb.tip.cancelDelay(Wb); //Cancel pending tip immediately",
"wrapBorder": "0",
"readonly": "true"
}
}
]
}
# example/coding/client-js/control.xwl
Title: control
```json
{
"title": "",
"icon": "",
"img": "",
"tags": "",
"hideInMenu": "false",
"text": "module",
"cls": "Wb.Module",
"properties": {
"cid": "module"
},
"_icon": "module",
"_expanded": true,
"items": [
{
"_icon": "edit",
"text": "codeEditor1",
"cls": "Wb.CodeEditor",
"_expanded": true,
"properties": {
"cid": "codeEditor1",
"full": "true",
"wrapBorder": "0",
"readonly": "true",
"value": "//Access components and controls\n\n//General properties and functions\nlet text = control.text; //Get label text of the control\ncontrol.text = 'text label'; //Text label\ncontrol.html = 'html label'; //HTML label, this property is invalid after setting text property\ncontrol.width = '10em'; //Set width\ncontrol.height = 80; //Set height\ncontrol.visible = false; //Hide control\ncontrol.hide(); //Same as above\ncontrol?.hide(); //Call hide with optional chaining\ncontrol.visible = true; //Show control\ncontrol.show(); //Same as above\ncontrol.appeared = false; //Hide control(not drawn), but still affects layout as normal.\ncontrol.setAppeared(false); //Same as above\ncontrol.disabled = true; //Disable control\ncontrol.setDisabled(true); //Same as above\ncontrol.icon = 'paste'; //Set icon\ncontrol.el.cls = 'cls1 cls2'; //Add cls1, cls2 class name to control's element\ncontrol.cls = 'cls1 cls2'; //Same as above\nconrols.el.removeCls('cls1'); //Remove control's element class name\nconrols.removeCls('cls1'); //Same as above\ncontrol.el.setStyle('color', 'red'); //Set control's element style\ncontrol.setStyle('color', 'red'); //Same as above\ncontrol.el.removeStyle('color'); //Remove control's element style\ncontrol.removeStyle('color'); //Same as above\n\n//Add and delete controls\npanel.insertBefore({ cname: 'text' }, text1); //Insert a new text box before text1\npanel.insertAfter({ cname: 'text' }, text1); //Insert a new text box after text1\npanel.insert(2, { cname: 'text' }); //Insert a new text box at the specific index\npanel.add({ cname: 'button', text: 'My Button' }); //Add components at the last\npanel.addHeader({ cname: 'text' }); //Add a text box as a sub-component in the panel header\npanel.addFooter({ cname: 'text' }); //Add a text box as a sub-component in the panel footer\ncontrol.remove(); //Remove control (control is reusable)\npanel.removeAll(); //Remove all child components in panel (components are reusable)\ncontrol.destroy(); //Destroy control (Really delete)\npanel.destroyAll(); //Destroy all child components in panel (Really delete)\n\n//Event and DOM listeners\npanel.on('destroy', app.onDestroy); //Add component event\npanel.un('destroy', app.onDestroy); //Remove component event\npanel.mon('keydown', app.onKeyDown); //Add dom listeners to panel's element\npanel.mun('keydown', app.onKeyDown); //Remove dom listeners from panel's element\npanel.mon(DocEl, 'keydown', app.onKeyDown); //Add dom listeners to DocEl, the listener will be removed after panel is destroyed.\npanel.mun(DocEl, 'keydown', app.onKeyDown); //Remove dom listeners from DocEl\n\n//Traverse and find\ncontrol = app.myControl; //Down control by app\ncontrol = panel.find('nameText'); //Find direct control by cid\ncontrol = panel.find(item => item.visible && item.foo == 'bar'); //Find direct control by function\ncontrol = panel.down('myControl'); //Down control by cid\ncontrol = panel.down(item => item.visible && item.foo == 'bar'); //Down control by function\ncontrol = panel.children.myControl; //Down control by proxy \"children\"\npanel = text.up('myPanel'); //Up control by cid\npanel = text.up(item => item.visible && item.foo == 'bar'); //Up control by function\ncomps = panel.filter(fn); //Find all direct comps by function\ncomps = panel.downAll(fn); //Down all comps by function\ncomps = text.upAll(fn); //Up all comps by function\npanel.each(item => console.log(item)); // Each direct child comps\npanel.eachOwned(item => console.log(item)); // Each sub-comps\npanel.eachWhole(item => console.log(item)); //Each direct child comps and sub-comps\npanel.cascade(item => console.log(item)); //Cascade comps\npanel.bubble(item => console.log(item)); //Bubble comps\ncontrol = comp.nextSibling; //Gets comp's next sibling\ncontrol = comp.previousSibling; //Gets comp's previous sibling"
}
}
]
}
# example/coding/client-js/dom-element.xwl
Title: dom-element
```json
{
"title": "",
"icon": "",
"img": "",
"tags": "",
"hideInMenu": "false",
"text": "module",
"cls": "Wb.Module",
"properties": {
"cid": "module"
},
"_icon": "module",
"_expanded": true,
"items": [
{
"_icon": "edit",
"text": "codeEditor1",
"cls": "Wb.CodeEditor",
"_expanded": true,
"properties": {
"cid": "codeEditor1",
"full": "true",
"wrapBorder": "0",
"readonly": "true",
"value": "//This example demonstrates dom elements. Only extended members are demonstrated, and native members are described at:\n//https://developer.mozilla.org/en-US/docs/Web/API/Element\n\n//Associations between DOM elements and components\nlet buttonEl = button1.el; //Gets the DOM element associated with the button1\nlet windowEl = window1.el; //Gets the DOM element associated with the window1\nlet button1 = buttonEl.citem; //Gets the button component associated with the button element\nlet window1 = windowEl.citem; //Gets the window component associated with the window element\nlet grid = div.getClosestComp(Wb.Grid); //Get the closest Wb.Grid component that contains div\n\n//Add, delete and modify\nnewEl = parentEl.insertEl(3, 'my-class', 'span'); //Creates a new element and inserts it before the specified index element\nnewEl = parentEl.addEl('my-class'); ///Creates a new element and adds it to the last\nnewEl = parentEl.addTag('span'); //Creates a new element with specific tag and adds it to the last\nnewEl = parentEl.insertAfter(el, refEl); //Inserts a node after the specified node\nnewEl = parentEl.insertElBefore('my-class', 'span', refNode); //Creates a new element and inserts it before the specified node\nnewEl = parentEl.insertElAfter('my-class', 'span', refNode); //Creates a new element and inserts it after the specified node\ndiv.insertHtml('afterend', '
abc
') //insert HTML, alias for insertAdjacentHTML\ndiv.clearChildren(); //Empty all child nodes in the div\n\n//Element class name\nlet cls = div.cls; //Gets class name of div\ndiv.cls = 'cls1'; //Add new class name cls1 to div. Keep the old classNames.\ndiv.cls = 'cls1 cls2 cls3'; //Add new classNames cls1, cls2, cls3 to div. Keep the old classNames.\nel.addCls('my-cls'); //Add a single class name to el\nel.removeCls('my-cls'); //Remove a single class name from el\nel.removeClasses('cls1 cls2 cls3'); ///Remove multiple class names from el\nel.setCls(true, 'my-cls'); //Add or remove a single class name\nel.toggleCls('my-cls'); //Toggle a single class name\nel.containsCls('my-cls'); //Determines whether to include a class name\nel.plainIcon = true; //All icons in this element use a uniform icon color\nel.layout = 'grid3'; //Setting the layout, unlike setting the class, setting a new layout will remove the original layout\n\n//Element style\nel.setStyle('color: red'); //Set element style\nel.getStyle('color'); //Gets element style\nel.removeStyle('color'); //Remove element style\nel.computeStyle(); //Returns a list of calculated styles\nel.styleText = 'color: red; width: 10em'; //Add styles separated by semicolons to an element. Keep the old styles.\n\n//Traverse elements\ndiv.each((el, index) => console.log(el, index)); //Iterate direct child elements\ndiv.bubble(el => console.log(el)); //Bubble traverse\ndiv.bubbleParent(fn); //Bubble traverse without div self\ndiv.cascade(el => console.log(el)); //Cascade traverse\ndiv.cascadeSelf(fn); //Cascade traverse with div self\ndiv.some(el => el.cls.includes('w-disp-none')); //Determines whether there is a specific direct child element\ndiv.every(el => el.cls.includes('w-disp-none')); //Determines whether all direct child elements pass the test function\ndiv.cascadeSome(el => el.cls.includes('w-disp-none')); //Determines whether there is a specific child element\ndiv.cascadeEvery(el => el.cls.includes('w-disp-none')); //Determines whether all child elements pass the test function\ndiv.bubbleSome(el => el.cls.includes('w-disp-none')); //Determines whether there is a specific parent element\ndiv.bubbleEvery(el => el.cls.includes('w-disp-none')); //Determines whether all parent elements pass the test function\n\n//Find elements\nel = div.query('div.w-row'); //Down query the first element, alias for querySelector\nelList = div.queryAll('div.w-row'); //Down query all elements, alias for querySelectorAll\nel = div.closest('div.w-row'); //Match the closest parent element\nel = div.find('w-row'); //Down query the first child element with the specific class name\nel = div.findParent('w-row'); //Up query the first parent element with the specific class name\nelList = div.findParents('w-row'); //Up query all parent elements with the specific class name\nelList = div.filter('w-row'); //Down query all child elements with the specific class name, alias for getElementsByClassName.\nel = div.down('div.w-row'); //Down query the first element, similar to query\nelList = div.downAll(selectors); //Down query all elements, similar to queryAll\nel.downBy(fn, scope); //Down query the first element by function\nel.downAllBy(fn, scope); //Down query all elements by function\nel = div.up('div.w-row'); //Up query the first element, similar to closest\nelList = div.upAll(selectors); //Up query all elements\nel.upBy(fn, scope); //Up query the first element by function\nel.upAllBy(fn, scope); //Up query all elements by function\n\n//Animation effects\ndiv.fadeIn(); //Displays a fade-in effect\ndiv.fadeIn(e => fn(), 300); //Displays a fade-in effect for the specified duration. Execute the callback function when finished.\nWb.info('ok').el.fadeIn(); //Displays a info dialog with the fade-in effect\ndiv.fadeOut(); //Displays a fade-out effect\nwindow1.el.fadeOut(e => window1.close()); //Close the window after displaying the fade-out effect\ndiv.slideIn(); //Slide in from the left\ndiv.slideIn(true); //Slide in from the top\n//Slide in from {x: '10px', y: '5em'} for 2 seconds, and finally remove div\ndiv.slideIn({ x: 10, y: '5em', callback() { div.remove() }, duration: 2000, easing: 'ease-in-out' });\nWb.error('error').el.slideIn(); //Displays an error dialog with the slide-in effect\nel.slideOut(); //Slide out from the right side\nel.slideOut(true); //Slide out from the bottom\nSlide to {x: '10px', y: '5em'} for 2 seconds, and finally remove div\ndiv.slideOut({ x: 10, y: '5em', callback() { div.remove() }, duration: 2000, easing: 'ease-in-out' });\nwindow1.el.slideOut({ callback() { window1.close() } }) //Close the window after displaying the slide-out effect\ndiv.slideTo({ x: 10, y: '2em' }) //The element slides from the current position to the specified position\ndiv.rippleEffect(100, 200); //Generates a ripple effect at a specific location\ndiv.highlight(); //Highlight effect\ndiv.highlight('#f00'); //Highlight effect with the specific color\n\n//Size, location, appearance etc.\nrect = div.getRect(); //Gets the rect of the element, alias for getBoundingClientRect\ndiv.setRect({ x, y, width, height }); //Set the rect of the element\nel.alignTo(destEl, \"tl-bl?\"); // Aligns the element\nel.alignTo(destEl, \"bl-c\", [-8, 0]);// Aligns the element with offsets\ndiv.visible = false; //Turns off the display of an element so that it has no effect on layout.\ndiv.setVisible(false); //Same as above\ndiv.appeared = false; //The element is invisible (not drawn), but still affects layout as normal.\ndiv.setAppeared(false); //Same as above\nisVisible = div.isVisible(); //Determines whether the element is visible deeply\ndiv.show(); //Show element, same as visible = true\ndiv.hide(); //Hide element, same as visible = false\ndiv.width = '8em'; //Set width\ndiv.setWidth('8em'); //Same as above\ndiv.height = 90; //Set height\ndiv.setHeight(90); //Same as above\ndiv.x = '8em'; //Set left\ndiv.setX('8em'); //Same as above\ndiv.y = 90; //Set top\ndiv.setY(90); //Same as above\ndiv.xy = ['8em', 90]; //Set left and top\ndiv.intoView(); //Scroll div into view\ndiv.intoViewCenter(); ///Scroll div into view center\ndiv.focusOnly(); //Sets the focus on div without adjusting the scroll bar\ndiv.autoScroll = true; //Whether scrolling is allowed"
}
}
]
}
# example/coding/js/array-set.xwl
Title: array-set
```json
{
"title": "",
"icon": "",
"img": "",
"tags": "",
"hideInMenu": "false",
"text": "module",
"cls": "Wb.Module",
"properties": {
"cid": "module"
},
"_icon": "module",
"_expanded": true,
"items": [
{
"_icon": "edit",
"text": "codeEditor1",
"cls": "Wb.CodeEditor",
"_expanded": true,
"properties": {
"cid": "codeEditor1",
"full": "true",
"value": "//This example demonstrates array and set. Only extended members are demonstrated, and native members are described at:\n//Array: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array\n//Set: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set\n\n//Add, delete and modify\narray = [1, 2];\narray.push(3); //push new item\narray.pushAll([1, 3, 5]); //All items are added to the array, output: [1, 2, 3, 1, 3, 5]\n[1, 2, 3].merge(new Set([3, 4, 5])); //array merge array/set, output: [1, 2, 3, 3, 4, 5]\narray.remove(2); //remove the first item\narray.removeAll(3); //remove all items\narray.removeFirst(item => item === 2); //remove the first item by function\narray.removeBy(item => item === 2); //remove all items by function\narray.erase(2); //remove item by item index\n[1, 2, 3].insert(0, 'a', 'b'); //Insert items at the specified index, output: [\"a\", \"b\", 1, 2, 3]\narray.pushIf(null, 'b'); //Push values without null/undefined value\n\n//Traverse\n[1, 2, 3].forEach((item, index) => console.log(item));\n[1, 2, 3].each((item, index) => { //each is similar to foreach, each can be interrupted and reversed\n console.log(item);\n if (item == 2)\n return false; //interrupted\n}, scope, true); //true means reverse traversal\n(new Set()).forEach(fn); //forEach set\n(new Set()).each(item => { console.log(item) }); //each set\n\n//Sort\n[1, 2, 3].sort();\narray = [123, 'abc', 'utf-string'];\narray.normalSort(); //Local sort\narray = [{ a: 3, b: 2 }, { a: 1, b: 4 }];\narray.normalSort('a'); //Sort by the \"a\" property\narray.normalSort(['a', 'b'], [false, true]); //Sort by the \"a\" property asc, \"b\" property desc.\narray.lowerSort('a'); //Similar to normalSort, case insensitive.\narray.mixSort('b'); //Similar to normalSort, Mix sort string, number and date locally in case-insensitive. Recommended sorting method.\n(new Set()).sort(params);\n(new Set()).normalSort(params);\n(new Set()).lowerSort(params);\n(new Set()).mixSort(params);\n\n//Prototype function\n[{ name: 'Allen' }, { name: 'Linda' }].pluck('name'); //Extracts the specified name attribute value, output: [\"Allen\", \"Linda\"]\n[1, 3, 5].diff([3, 5]); //Get difference, output: [1]\n[1, 3, 5].intersect([3, 5]); //Get intersect, output: [3,5]\n[1, { foo: 'bar' }, 5].copy(); //Shallow copy\n[1, 3, 5].equals([1, 3, 5]); //Determines whether the content is the same\n[1, 2, 1, 3].unique(); //Distinct array, output: [1, 2, 3]\n[1, 2, 3].unique([3, 4, 5]); //Distinct array, output:[1, 2, 3, 4, 5]\n['a', 'b', 'c'].unique(['d', 'b'], true); //Distinct array with subtract, output: ['a', 'c', 'd', 'b']\nindex = array.indexOf(2); //Get the index of item\nincludes = array.includes(2); //Determines whether the specified item is included\n\n//Getter properties\n[1, 2, 3].firstItem; //Return the first item\n[1, 2, 3].lastItem; //Return the last item",
"wrapBorder": "0",
"readonly": "true"
}
}
]
}
# example/coding/js/common-usage.xwl
Title: common-usage
```json
{
"title": "",
"icon": "",
"img": "",
"tags": "",
"hideInMenu": "false",
"text": "module",
"cls": "Wb.Module",
"properties": {
"cid": "module"
},
"_icon": "module",
"_expanded": true,
"items": [
{
"_icon": "edit",
"text": "codeEditor1",
"cls": "Wb.CodeEditor",
"_expanded": true,
"properties": {
"cid": "codeEditor1",
"full": "true",
"value": "//This example demonstrates the general usage of JavaScript in client and server programming\n//For more resources, please visit: https://developer.mozilla.org/en-US/docs/Web/JavaScript\n\n//Define a class\nCls['My.pack.ClassName'] = class myClassName extends Wb.Base {\n //static class prototype property\n static foo = 'bar';\n\n //static class prototype function\n static func() {\n }\n\n //instance property\n myProp = 'xxx'\n\n //private instance property\n #privateProp = new Date();\n\n //instance prototype members(all members of \"protos\" will be added to the prototype of the class instance)\n static protos = {\n foo: 'bar',\n abc: 123\n };\n\n //constructor function\n constructor(param) {\n super(param); //call super function\n this.param = param; //add param to the class instance\n this.abc = 234; //Add class instance property abc\n this.def = 456; //Add class instance property def\n console.log(this.foo); //show prototype property foo, foo value is \"bar\"\n console.log(this.abc); //show instance property abc, abc value is \"234\"\n delete this.abc; //delete instance property abc\n console.log(this.abc); //show prototype property abc, abc value is \"123\", because there is no instance property at this time\n console.log(this.#privateProp); //show private instance property #privateProp\n this.height = 456; //use setter\n console.log(this.height); //use getter\n }\n\n //prototype function\n myFunc(param) {\n super.myFunc(param); //call super function\n }\n\n //Setter\n set height(value) {\n let me = this;\n\n if (me.height$ !== value) {\n me.height$ = value;\n me.doSomething();\n }\n }\n\n //Getter\n get height() {\n return this.height$;\n }\n}\nlet myCls = new My.pack.ClassName(); //create a new instance\n\n//Define getter and setter in app\nWb.define(app, {\n /** @property {String} - Setter description. */\n set$name(value) {\n //this is equal to app\n if (this.name$ !== value) {\n this.name$ = value;\n doSomething();\n }\n },\n /** @property {String} - Getter description. */\n get$name() {\n //this is equal to app\n return this.name$;\n },\n /**\n * Function description.\n */\n myMethod() {\n }\n});\n\n//Determines the type of value\nisString = Wb.isString(123); //Determines whether the value is a string\nisNumber = Wb.isNumber('abc'); //Determines whether the value is a number\nisNumeric = Wb.isNumeric('123'); //Determines whether the value is a numeric value\nisDate = Wb.isDate(123); //Determines whether the value is a date\nisBoolean = Wb.isBoolean('abc'); //Determines whether the value is a boolean\nisArray = Wb.isArray([1, 2, 3]); //Determines whether the value is an array\nisObject = Wb.isObject({ foo: 'bar' }); //Determines whether the value is a \"JavaScript Object\"\nisFunction = Wb.isFunction('abc'); ///Determines whether the value is a Function\nisPrimitive = Wb.isPrimitive(123); //Determines whether the value is of the narrow original type(String, Number, and Boolean)\nisIterable = Wb.isIterable([]); //Determines whether the value is traversable\nisEmpty = Wb.isEmpty({}); //Determines whether the value is empty(null, undefined, '', [], {} and other object with length 0)\n\n//Conversion of values\nstringValue = String(value); //to a string\nboolValue = Wb.parseBool('false'); //to a boolean. 'false', '0' and falsy value return false, others return true\ndateValue = Wb.parseDate('2021-3-10 15:13:12.18', 'y-MM-dd HH:mm:ss.S'); //Converts specified format text to date\nintValue = parseInt('123'); //to an integer\nfloatValue = parseFloat('1.23'); //to a float\n\n//Copies all enumerable own properties from one or more source objects to a target object. Alias for Object.assign.\nresult = Wb.apply({ abc: 123 }, { foo: 'bar' });\n//Copies non-existent properties from source objects\nresult = Wb.applyIf({ foo: 'abc' }, { foo: 'def', bar: 123 });\n//Copies non undefined/null properties from source objects\nresult = Wb.applyValue({ foo: 'abc' }, { bar: 123, more: null });\n//Copies properties from source objects with specified names\nresult = Wb.applyWith({ foo: 'abc' }, { param1: 'def', param2: 123 }, ['param2']);\n//Copies non undefined/null properties from source objects with specified names\nresult = Wb.applyValueWith({ foo: 'abc' }, { param1: 'def', param2: null }, ['param2']);\n//Copies properties from source objects without specified names\nresult = Wb.applyWithout({ foo: 'abc' }, { param1: 'def', param2: 123 }, ['param2']);\n//Copies properties from source objects and merge object\nresult = Wb.applyMerge({ a: { v1: 1, v2: 2 }, b: 'abc' }, { a: { v3: 3, v4: 4 }, c: 'xyz' });\n//Shallow copy object\nresult = Wb.copy({ abc: 123 });\n//Deep clone object\nresult = Wb.clone({ foo: 'bar', arr: [1, 2, 3] });\n//Copies object with getter/setter support\nresult = Wb.define({ get$method() { }, set$method() { } });\n\n//Encode and decode\n//Converts a JavaScript value to a JSON string. Alias for JSON.stringify.\nlet text = Wb.encode({ foo: 'bar', abc: 123 });\n//Parses a JSON string, constructing the JavaScript value or object described by the string. Alias for JSON.parse.\nlet object = Wb.decode(text);\n//Wb.encode with pretty formatting\nlet prettyText = Wb.encodePretty({ foo: 'bar' });\n//Serialize a JavaScript value to a string. The difference from Wb.encode is that it supports date encoding.\ntext = Wb.serialize({ foo: 'bar', date: new Date()});\n//Deserialize a string to a JavaScript value. The difference from Wb.decode is that it supports date decoding.\nobject = Wb.deserialize(text);\n//Encode the string to a Base64 string\nbase64Text = Wb.encodeBase64(text);\n//Decodes the Base64 string to a string\ntext = Wb.decodeBase64(base64Text);\n\n//Iterates through all members of the object\nWb.each({ abc: 123 }, (k, v) => {\n console.log(k);\n if (k == 'foo')\n return false; //Break iteration\n});\n\n//Find object\n//Find the first member name and output \"bar\"\nWb.find({ foo: 123, bar: 'abc' }, (k, v) => v === 'abc');\n//Find all member names\nWb.filter(object, fn);\n//Determines whether some members meet test condition\nWb.some({ foo: { name: 'Allen' }, bar: { name: 'Linda' } }, (k, v) => v.name == 'Linda');\n//Determines whether all members meet test condition\nWb.every({ foo: { name: 'Allen' }, bar: { name: 'Linda' } }, (k, v) => v.name == 'Linda');\n//Finds the first member name in an object that has the specified value\nWb.findKey({ a: 123 }, 123);\n\n//Down traverse\nitems = [{ param: 'one' }, { param: 'two', items: [{ param: 'three' }] }];\nWb.cascade(items, item => console.log(item.param)); //output: one, two, three\nWb.cascade(parentNode, node => console.log(node), 'childNodes'); //Traverses all child nodes of the element\nobject = { param: 'two', items: [{ param: 'three' }] };\nitems = [{ param: 'one' }, object];\nWb.down(items, item => item.param === 'two'); //Down traverses the object and find the first item\nWb.downAll(items, fn); //Down traverses the object and find all items\n\n//Up traverse\nlet items = { param: 'one', parent: { param: 'two', parent: { param: 'three' } } };\nWb.bubble(items, parent => console.log(parent.param)); //output: one, two, three\nWb.bubble(childNode, parent => console.log(parent), 'parentNode'); //Traverses all parent nodes of an element\nlet object = { param: 'two', parent: { param: 'three' } };\nlet items = { param: 'one', parent: object };\nWb.up(items, parent => parent.param === 'two'); //Up traverses the object and find the first item\nWb.upAll(items, fn); //Up traverses the object and find all items\n\n//Exception handling\ntry {\n doSomething();\n Wb.raise('error message'); //throw and Error\n} catch (e) {\n processException();\n throw e;\n} finally {\n finallyMethod();\n}\n\n//Value comparison\nWb.compare(a, b); //Intl.Collator().compare\nWb.lowerCompare(a, b); //to lowercase compare\nWb.mixCompare(a, b); //Mixed values compare, supports local comparison of UTF characters.\n\n//Value formatting\nval = Wb.format(1234, '#,##0.00'); //Format a number, output: \"1,234.00\"\nval = Wb.format('Your name is {name}', { name: 'Jeena' }); //Format a string, output: \"Your name is Jeena\"\nval = Wb.format('foo {0} bar {1} and {0}', 'abc', 123); //Format a string, output: \"foo abc bar 123 and abc\"\nval = Wb.format(new Date('2021-3-10'), 'y-MM-dd'); //Format a date, output: \"2021-03-10\"",
"wrapBorder": "0",
"readonly": "true"
}
}
]
}
# example/coding/js/date.xwl
Title: date
```json
{
"title": "",
"icon": "",
"img": "",
"tags": "",
"hideInMenu": "false",
"text": "module",
"cls": "Wb.Module",
"properties": {
"cid": "module"
},
"_icon": "module",
"_expanded": true,
"items": [
{
"_icon": "edit",
"text": "codeEditor1",
"cls": "Wb.CodeEditor",
"_expanded": true,
"properties": {
"cid": "codeEditor1",
"full": "true",
"value": "//This example demonstrates date. Only extended members are demonstrated, and native members are described at:\n//https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date\n\nlet date1 = new Date(), date2 = date1.addDay(3), date3 = date1.addDay(10);\n\n//Date add/subtract\ndate1.addMilliSec(3); //add milliseconds\ndate1.addMilliSec(-3); //Subtract milliseconds\ndate1.addSecond(3); //add seconds\ndate1.addMinute(3); //add minutes\ndate1.addHour(3); //add hours\ndate1.addDay(3); //add days\ndate1.addMonth(3); //add months\ndate1.addYear(3); //add years\n\n//Prototype functions\ndate1.equals(date2); //Determines whether the current date is equal to the specified date.\ndate1.equalsDate(date2); //Determines whether the current date is equal to the specified date, only compare date part.\ndate1.equalsMonth(date2); //Determines whether the current date is equal to the specified date, only compare year and month.\ndate2.between(date1, date3); //Determines whether the current date is between the specified start and end date.\ndate2.elapse(date1); //Gets the number of milliseconds from the current date to the specified date\n\n//Formatting\n//output like: \"2023-03-02 10:24:03.672\"\ndate1.format('y-MM-dd HH:mm:ss.S');\n//to date value in text, region independent.\ndate1.textValue;\n//equals to textValue property\ndate1.toString();\n//to local date text in 4-digit year and 2-digit month days, in some regions output: \"2021/03/09\"\ndate1.dateText;\n//to local time text in 24-hour 2-digit hours, minutes, and seconds, in some regions output: \"15:03:23\"\ndate1.timeText;\n//to local time text in 12-hour 2-digit hours, minutes, and seconds, in some regions output: \"PM 02:15:29\"\ndate1.timeText12;\n//to local date time text in 4-digit year and 2-digit month days, 24-hour 2-digit hours, minutes, and seconds,\n//in some regions output: \"2021/03/09 15:01:10\"\ndate1.dateTimeText;\n//to local date time text in 4-digit year and 2-digit month days, 14-hour 2-digit hours, minutes, and seconds,\n//in some regions output: \"2022/10/06 PM 02:17:06\"\ndate1.dateTimeText12;\n//similar to the dateTimeText property. If hours, minutes, seconds are 0, only the date part is displayed.\ndate1.autoText;\n//similar to the dateTimeText property, with 3-digit millisecond, in some regions output: \"2021/03/09 15:01:10.120\"\ndate1.dateTimeMilliText;\n//similar to the dateTimeText12 property, with 3-digit millisecond, in some regions output: \"2021/03/09 PM 02:17:06.120\"\ndate1.dateTimeMilliText12;\n\n//Getter properties\ndate1.isLeapYear; //Determines whether it is a leap year\ndate1.monthFirstDate; //Return the date of the first day of the month\ndate1.monthLastDate; //Return the date of the last day of the month\ndate1.monthDays; //Return the number of days in the month\ndate1.mondayDate; //Return the date value of the Monday of the week. Monday as the first day of the week.\ndate1.sundayDate; //Return the date value of the Sunday of the week. Sunday as the first day of the week.\ndate1.datePart; //Return the date part, the time part is set to 0.\ndate1.timePart; //Return the time part, the date part is set to \"1900-01-01\".",
"wrapBorder": "0",
"readonly": "true"
}
}
]
}
# example/coding/js/map.xwl
Title: map
```json
{
"title": "",
"icon": "",
"img": "",
"tags": "",
"hideInMenu": "false",
"text": "module",
"cls": "Wb.Module",
"properties": {
"cid": "module"
},
"_icon": "module",
"_expanded": true,
"items": [
{
"_icon": "edit",
"text": "codeEditor1",
"cls": "Wb.CodeEditor",
"_expanded": true,
"properties": {
"cid": "codeEditor1",
"full": "true",
"value": "//This example demonstrates map. Only extended members are demonstrated, and native members are described at:\n//https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map\n\n//Add, delete and modify\nlet map = new Map([['key1', 'Allen'], ['key2', 'Linda']]);\nmap.set('key', 'value'); //Add or modify\nmap.remove('key'); //Delete\n\n//Traverse\nmap.forEach((v, k, map) => console.log(v));\nmap.each((k, v) => { console.log(k, v) }); //each is similar to foreach, each can be interrupted\nmap.some((k, v) => v === 'Linda'); //Like Array.some\nmap.every((k, v) => v.includes('e')); //Like Array.every\nmap.find(k => k == 'key2'); //Like Array.find\nmap.filter((k, v) => v.includes('e')); //Like Array.filter",
"wrapBorder": "0",
"readonly": "true"
}
}
]
}
# example/coding/js/number.xwl
Title: number
```json
{
"title": "",
"icon": "",
"img": "",
"tags": "",
"hideInMenu": "false",
"text": "module",
"cls": "Wb.Module",
"properties": {
"cid": "module"
},
"_icon": "module",
"_expanded": true,
"items": [
{
"_icon": "edit",
"text": "codeEditor1",
"cls": "Wb.CodeEditor",
"_expanded": true,
"properties": {
"cid": "codeEditor1",
"full": "true",
"value": "//This example demonstrates number. Only extended members are demonstrated, and native members are described at:\n//https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number\n\n//General usage\n(92).snap(5); //Converts to the value closest to the specified step, output: 90\n(56).constrain(80, 90); //limit value >= minValue and value <= maxValue, output: 80\n\n//Formatting\n(12345.625).format('$#,##0.00'); //\"$12,345.63\"\n(12345.625).format('0.0###'); //\"12345.625\"\n(1.23).format('000'); //\"001\"\n(1.235).format('0.00%'); //\"1.24%\"\n(1234.5678).text; //to local text, in some regions output: \"1,234.568\"\n(1234.5678).intText; //to local integer text, in some regions output: \"1,235\"\n(1.2).floatText; //to local float text, in some regions output: \"1.2\"\n(1.2).percent; //to local percent text(2 decimal places), in some regions output: \"120.00%\"\n(1.2).percentInt; //to local percent text(no decimals), in some regions output: \"120%\"\n(1.2).percentAuto; //to local percent text(Keep up to 2 decimal places), in some regions output: \"120%\"\n\n//Currency\n(1234.5).usd; //to local USD currency text, in some regions output: \"US$1,234.50\"\n(1234.5).cny; //to local RMB currency text, in some regions output: \"¥1,234.50\"\n(1234.5).eur; //to local Euro currency text, in some regions output: \"€1,234.50\"\n(1234.5).gbp; //to local GBP currency text, in some regions output: \"£1,234.50\"\n(1234.5).jpy; //to local Yen currency text, in some regions output: \"JP¥1,235\"\n(1234.5).cad; //to local Cad currency text, in some regions output: \"CA$1,234.50\"\n(1234.5).aud; //to local Australian dollars currency text, in some regions output: \"AU$1,234.50\"\n(1234.5).hkd; //to local Hong Kong dollars currency text, in some regions output: \"HK$1,234.50\"\n\n//Byte size\n(12345678).kb; //to local KB size text, in some regions output: \"12,056 KB\"\n(12345678912).mb; //to local MB size text, in some regions output: \"11,774 MB\"\n(12345678912).fileSize; //to local MB/KB/B size text, in some regions output: \"11,774 MB\"\n\n//Getter properties\n(123.45).decimalCount; //Decimal place count",
"wrapBorder": "0",
"readonly": "true"
}
}
]
}
# example/coding/js/string.xwl
Title: string
```json
{
"title": "",
"icon": "",
"img": "",
"tags": "",
"hideInMenu": "false",
"text": "module",
"cls": "Wb.Module",
"properties": {
"cid": "module"
},
"_icon": "module",
"_expanded": true,
"items": [
{
"_icon": "edit",
"text": "codeEditor1",
"cls": "Wb.CodeEditor",
"_expanded": true,
"properties": {
"cid": "codeEditor1",
"full": "true",
"value": "//This example demonstrates string. Only extended members are demonstrated, and native members are described at:\n//https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String\n\n//General usage\n'my name is'.contains('name'); //Whether to contain \"name\", alias for String.includes\n'foo bar foo'.occur('foo'); //Gets the number of occurrences of the specified string\n'my name is: _$name$_'.replaceParams({ name: 'Allen' }); //Replaces the text using the _$name$_ syntax\n'
'.toHTML(true, true); //To HTML\n'abc, def, ghi'.splitTrim(); //Split the string and trim each item.\n\n//Formatting\n'foo {0} bar {1} and {0}'.format('abc', 123);\n'foo {value1} bar {value2}'.format({ value1: 'abc', value2: 123 });\n'23508172639'.formatGroup('???? ???? ???'); //Group formatting, output: \"2350 8172 639\"\n'abc def'.formatGroup('??-?? ?? ??'); //Group formatting, output: \"ab-cd ef\"\n'abc def'.formatGroup('?? ??'); //Group formatting, output: \"ab cd\"\n\n//Get the substring\n'foo.bar.abc'.firstItem('.'); //Gets the substring before the first specified string, output: \"foo\"\n'foo.bar.abc'.lastItem('.'); //Gets the substring after the last specified string, output: \"abc\"\n'foo.bar.abc'.beforeItem('.'); //Gets the substring before the last specified string, output: \"foo.bar\"\n'foo.bar.abc'.afterItem('.'); //Gets the substring after the first specified string, output: \"bar.abc\"\n'abc (foo) def'.getPart('(', ')'); //Gets the string between two strings, output: \"foo\"\n\n//Getter properties\n'allen'.capital; //Convert the first char to an uppercase char, output: \"Allen\"\n'
'.htmlText; //to HTML text, output: \"<div>\"\n'
\\n'.htmlLine; //to single line HTML text\n'2021-03-12 14:19:39.614'.dateValue; //to date value with format \"y-MM-dd HH:mm:ss.SSS\"",
"wrapBorder": "0",
"readonly": "true"
}
}
]
}
# example/coding/server-js/call-python.xwl
Title: call-python
```json
{
"title": "",
"icon": "",
"img": "",
"tags": "",
"hideInMenu": "true",
"text": "module",
"cls": "Wb.Module",
"properties": {
"cid": "module",
"serverScript": "// Please deploy Python related jars before using these feature: https://www.geejing.com/site/python/graal.zip\n// eg: copy these jars to \"apache-tomcat/graal\" folder\n// call demo.py to get the text content of wb/system/config.json\n// pyArray = Polyglot.eval('python', '[1,2,42,4]'); // Call Python code directly\nlet result = Polyglot.evalFile('python', 'wb/modules/example/coding/server-js/demo.py');\nWb.send(result);"
},
"_icon": "module"
}
# example/coding/server-js/common-usage.xwl
Title: common-usage
```json
{
"title": "",
"icon": "",
"img": "",
"tags": "",
"hideInMenu": "false",
"text": "module",
"cls": "Wb.Module",
"properties": {
"cid": "module"
},
"_icon": "module",
"_expanded": true,
"items": [
{
"_icon": "edit",
"text": "codeEditor1",
"cls": "Wb.CodeEditor",
"_expanded": true,
"properties": {
"cid": "codeEditor1",
"full": "true",
"value": "//This example demonstrates the general usage of server JavaScript programming and other language programming\n//For more resources, please visit: https://developer.mozilla.org/en-US/docs/Web/JavaScript\n\n//Acess Java classes\n//Access arbitrary Java classes starting with the \"Packages\" keyword. Not recommended.\nlet file = new Packages.java.io.File('/path');\n//Package name starts with \"com\", \"java\", \"org\", etc. can omit the \"Packages\" keyword. Not recommended.\nlet ArrayList = new java.util.ArrayList();\n//Using \"Java.type\" to get classes has higher performance and applicability. Recommended.\nlet HashMap = Java.type('java.util.HashMap');\n//Create a HashMap object, some classes like HashMap/FileUtil/IOUtils are predefined and ready to use.\nlet map = new HashMap();\n\n//Java objects to JS objects. Usually Java objects can be used directly in JS without conversion,\n//and the system will automatically convert to the corresponding type.\nstrArrType = Java.type(\"java.lang.String[]\"); //Defines the String[] type\njavaArr = new strArrType(3); //Create an array of length 3\njsArray = Java.from(javaArr); //Java array to JS array\n\n//Js objects to Java objects. Usually the system automatically converts JS objects when they are passed to Java,\n//and in some cases the conversion can be specified in the following ways:\njsArr1 = [\"a\", \"b\", \"c\"]; //Define the JS array\nstrArrType1 = Java.type(\"java.lang.String[]\"); //Define String[]\njavaArr1 = Java.to(jsArr1, strArrType1); //JS array to Java array\n\n//Java-related functions\njsJavaObj = Java.isJavaObject(123); //Determines whether it is a Java object\nisCls = Java.isType(HashMap); //Determines whether it is a Java Type\ntypeName = Java.typeName(HashMap); //Gets the class name, return: java.util.HashMap\n\n//Call overloaded Java methods\nSystem.out.println(123); //Automatically adapt parameter types\nSystem.out['println(boolean)'](true); //Explicitly specify function with Boolean parameter\nSystem.out['println(char[])']([1, 2]); //Explicitly specify function with char[] parameter\nSystem.out['println(java.lang.String)']('foo'); //Explicitly specify function with String parameter\n\n//Access to Java array/list\nObjectArray = Java.type('java.lang.Object[]');\nobjArray = new ObjectArray(3); //Create an array of length 3\nobjArray[0] = 1;\nobjArray[1] = 'abc';\nobjArray[2] = new JavaDate();\nobjArray.forEach(item => Wb.log(item)); //Iterate through the array\nobjArray.each(item => {\n Wb.log(item);\n if (item == 1)\n return false; //Break iteration\n});\nobjArray.sort(); //call native sort function\nobjArray.mixSort(); //call mixSort function, see WebBuilder docs.\n\n//Access to Java Map\nmap = new HashMap();\nmap.put('abc', 123);\nmap.put('foo', 'bar');\nabc = map.abc; //123\nmap.forEach((k, v) => Wb.log(k + '=' + v)); //Traverse the Map\nmap.each((k, v) => {\n Wb.log(k + '=' + v);\n if (k == 'abc')\n return false; //Break iteration\n});\n\n//Java String\njavaString = new (Java.type('java.lang.String'))(\"Java\");\njavaString.length === 4; //length is a property, and Java string are treatable as JS string\nbytes = javaString.getBytes('utf-8'); //Call the extended getBytes function to get the utf8 bytes of string\n\n//Java date, usually when calling the Java method, the system will automatically convert the JS date to Java date.\nDateUtil.format(new Date(), 'yyyy'); //The system automatically converts JS dates to Java dates\nnew JavaDate(new Date().getTime()); //Explicitly convert JS dates to Java dates, JavaDate is java.util.Date\n\n//Access JS objects from Java\nmap = { foo: 'bar', abc: 123 };\nJavaClass.javaMethod(map); //The map parameter implements the Map interface in Java, map.get(\"foo\") to get \"bar\"\n\n//JS Object/Array to Java org.json.JSONObject/org.json.JSONArray\njsonObject = Wb.toJava(jsObject); //Use api Wb.toJava to convert to JSONObject\njsonArray = Wb.toJava(jsArray); //Use api Wb.toJava to convert to JSONArray\njsonObject = new JSONObject(Wb.encode(jsObject)); //Convert jsObject to a string and then convert it to JSONObject\njsonArray = new JSONArray(Wb.encode(jsArray)); //Convert jsArray to a string and then convert it to JSONArray\njsonObject = new JSONObject({ foo: 'bar', abc: 123, date: new Date() });//Efficient way, js Object to JSONObject. Please note that \"new Date()\" will return \"{}\"(a JSONObject), because it is a Map in Java.\njsonArray = new JSONArray(Java.to(['abc', 123, new Date()]));//Efficient way, js Array to JSONArray. Please note that \"new Date()\" will return \"{}\"(a JSONObject), because it is a Map in Java.\n\n//Java org.json.JSONObject/org.json.JSONArray to JS Object/Array\njsObject = Wb.toJs(jsonObject); //Use api Wb.toJs to convert to Object\njsArray = Wb.toJs(jsonArray); //Use api Wb.toJs to convert to Array\narray = Wb.decode(jsonArray.toString());\nobject = Wb.decode(jsonObject.toString());\narray = Wb.getProxy(jsonArray); //Access JSONArray via proxy, when jsonArray is large, this method is efficient.\nobject = Wb.getProxy(jsonObject); //Access JSONObject via proxy, when jsonObject is large, this method is efficient.\n\n//app is a global visible object in execution-context, created at start and deleted at end\napp.myVar = 'abc'; //Add myVar to the app\nWb.run('my/file1.xwl'); //\"app.myVar\" is visible in file1.xwl\n\n//Regular traversal\narray.forEach(item => Wb.log(item));\n//Interruptible traversal\narray.each(item => {\n Wb.log(item);\n if (item == 'foo')\n return false; //Break iteration\n});\n//Suggest changing to [array.each(item => {item.method()})], avoid unexpected interruptions caused by return false\narray.each(item => item.method());\n//Traverse the object, return false to interrupt the traversal\nWb.each(object, (k, v) => {\n console.log(k, v);\n});\n//Iterate Java members\nm = Java.type('java.lang.Math')\nfor (i in m) { print(i); }\n\n//Java class extends\nJavaExt = Java.extend(Java.type(\"some.AbstractClass\"), Java.type(\"some.Interface1\"));\nimpl = new JavaExt({\n superclassMethod: function () { },\n interfaceMethod: function () { },\n toString() { return \"MyClass\"; }\n});\nimpl.superclassMethod();\nsw = new (Java.type(\"java.io.StringWriter\"));\nFilterWriterAdapter = Java.extend(Java.type(\"java.io.FilterWriter\"));\nfw = new FilterWriterAdapter(sw, {\n write: function (s, off, len) {\n }\n});\nfw_super = Java.super(fw); //call super\nfw.write(\"abc\");\n\n//Java classes variables\nnew HashMap();//HashMap is java.util.HashMap\nnew JavaDate(); //JavaDate is java.util.Date\nIOUtils.copy(source, dst); //IOUtils is org.apache.commons.io.IOUtils\n\n//Run ServerScript in Java\nresult = com.wb.graal.Executor.run(\"let a=123;return Wb.run('my/file.xwl');\"); // Run any script\nresult = com.wb.graal.Executor.execute(\"Wb.sql\", \"select * from wb_user\"); // Run Wb.sql function and get result\nresult = com.wb.graal.Executor.execute(\"Wb.loadCall\", \"wb/ss/myModule.mjs\", \"myExportFunc\", \"param1\", \"param2\"); // Call exposed function in a specified module\n\n//High frequency call JS function in Java code\nfn = new com.wb.graal.JSFunc(\"Wb.encode\");\n// fn = new com.wb.graal.JSFunc(\"Wb.encode\", request, response); // share request and response. This way, parameters can be shared\ntry {\n for (i = 0; i < 1000; i++)\n fn.execute(i);\n} finally {\n fn.close();\n}\n\n//Call other programming languages directly\n//When using other languages, please install the corresponding language first,\n//and the installation method is to run it in the bin directory of the JDK:\n//gu install python //Install python\n//gu install R //Install R\npyArray = Polyglot.eval('python', '[1,2,42,4]'); //Call Python code directly\nrArray = Polyglot.eval('R', 'runif(1000)'); //Call R code directly\nrFunc = Polyglot.evalFile('R', 'myExample.r'); //call R file\nrResult = rFunc(); //Call R function",
"wrapBorder": "0",
"readonly": "true"
}
}
]
}
# example/coding/server-js/database-access.xwl
Title: database-access
```json
{
"title": "",
"icon": "",
"img": "",
"tags": "",
"hideInMenu": "false",
"text": "module",
"cls": "Wb.Module",
"properties": {
"cid": "module"
},
"_icon": "module",
"_expanded": true,
"items": [
{
"_icon": "edit",
"text": "codeEditor1",
"cls": "Wb.CodeEditor",
"_expanded": true,
"properties": {
"cid": "codeEditor1",
"full": "true",
"value": "//Access database by JDBC\nlet conn, statement, resultSet;\n\ntry {\n conn = DataSource.getConnection('wb-sqlserver');\n statement = conn.prepareStatement('select user_name from wb_user where sid=?');\n statement.setString(1, 'admin');\n resultSet = statement.executeQuery();\n while (resultSet.next()) {\n Wb.log(resultSet.getString(1));\n }\n} finally {\n //Note that the closing order is resultSet, statement, conn\n //SysUtil.close performs the close without throwing any exception\n SysUtil.close(resultSet);\n SysUtil.close(statement);\n SysUtil.close(conn);\n}\n\n//Gets the default encapsulated db connection, which is automatically closed after the execution-context is completed\n//regardless of whether an exception occurs\nconn = Wb.getConn(); //Gets a shared connection of the default database\nconn = Wb.getConn('wb-sqlserver'); //Gets the shared connection with the specified name\nconn = new Wb.Connection('wb-sqlserver'); //Create a new stand-alone connection\nconn.startTrans(); //Start transaction\nconn.startTrans('serializable'); //Start transaction with the specific isolation level\nconn.commit(); //Commit transaction\nconn.rollback(); //Rollback transaction\n\n//Run arbitrary SQL by Wb.Query and immediately release all resources except the db shared connection,\n//which is automatically closed after the execution-context is completed. See Wb.Query.run docs.\n//Result is an object composed of all results returned by SQL, including any number of return values and output parameters\nresult = Wb.sql('select * from wb_user where sid={?param1?}');\ncount = Wb.sql('delete from table1 where 1 = 0', 'wb-oracle'); //\"wb-oracle\" is the database name\nWb.sql({ sql: 'select * from table1', db: 'wb-oracle', fn(row) { process(row); } });\n//Access stored procedure, {?inParam?} is the input parameter and {*outParam*} is the output parameter\nWb.sql('{call sp({?timestamp|inParam?}, {*cursor|p1*}, {*double|3|p2*})}');\n//Perform a batch operation to insert records\nWb.sql({\n sql: 'insert into test (sid, varchar_field) values({?sid?}, {?varchar_field?})',\n params: [{ sid: 'foo', varchar_field: 'bar' }, { sid: 'abc', varchar_field: 'def' }]\n});\n//Set fn to traverse all records, and specify fn to traverse all records by default\nWb.sql({\n sql: 'select * from wb_perm', fn(item, name, index) {\n if (index > 10)\n return false; //Break traversal\n Wb.log(item)\n }\n});\n\n//Gets the first result set returned by SQL\nrows = Wb.getRows('select * from wb_user'); //Gets rows in object format\nWb.table(rows); //Display the data as a table in the IDE devtools console\nrows = Wb.getAllRows('select * from wb_user'); //Gets all rows in object format, recommend using fn parameter\nrecs = Wb.getRecords('select * from wb_user'); //Gets records in array format\nWb.table(recs);\nrecs = Wb.getAllRecords('select * from wb_user'); //Gets all records in array format, recommend using fn parameter\nWb.getRows('select * from wb_user', 'wb-oracle'); //Access the specific database\nWb.getRecords({ sql: 'select * from wb_user', db: 'wb-oracle', blob: 'text' }); //Use object as parameter configurations\n\nrow = Wb.getRow('select * from wb_user'); //Gets the first row int object format\nrec = Wb.getRecord('select * from wb_user'); //Gets the first record int array format\n\n//Gets object that includes columns metadata, rows and others, rows in object format\nrows = Wb.getRowx('select * from wb_user');\n//Gets object that includes columns metadata, records and others, records in array format\nrecs = Wb.getRecordx('select * from wb_user');\nrows = Wb.getDict('select * from wb_user'); //Gets the dictionaryized object by Wb.getRowx\nrecs = Wb.getDictRecords('select * from wb_user'); //Gets the dictionaryized object by Wb.getRecordx\n\nrs = Wb.sqlRS('select * from wb_user').resultSet; //Run SQL to get the ResultSet\nrows = Wb.sqlAll('select * from test'); //Gets rows for all values including blob values\nrows = Wb.Query.getRows(resultSet, configs); //Gets rows in object format by ResultSet\nrecords = Wb.Query.getRecords(resultSet, configs); //Gets records in array format by ResultSet\n\nWb.sendRows('select * from wb_user'); //Send the results generated by Wb.getRows\nWb.sendRow('select * from wb_user'); //Send the results generated by Wb.getRow\nWb.sendRecords('select * from wb_user'); //Send the results generated by Wb.getRecords\nWb.sendRecord('select * from wb_user'); //Send the results generated by Wb.getRecord\nWb.sendRowx('select * from wb_user'); //Send the results generated by Wb.getRowx\nWb.sendRecordx('select * from wb_user'); //Send the results generated by Wb.getRecordx\nWb.sendDict('select * from wb_user'); //Send the results generated by Wb.getDict\nWb.sendDictRecords('select * from wb_user'); //Send the results generated by Wb.getDictRecords\n\n//Use JS string template to define large SQL\nsql = `\n select user_name as Name from wb_user\n where sid='admin'\n`;\n\n//Access stored procedures\n\n//Create the following stored procedure in SQL Server:\nWb.sql(`\n create procedure test_proc\n (\n @inParam int, -- in param\n @outParam int out -- in and out param\n )\n as\n begin\n set @outParam=@inParam+2 --Returns the output parameters\n select * from wb_user --Returns ResultSet 1\n delete from wb_key where 1=0 --Returns the affected rows\n select * from wb_role --Returns ResultSet 2\n return 123 --returned value\n end\n`, 'wb-sqlserver');\n\n//Call the above test_proc procedure and get a total of 5 results:\n//including outParam, returned value, 2 ResultSets, and 1 affected row\n//Run the stored procedure using Wb.sql, {*type|name*} represents output parameter, {?type|name?} represents input parameter\n//You can also run the following SQL in [Management Tools]->[Database Explorer]:\n// {{*returnValue*}=call test_proc(3,{*outParam*})}\n//to get the return 5 results\nWb.set({ myInParam: 3 }); //Set the input parameter value\nlet result = Wb.sql('{{*returnValue*}=call test_proc({?myInParam?},{*outParam*})}', 'wb-sqlserver'); //Run sql\nWb.log(result); //Display the results in the IDE devtools console\nWb.log(result.$return[0]); //Get the first ResultSet\nWb.log(result.outParam); //Get outParam\n\n//Create the following stored procedure in Oracle:\nWb.sql(`\n CREATE OR REPLACE NONEDITIONABLE PROCEDURE USER_PROC\n (\n P_USER OUT TYPES.X_CURSOR,\n P_NAME IN VARCHAR\n )\n AS\n BEGIN\n OPEN P_USER FOR SELECT * FROM WB_USER WHERE USER_NAME = P_NAME;\n END USER_PROC;\n`, 'wb-oracle');\n//Send the first ResultSet output parameter p_user to the client\n//The \"cursor\" in {*cursor|p_user*} explicitly indicates that the output type of p_user is cursor\nWb.sendRows(`{call user_proc({*cursor|p_user*}, 'admin')}`, 'wb-oracle');\n\n//select, insert, delete, update, and synchronize\n//Insert, delete, or update the specified data to my_table in a transaction.\n//Field names starts with \"$\" are represented as old values, and field names starts without \"$\" represent new values.\nWb.sync({\n tableName: 'my_table',\n insert: [{ field1: 'ab', field2: 12 }, { field1: 'cd', field2: 34 }],\n update: [{ field1: 'newValue', $field1: 'oldValue' }],\n del: [{ $field1: 'xyz' }]\n});\n//Specify whereFields\nWb.sync({\n tableName: 'my_table',\n update: [{ field1: 'newValue', $field1: 'oldValue', $field2: 'abc' }],\n //Explicitly specify field1 and field2 as the where key fields, otherwise the system will automatically get the key fields\n whereFields: 'field1, field2'\n});\n//Perform a conditional select\nWb.sync({\n tableName: 'wb_user',\n fields: 'sid, user_name',\n select: { $sid: 'admin' }\n});\n//Downloads the specified BLOB field as a file\nWb.sync({\n tableName: 'wb_resource',\n download: { _meta: { fieldName: 'svalue', filename: 'desktop.json' }, $sid: 'admin@desktop' }\n});",
"wrapBorder": "0",
"readonly": "true"
}
}
]
}
# example/coding/server-js/devtools-debug.xwl
Title: devtools-debug
```json
{
"title": "",
"icon": "",
"img": "",
"tags": "",
"hideInMenu": "false",
"text": "module",
"cls": "Wb.Module",
"properties": {
"cid": "module"
},
"_icon": "module",
"_expanded": true,
"items": [
{
"_icon": "viewport",
"text": "viewport1",
"cls": "Wb.Viewport",
"properties": {
"cid": "viewport1",
"html": "
\n
This example demonstrates how to remotely debug server-side code using the browser \"devtools\":
\n \n
Add the module file \"test.xwl\" and write arbitrary code in the serverScript property, such as \"Wb.log('test')\".\n
\n
Select the \"test.xwl\" module and click IDE menu [Run] ->[Toggle Debugging Status].
\n
Click the IDE menu [Run] -> [Run] to run \"test.xwl\".
\n
Click the \"Debugging\" tab card at the bottom of the IDE, and double-click the \"test1.xwl\" debugging item to open\n new window.
\n
Click the address bar in the new window, press \"Ctrl+V\" to paste the debugging address, and press Enter to open\n the \"devtools\" debugging page.
\n
After adding the keyword \"debugger\" anywhere in the script, the code will pause and wait for debugging there.\n
\n
The debugging URL is the same in the same session and the same module, debugging multiple times only requires\n refreshing the \"devtools\" debugging page after running the module.
\n
When debugging remotely, due to security reasons, the browser may block access to the debugging page and prompt\n that the page was not found. In this case, you can press [F12] key to open \"devtools\" and then press Enter key in\n the browser address bar.