PropertyEventMethodIndex
$w - 5.0_1.3015A.20180410.143527

Provides utilities frequently used in WebSquare5.
PIs are contained in a package that belongs to a WebSquare5 object. For developer's convenience, however, APIs are also individually provided

Type

engine

Property Summary

Event Summary

Method Summary

ajax( options )
A communication module similar to submission, but provides more room for the developer to control.
clearInterval( keyName , force )
Clears an Interval object registered by WebSquare5.
clearPage( )
Refreshes the browser to the initial state (and reloads the WebSquare5 Engine and the resources.)
clearTimeout( key , force )
Clears the functions registered by setTimer of WebSquare5 after time-out.
closePopup( id )
Closes the popup based on the ID allocated by openPopup or createPopup.
createSubmission( submissionObj )
Dynamically creates a submission.
dateAdd( day1 , offset )
Adds as many days as defined to the date. (date + offset)
dateDiff( startDate , endDate )
Returns the difference between the two dates. ( to - from )
download( actionUrl , XML , sendMethod )
Provides interfaces to call the URL in which a download module exists and to download a file.
executeParallel( submission , processMsg , finalCallback , rejectCallback , id )
Executes the submissions in parallel without creating a workflow.
executeSerial( submission , processMsg , finalCallback , rejectCallback , id )
Executes the submissions in serial without creating a workflow.
executeSubmission( submissionID , requestData , obj )
Executes the submission of the corresponding ID.
executeWhilst( submissionId , condFn , maxRepeat , processMsg , resolveCallback , rejectCallback , id )
Repeatedly calls a certain submission without creating a workflow.
executeWorkflow( workflowId )
Executes the workflow of the received workflowId or workflowObj.
getAllBASE64Parameter( )
Decodes all Base64-encoded get-type parameters, and returns the result in JSON format.
getAllParameter( )
Returns all get-type parameters in JSON format.
getBASE64Parameter( param )
Decodes a Base64-encoded get-type parameter, and returns the result.
getCurrentServerDate( pattern )
Gets the present time of the WAS.
getFormattedDate( dateObj , pattern )
Receives a JavaScript Date object and returns it in the specified format.
getIntervalKeyList( )
Returns all keys registered by setInterval as an array.
getMaxMinYear( )
Returns maxYear and minYear in the config file in JSON format.
getParameter( param )
Returns get type parameters or data defined in dataObject of openPopup method.
getParentFrame( )
Returns the WFrame object when called by the script of the WFrame.
getParentId( )
Returns the WFrame ID when called by the scirpt of the WFrame.
getPopupId( )
Gets the ID of the popup.
getPopupParam( )
Returns dataObject parameters or XML parameters as a string to create a popup using openPopup.
getPopupUrl( )
Gets the current URL of the popup window.
getPopupWindow( id )
Searches by ID defined in openPopup and returns the window of the searched popup.
getRunningWorkflow( workflowID )
Returns the object of the currently running first workflow.
getRunningWorkflowID( )
Returns the ID of the currently running workflow.
getRuntimeId( )
Returns the actual ID of the component by receiving the component ID (in the page).
getStringByteSize( str )
Returns the byte size of the given string.
getSubmission( submissionID )
Returns the submission object of the corresponding submissionID.
getTimeoutKeyList( )
Returns all registered keys of setTimeout API as an array.
getWorkflow( id )
Gets the workflow object of the corresponding ID.
hideModal( )
Hides the modal layer of WebSquare5.
isPopup( )
Checks whether the present window is a pop-up.
isRunningWorkflow( workflowID )
Check whether there is a currently running workflow.
isWframePopup( )
Checks whether the current page is a WFrame popup.
js( scriptUrl , callback )
Controls the sequence of loading multiple external scripts.
log( msg )
Displays logs on through the Log menu of the browser or in the developer mode of the browser.
openPopup( url , options , params , target )
Creates a popup according to the specified properties.
parseDate( dateStr , format )
Converts the date-format data into Date.
reinitialize( browserRefresh )
Reloads the page without refreshing the browser, or refreshes the browser.
rejectWorkflow( reject , workflowID )
Rejects the currently running workflow.
setDisabled( obj )
Disables the belongings of the specified component.
setDocumentLang( lang )
Sets the language code in the HTML tag.
setDomain( domain )
Sets document.domain property.
setInterval( func , options )
Regularly executes the function.
setTimeout( func , options )
Executes the specified function after a certain period of time.
showModal( popupComponents )
Shows the modal layer and sets (enables) the popup for the component.
toTimestampString( dateObj )
Returns the JavaScript Data object in the Timestamp format of Java SQL.
url( w2xPath , options )
ends only the WebSquare page (w2xPath) for page changing.
URLEncoder( str )
Converts the given character string into application/x-www-form-urlencoded MIME format.

Property Detail

Event Detail

Method Detail

ajax( options )
A communication module similar to submission, but provides more room for the developer to control.
Request/Response data type is string, and supports easy interface with JavaScript encryption/decryption modules.
Parameter
nametyperequireddescription
optionsJSONYJSON-type object
<String:Y> options.action : ajax request address <String:N> options.mode : [default: asynchronous,synchronous] <String:Y> options.mediatype : [default: application/xml, application/x-www-form-urlencoded, application/json, text/xml] <String:N> options.method : [default: POST, GET, PUT, DELETE] <String:N> options.requestData : Request text <JSON:N> options.requestHeader : JSON object to specify in the request header <Number:N> options.timeout : Timeout for AJAX request. In case no response arrives within the time-out, the error callback function will be executed. <String:N> options.type : [xml, json] In case of XML, XML objects are defined in responseBody. In case of JSON, a JavaScript object will be defined. In other cases, defined by the Text format. <Function:N> options.beforeAjax : Executed before the request. If "false" is returned by this function, AJAX request will not be made. <Function:N> options.success : A callback function executed upon a successful request. <Function:N> options.error : A callback function executed upon a failed request
Sample
var options = {}; options.action = "/test.jsp"; options.mode = "asynchronous"; options.mediatype = "text/json"; options.method = "POST"; options.requestData = '{ "name" : "WebSquare" , "addr" : "Seoul" }'; options.requestHeader = {insUserData:"w5Edu"}; options.success = doSucess; // Defined function object options.error = function( e ){ // The function is defined. //e.errorType - Fixed "target-error" is returned. //e.resourceUri - URI //e.responseHeaders - Response Headers //e.responseStatusCode - Response Status Code //e.responseReasonPhrase - Response Status Text //e.requestBody - Request Data in the string format //e.responseText - Original response data in string format // Status code alert display. alert("errorCode:"+e.responseStatusCode); }; $w.ajax( options ); // A callback function for options.success in the above example. function doSucess( e ){ // e is a JSON object to contain the communication result. //e.resourceUri - URI //e.responseHeaders - Response Headers //e.responseStatusCode - Response Status Code //e.responseReasonPhrase - Response Status Text //e.responseBody - Response data as an XML object.(If the response content type is JSON, the JSON object will be parsed in XML.) //e.responseText - Original response data in string format // Display the response as an alert. alert("success\n"+e.responseText); }
clearInterval( keyName , force )
Clears an Interval object registered by WebSquare5. ( $w.setInterval )
Parameter
nametyperequireddescription
keyNameStringYName of the key (registered in options by $w.setInterval)
forceBooleanNWhether to execute the function before clearing the Interval object of the corresponding keyName. The default is false.
Sample
// options.key is set as "timer1" by $w.setInterval. $w.clearInterval("timer1");
clearPage( )
Refreshes the browser to the initial state (and reloads the WebSquare5 Engine and the resources.)
Used by the onpageunload event when the browser needs to be initialized in the SPA mode.
Add onpageunload event and call this function in the components that have memory leak issue in the SPA mode such as Editor or Chart.
Same as calling $w.url(WebSquare.baseURI + "blank.xml", {spa:true, forceReload:true});.
Sample
<body> <script type="javascript" ev:event="onpageunload"><![CDATA[ $w.clearPage(); // Refreshes the browser and reloads WebSquare Engine and the resources. ]]></script> </body>
clearTimeout( key , force )
Clears the functions registered by setTimer of WebSquare5 after time-out. ( $w.setTimer )
Parameter
nametyperequireddescription
keyStringYoptions.key value set by $w.setTimer.
forceBooleanNWhether to execute the setTimer function or not. The default is false.
Sample
// options.key is "timer1" in $w.setTimer. $w.clearTimeout("timer1");
closePopup( id )
Closes the popup based on the ID allocated by openPopup or createPopup.
Parameter
nametyperequireddescription
idStringYPopup ID
Sample
$w.closePopup("popup1");
createSubmission( submissionObj )
Dynamically creates a submission.
Parameter
nametyperequireddescription
submissionObjJSONYSubmission object to register. The properties are as shown below.
<String:Y> submissionObj.id : ID of the submission object. Required to execute the communication module. <String:N> submissionObj.ref : Conditional expression of the DataCollection to send to the server (request.) Or, XPath of the instance data. <String:N> submissionObj.target : Conditional expression of the DataCollection to save the response from the server. Or, XPath of the instance data. <String:N> submissionObj.action : Server URI. (Due to browser security policies, cross-domain is not supported.) <String:N> submissionObj.method : [default: post, get, urlencoded-post] get: To add the parameter to the URL (same as in HTML.) post: To contain the parameter in the body section (same as in HTML.) urlencoded-post:urlencoded-post. <String:N> submissionObj.mediatype : [default: application/xml, text/xml, application/json, application/x-www-form-urlencoded] application/x-www-form-urlencoded : Web form (HTML). application/jso : JSON type. application/xml : XML type. text/xml : For the differences, see http://stackoverflow.com/questions/4832357.) <String:N> submissionObj.mode : [default: synchronous, synchronous] Communication method with the server.. asynchronous. synchronous. <String:N> submissionObj.encoding : [default: utf-8, euc-kr, utf-16] Encoding type on the server (euc-kr/utf-16/utf-8) <String:N> submissionObj.replace : [default: none, all, instance] Applying type of the response data received from the action. all : To replace the entire document with the response data. Instance : To replace only the applicable part. None : Do not replace. <String:N> submissionObj.processMsg : Message to display during the submission. <String:N> submissionObj.errorHandler : Function to execute upon a submission error. <String:N> submissionObj.customHandler : Function to execute upon a submission. <Function:N> submissionObj.submitHandler : Function for <script type="javascript" ev:event="xforms-submit"> <Function:N> submissionObj.submitDoneHandler : Function for <script type="javascript" ev:event="xforms-submit-done"> <Function:N> submissionObj.submitErrorHandler : Function for <script type="javascript" ev:event="xforms-submit-error">
Sample
var submissionObj = { "id" : "submission_dynamic0", "ref" : "data:json,dc_reqDataMap", "target" : "data:json,dc_resDataMap", "action" : "/data/sampleData.json", "method" : "post", "mediatype" : "application/json", "encoding" : "UTF-8", "mode" : "asynchronous", "processMsg" : "processing ~ ~ ~ ", "submitDoneHandler" : function(e) { alert(e.responseText); }, "submitErrorHandler" : function(e) { alert(e.responseStatusCode); } }; $w.createSubmission( submissionObj );
dateAdd( day1 , offset )
Adds as many days as defined to the date. (date + offse)
Parameter
nametyperequireddescription
day1StringYDate
offsetNumberYOffset to add to the date
Return
typedescription
StringThe offset-added/-deducted date
Sample
var tmpDate1 = $w.dateAdd( 20120102, 7 ); (Return Example) tmpDate1 : 20120109 var tmpDate2 = $w.dateAdd( 20140101, -7 ); (Return Example) tmpDate2 : 20131225
dateDiff( startDate , endDate )
Returns the difference between the two dates. ( to - from )
Parameter
nametyperequireddescription
startDateStringYStarting date
endDateStringYEnding date
Return
typedescription
NumberDifference between the two dates
Sample
var diff = $w.dateDiff( "20120120", "20120210" ); (Return Example) diff : 21
download( actionUrl , XML , sendMethod )
Provides interfaces to call the URL in which a download module exists and to download a file.
Parameter
nametyperequireddescription
actionUrlStringYURL with a file download feature
XMLStringNA character string xmlValue is sent to the server. If not specified, other values than xmlValue will be sent to the server.
sendMethodStringNTransmission method (get or post). The default is post.
Sample
var url = "/download.do" // Server URL with a file download. (Not provided for the basic module of WebSquare5.) $w.download( url );
executeParallel( submission , processMsg , finalCallback , rejectCallback , id )
Executes the submissions in parallel without creating a workflow.
submission1 call -> submission2 call -> submission1 callback -> submission2 callback
Parameter
nametyperequireddescription
submissionarrayYid array ex) ["submission1", "submission2", "submission3"]
processMsgStringN
finalCallbackfunctionNfunction
rejectCallbackfunctionNfunction
idStringN
Sample
$w.executeParallel( ["submission1", "submission2", "submission3"],processMsg, final_callback, reject_callback, id) ; submission1,submission2, submission3 call -> submission1 callback -> submission2 callback -> submission3 callback -> final_callback or reject_callback
executeSerial( submission , processMsg , finalCallback , rejectCallback , id )
Executes the submissions in serial without creating a workflow.
submission1 call -> submission1 callback -> submission2 call -> submission2 callback
Parameter
nametyperequireddescription
submissionarrayYid array ex) ["submission1", "submission2", "submission3"]
processMsgStringN
finalCallbackfunctionNfunction
rejectCallbackfunctionNfunction
idStringN
Sample
$w.executeSerial( ["submission1", "submission2", "submission3"], processMsg,final_callback, reject_callback) ; submission1 call/callback -> submission2 call/callback -> submission3 call/callback -> final_callback or reject_callback
executeSubmission( submissionID , requestData , obj )
Executes the specified submission.
Parameter
nametyperequireddescription
submissionIDStringYSubmission ID
requestDataObjectNRequested data
objObjectNComponent to disable during submission
Sample
$w.executeSubmission ("submission1") ; Execute submission1.
executeWhilst( submissionId , condFn , maxRepeat , processMsg , resolveCallback , rejectCallback , id )
Repeatedly calls a certain submission without creating a workflow.
Parameter
nametyperequireddescription
submissionIdStringYsubmission ID
condFnfunctionYExecution status-checking function
maxRepeatintYMaximum execution count. Can be used to control infinite loops when the workflow can be identified only by the condition.
processMsgStringN
resolveCallbackfunctionNfinalCallback function
rejectCallbackfunctionNrejectCallback function
idStringN
Sample
$w.executeWhilst( "submission1", cond_check, 100, processMsg,final_callback, reject_callback, id) ; Repeatedly calls (and calls back) the submission not more than 100 times when cond_check is success. -> final_callback or reject_callback
executeWorkflow( workflowId )
Executes the workflow of the received workflowId or workflowObj.
Parameter
nametyperequireddescription
workflowIdObjectYworkflow ID or workflowObj
Sample
$w.executeWorkflow ("workflow1") ; workflowCollection/Run the workflow of which ID is workflow1. Or var workflowObj= {"id":"workflow1", "processMsg" : "Running.. ", "service" : [{ "type":"submission", "id" : "submission1"}, { "type":"submission","condition": cond, "id" : "submission2"}, { "type":"submissionCallback", "id" : "submission1", "callback":post}, { "type":"submissionCallback", "id" : "submission2", "callback":post} ], "finalCallback" : final_callback, "rejectCallback": reject_callback }) ; $w.executeWorkflow (workflowObj) ; Run the workflow with the workflowObj object.
getAllBASE64Parameter( )
Decodes all Base64-encoded get-type parameters, and returns the result in JSON format.
Sample
$w.getAllBASE64Parameter();
getAllParameter( )
Returns all get-type parameters in JSON format.
Sample
var getParam = $w.getAllParameter();
getBASE64Parameter( param )
Decodes a Base64-encoded get-type parameter, and returns the result in JSON.
Parameter
nametyperequireddescription
paramStringNParameter specified in URI
Return
typedescription
StringParameter string
Sample
$w.getBASE64Parameter("name");
getCurrentServerDate( pattern )
Gets the present time of the WAS.
Receives the Java SimpleDateFormat pattern as an argument to display the time.
In case the pattern is not specified, the date will be displayed in yyyMMdd format.
Parameter
nametyperequireddescription
patternStringN[default:yyyyMMdd] Date format
Return
typedescription
StringServer date (and time) as a string
Sample
// y Year 1996; 96 //M Month in year 07 //d Day in month 10 //H Hour in day (0-23) 0 //m Minute in hour 30 //s Second in minute 55 //S Millisecond 978 var dateStr = $w.getCurrentServerDate(); //yyyyMMdd (Return Example) dateStr : 20111225 var dateStr = $w.getCurrentServerDate("yyyy-MM-dd HH:mm:ss"); (Return Example) dateStr : 2014-11-07 15:49:10:080
getFormattedDate( dateObj , pattern )
Receives a JavaScript Date object and returns it in the specified format.
If the pattern is not specified, the return will be same as those returned by Java System.currentTimeMillis.
Parameter
nametyperequireddescription
dateObjDateObjectYJavaScript Data object"
patternStringNDate and time display pattern
Return
typedescription
StringDate and time data in the specified format
Sample
// Date and Time Display //y Year 1996; 96 //M Month in year 07 //d Day in month 10 //H Hour in day (0-23) 0 //m Minute in hour 30 //s Second in minute 55 //S Millisecond 978 var dateObj = new Date(); var dateStr = $w.getFormattedDate ( dateObj, “MM.yyyy” ); (Return Example) dateStr : 11.2014
getIntervalKeyList( )
Returns all keys registered by setInterval as an array.
Return
typedescription
ArrayKey array registered by setInterval
Sample
var IntervalKeyList = $w.getIntervalKeyList(); for(var i = 0; i &lt; IntervalKeyList.length; i++) { $w.clearInterval(IntervalKeyList[i]); } // Clears all registered timers.
getMaxMinYear( )
Returns maxYear and minYear in the config file in JSON format.
Return
typedescription
JSONmaxYearand minYear in config.xml.
<Number> maxYear [default:2099] maxYear specified in config.xml. <Number> minYear [default:1901] minYear specified in config.xml.
Sample
maxYear and minYear in the config.xml are the default. <websquare> <date> <maxYear value="2099" /> <minYear value="1000" /> </date> </websquare> var maxMinYear = $w.getMaxMinYear(); // (Return Example) maxMinYear.maxYear : 2099 (yyyy) // (Return Example) maxMinYear.minYear : 1000 (yyyy)
getParameter( param )
Returns get type parameters or data defined in dataObject of openPopup method.
Encode get type parameters written in characters other than alphabets with WebSquare.Text.URLEncoder.
To disable URLEnclding of WebSquare5, set the following in the config file.
<net><websquareDecoder value="false" /><net>
Parameter
nametyperequireddescription
paramStringYParameter specified in the URI or the dataObject name defined in openPopup.
Return
typedescription
String|JSONCharacter string of the param definedin the URL If there is no parameter in dataObject of openPopup, "" will be returned.
Sample
//URL : http://localhost:8080/websquare/websquare.html?w2xPath=/test.xml&amp;&amp;userID=1234 var tmpUserID = $w.getParameter("userID"); // (Return Example) "1234" // Define dataObject of $w.openPopup as shown below. //dataObject : { type : "json", data : {name:"WebSquare",addr:"Seoul"}, name : "rowObj" } var popRowObj = $w.getParameter("rowObj"); // (Return Example) {name:"WebSquare",addr:"Seoul"} //type : JSON Object
getParentFrame( )
Returns the WFrame object of the parent when called by the script in the WFrame. Returns null when called by a global script.
Return
typedescription
ObjectWFrame object
Sample
// When writeen in main.xml <w2:wframe id='wframe1' src='sub.xml'/> scwin.$w.getParentFrame(); // When run by sub.xml, wframe1 object will be returned. // When run by main.xml, null will be returned.
getParentId( )
Returns WFrame ID when called by the script in the WFrame. Returns null when called by a global script.
Return
typedescription
StringWFrame ID
Sample
// When writeen in main.xml <w2:wframe id='wframe1' src='sub.xml'/> scwin.$w.getParentId(); // When run by sub.xml, 'wframe1' will be returned. // When run by main.xml, null will be returned.
getPopupId( )
Gets the ID of the popup. Needed when the popup is on the WFrame.
Return
typedescription
StringID of the popped up window.
getPopupParam( )
Returns dataObject parameters or XML parameters as a string to create a popup using openPopup.
When both dataObject and XML properties are defined, only dataObject will be returned.
It is recommended to use $w.getParameter (name value in dataObject) for dataObject.
Return
typedescription
StringString of the dataObject or XML property or the pop-up
Sample
// Define the dataObject of openPopup as shown below. //dataObejct : {type:"json" , name:"tmpData" , data:{"test":"WebSquare"}} var dataStr = $w.getPopupParam(); // (Return Example) {"test":"WebSquare"}
getPopupUrl( )
Gets the URL of the current popup window. Required when the popup is in the WFrame.
Return
typedescription
StringReturns the URL of the current window. Gets the URL of the WFrame window when called within the WFrame.
getPopupWindow( id )
Searches by ID defined in openPopup and returns the window of the searched popup.
Can the components and the global variables within the popup.
Parameter
nametyperequireddescription
idStringYPopup ID
Return
typedescription
ObjectPopup window
Sample
// Returns the window of which ID is popup1. var popWinObj = $w.getPopupWindow("popup1"); // Access the global variable tmpVal of the popup. var popTmpVal = popWinObj.tmpVal; // Get the value of the component of which ID is input1. var popInputVal = popWinObj.input1.getValue();
getRunningWorkflow( workflowID )
Returns the ID of the currently running first workflow.
Parameter
nametyperequireddescription
workflowIDStringNworkflow ID
Return
typedescription
ObjectCurrently running workflow object
Sample
Valid only in the workflow running node (condition, defaultCallback, callback, finalCallback, rejectCallback, etc.) Use workflowObj.result to get the result of the completed submissions. var workflowObj = $w.getRunningWorkflow( );
getRunningWorkflowID( )
Returns the ID of the currently running workflow.
Return
typedescription
StringID of the currently running workflow
Sample
Return the currently running workflow ID var runID = $w.getRunningWorkflowID( );
getRuntimeId( )
Returns the actual ID of the component by receiving the component ID (in the page).
When the scope function of the WFrame is in use, the actual ID of the component in the WFrame will be “wframe ID + _ + Component ID”. This function is to get this actual ID.
Return
typedescription
StringActual ID of the component
Sample
// There is <w2:input id='input1'/> <w2:wframe id='wframe1' src='sub.xml'/> in main.xml. // There is <w2:input id='input2'/> in sub.xml. // When scwin.$w.getRuntimeId("input2") is called in sub.xml, 'wframe1_input2' will be returned. // When scwin.$w.getRumtimeId('input1') is called in sub.xml, 'input1' will be returned. // When scwin.$w.getRuntimeId("input2") is called in main.xml, '' will be returned. // When scwin.$w.getRuntimeId("input1") is called in main.xml, 'input1' will be returned.
getStringByteSize( str )
Returns the byte size of the given string. The byte size of the Korean chracters depends on <byteCheckEncoding value="euc-kr" /> setting in config.xml. In case of euc-kr, one Korean character is 2 bytes, and in case of utf-8, 3 bytes.
Parameter
nametyperequireddescription
strStringYString to get the byte size
Return
typedescription
Numberbyte size
Sample
var dataLength = $w.getStringByteSize("websquare"); // (Return Example) dataLength : 9 var dataLength2 = $w.getStringByteSize("Hello"); // (Return Example) dataLength2 : 4 // In case of <byteCheckEncoding value="euc-kr" /> // (Return Example) dataLength2 : 6 // In case of <byteCheckEncoding value="utf-8" />
getSubmission( submissionID )
Returns the submission object of the corresponding submissionID.
Submission properties such as action, ref, and target are changeable.
Parameter
nametyperequireddescription
submissionIDStringYsubmission ID.
Return
typedescription
SubmissionObjectSubmission object of the corresponding ID
Sample
// When a submission exists as shown below. <xf:submission id="submission1" ref="data:json,reqDataMap1" target="data:json,resDataMap1" action="/getUserInfo.jsp" method="post" mediatype="application/json" encoding="UTF-8" mode="asynchronous" processMsg=""> </xf:submission> // Return the submission object. var sub = $w.getSubmission( "submission1" ); // Change the submission properties. sub.action = "/getBookInfo.jsp"; sub.ref = "data:json,reqDataMap2";
getTimeoutKeyList( )
Returns all registered keys of setTimeout API as an array.
Return
typedescription
ArrayList of the registered keys of setTimeout
Sample
var timeoutKeyList = $w.getTimeoutKeyList(); for(var i = 0; i &lt; timeoutKeyList.length; i++) { $w.clearTimeout(timeoutKeyList[i]); } // Clears all registered timers.
getWorkflow( id )
Gets the workflow object of the corresponding ID.
Parameter
nametyperequireddescription
idStringYworkflow ID
Return
typedescription
ObjectWorkflow of the corresponding ID
Sample
If workflow1 is defined in XML, the workflow object can be obtained even before execution. For the dynamically created workflow, valid only in the workflow running node (condition, callback, finalCallback, rejectCallback, etc.) Use workflowObj.result to get the result of the completed submissions. var workflowObj = $w.getWorkflow( "workflow1" );
hideModal( )
Hides the modal layer of WebSquare5.
Sample
$w.hideModal();
isPopup( )
Checks whether the present window is a pop-up.
Return
typedescription
boolean"true" for popup. "false" otherwise.
Sample
var ispopup = $w.isPopup(); // (Return Example) false
isRunningWorkflow( workflowID )
Check whether there is a currently running workflow.
If the workflow ID is known, the execution status of the workflow will be returned.
Parameter
nametyperequireddescription
workflowIDStringNworkflow ID
Return
typedescription
booleanExecution status
Sample
Check whether there is a currently running workflow. var isRun = $w.isRunningWorkflow( );
isWframePopup( )
Checks whether the current window is a WFrame popup.
Return
typedescription
Boolean“true” for WFrame popup, and “false” otherwise.
Sample
// Run the bewlow in main.xml. scwin.$w.openPopup("w1.xml", {"type" : "litewindow", "frameMode" : "iframe"}); scwin.$w.openPopup("w2.xml", {"type" : "litewindow", "frameMode" : "wframe"}); // When scwin.$w.isWframePopup() is executed in main.xml, false will be returned. // When scwin.$w.isWframePopup() is executed in w1.xml, false will be returned. // When scwin.$w.isWframePopup() is executed in w2.xml, true will be returned.
js( scriptUrl , callback )
Controls the sequence of loading multiple external scripts. Loads the scripts in parallel, but runs them in a sequential manner. If the last received parameter is a function, execute the function after script loading. (callback)
Parameter
nametyperequireddescription
scriptUrlStringYjavascript url. The parameter count is not fixed. When there are multiple scripts to load, as man script URLs as the script count will be received.
callbackFunctionNIf the last received type is a function, the function will be executed after all scripts are executed. A callback function.
Sample
$w.js("/common/js/common.js", "/common/js/test1.js", "/common/js/test2.js", function(){alert("all done");}); // common.js, test1.js, and test2.js will be loaded in parallel, but they will be executed in the receive order (common.js -> test1.js -> test2.js.) // The callback function will be executed after test2.js is loaded. Then, alert("all done"); will be executed.
log( msg )
Displays logs on through the Log menu of the browser or in the developer mode of the browser.
If an object is displayed, an error may occur. Change the object into a string.
To output logs on the browser console, add the following setting (console="true") in config.xml.
<debug value="true" console="true"/>
Parameter
nametyperequireddescription
msgStringYMessage to dsiplay
Sample
$w.log('Log Test');
openPopup( url , options , params , target )
Creates a pop-up according to the properties.
Parameter
nametyperequireddescription
urlStringYPop-up window URL
optionsObjectYPopup options. (width, height, etc.)
<String:N> options.id : [default: ppo1] popup id <String:N> options.type : [default: browser] Popup type. window or browser (Default). browser is to use window.open regardless of the useIFrame setting. <String:N> options.width : [default: 500px] Popup width <String:N> options.height : [default: 500px] Popup height <String:N> options.top : [default: 100px] Top setting of the popup. When the useIframe is true, calculation is based on the browser. In case of false, calculation is based on the monitor. <String:N> options.left : [default: 100px] Left value of the popup. When the useIframe is true, calculation is based on the browser. In case of false, calculation is based on the monitor. <String:N> options.popupName : [default: WebSquarePopup] Name of the popup object. Displayed on the name layer of the popup frame. <String:N> options.modal : [default: false] Disables the background through the modal. In case of false, the component behind can be used. <String:N> options.useModalStack : [default: false] Activates the last opened popup when there are multiple popups. (true: Activates the last popup only. false: Activates all popups.) (Added in 5.0_1.2701A.20170714.211228.) <String:N> options.useIFrame : [default: false] In case of type="window" or "litewindow", uses IFrame or WFrame to create the popup. True is to use IFrame or WFrame, and false is to use window.open API when creating a popup. <String:N> options.frameMode : [default: ""] In case of type="window" or "litewindow" and useIFrame="true", uses WFrame or IFrame when creating a popup. <String:N> options.style : [default: ""] Popup style. If defined, left, top, width, height settings will not be applied. <String:N> options.srcData : [default: null] Xpath to give to the parent when the popup object type is window. <String:N> options.destData : [default: null] XPath to set in the popup when the popup object type is window. <Object:N> options.dataObject : Object to enter the data type, data, and the parameter names for the popup. (Example) { type: ["xml","string","json","array"], data: "Transmission Data" , name :"Parameter Names"} <String:N> options.xml : [default: null] XML to send to the popup. Can get from the string popup of the document through the use of WebSquare.uiplugin.popup.getPopupParam(). <String:N> options.resizable : [default: false] Size resizability. (Valid when the useIfrmae is false.) <String:N> options.status : [default: false] Status display. (Valid when the useIfrmae is false.) <String:N> options.menubar : [default: false] Display of the menubar. (Valid when the useIfrmae is false.) <String:N> options.scrollbars : [default: false] Display of the scrollbar. (Valid when the useIfrmae is false.) <String:N> options.title : [default: false] Display of the title. (Valid when the useIfrmae is false.) <String:N> options.useMaximize : [default: true] Maximization of the title upon the end user’s double-clicking in case of useIFrame:true <String:N> options.closeAction : [default: ""] Name of the function to be called upon the end user’s clicking the Close button in case of useIFrame:true Closes the popup if the user-defined function returns true. <String:N> options.className : [default: ""] userIFrame: Class to apply to the popup design <String:N> options.fullscreen : [default: false] fullscreen: Displays the popup on the full screen (For IE only.) <String:N> options.useControl : [default: false] useControl: true is to use Min, Max, and Close buttons. Valid with the setting of type="litewindow" or type=window" and useIFrame="true". <String:N> options.foldOnMinimized : [default: false] In case of foldOnMinimize: true, minimizing will be changed into folding. When using "minimize:true" in the controls option, use "foldOnMinimize:true". (Added in 5.0_1.2783B.20170908.145609.) <Object:N> options.controls : [default: { minimized:true, maximized:true, close:true }] Hides or displays certain control buttons. (Valid when the useControl is true.) In case of "minimize:true", set "foldOnMinimize:true". Using "foldOnMinimize:false" will make the window disappear instead of being folded. (Added in 5.0_1.2799B.20170918.104858.) <Object:N> options.foldSize : [default: { width: 500 }] foldSize: Defines the size of minimizing (folding.) (Valid when "minimize:true" and "foldOnMinimize:true" are used in the controls.)
paramsNullNUnused parameter. Enter null to use the fourth parameter.
targetObjectNwindow object. The default is window.
Sample
requires("uiplugin.popup"); // Include to use the pop-up. // Returned upon calling of methods such as dataList1.getRowJSON. var rowJSON = { "addr": "Seoul", "name": "Janet", "rowStatus": "R" }; // Object to send. var dataObj={ type : "json", // Data type. "xml","string","json","array" data : rowJSON, // Data object to send. name : "rowObj" // Name of the parameter. $w.getParameter( "rowObj" ) can get the name from the pop-up. }; var options = { id : "popup1", type : "browser", width: "230px", height: "250px", top: "130px", left: "200px", popupName : "openPopup1", modal : true, useIFrame : useIFrame, resizable : true, status : true, menubar : false, scrollbars : false, title : false, dataObject : dataObj }; $w.openPopup("/popup.xml", options );
parseDate( dateStr , format )
Converts the date-format data into Date. (Default : yyyyMMdd)
Parameter
nametyperequireddescription
dateStrStringYDate string
formatStringNDate format. Do not include delimiters.
Return
typedescription
DateDate object of JavaScript
Sample
var dateObj = $w.parseDate ("20120101"); // (Result) Sun Jan 01 2012 00:00:00 GMT+0900 (KST) var dateObj = $w.parseDate("2012-01-01"); // (Result) Sun Jan 01 2012 00:00:00 GMT+0900 (KST) var dateObj = $w.parseDate("2012-01-01","yyyyMMdd"); // (Result) Sun Jan 01 2012 00:00:00 GMT+0900 (KST) // The format must not include delimiters. The following example will return an error. var dateObj = $w.parseDate("2012-01-01","yyyy-MM-dd"); // (Result) null - Script error. var dateObj = $w.parseDate ("01222013112430", "MMddyyyyHHmmss"); // (Result) Tue Jan 22 2013 11:24:30 GMT+0900 (KST)
reinitialize( browserRefresh )
Reloads the page without refreshing the browser, or refreshes the browser.
Parameter
nametyperequireddescription
browserRefreshBooleanN[default:false, true] Reloads the page without refreshing the browser, or refreshes the browser.
Sample
$w.reinitialize(); // Reloads the page without refreshing the browser. $w.reinitialize(true); // Refreshes the browser.
rejectWorkflow( reject , workflowID )
Rejects the currently running workflow. When the workflow ID is given, the workflow will be rejected only when in running.
Parameter
nametyperequireddescription
rejectStringNReason of rejection
workflowIDStringN
Return
typedescription
ObjectRejected workflow Object
Sample
var workflowObj = $w.rejectWorkflow( );
setDisabled( obj )
Disables the belongings of the specified component.
Parameter
nametyperequireddescription
objJSONYObject with disabled settings
<String:N> obj.componentId :[default:body] Component ID. Or, body when not specified. <boolean:Y> obj.disabled : [default:false, true] Whether disabled or not. &lt;Array<String>:N> obj.excludeIdList : Array containing the component ID to exclude. &lt;Array<String>:N> obj.includeIdList : Array containing the component ID to include. (Applied to all when not specified.)</td> </tr> </table> <!--만일 해당 Method 에 return 값이 있는 경우 table 테그를 이용해서 보여준다.--> <table id="ptable"> <caption>Return</caption> <tr> <td class="header1">type</td><td class="header2">description</td> </tr> <tr> <td class="row">JSON</td><td class="row">Returns JSON-type data.<br /> <xmp class='js description'><Array> object.doneComponents Array containing completed components <Array> object.skipComponents Array containing disabled and skipped component IDs
Sample
$w.setDisabled({"disabled":true}); // Disable all. $w.setDisabled({"disabled":false}); // Enable all. $w.setDisabled({"componentId":"group1", "disabled":true}); // Disable the components belonging to group1. $w.setDisabled({"componentId":"", "disabled":true, "excludeIdList": ["output10"]}); // Disable all except output10. $w.setDisabled({"componentId":"", "disabled":true, "includeIdList": ["output1","output2"]}); // Disable output1 and output2 only.
setDocumentLang( lang )
Sets the language code in the HTML tag.
Parameter
nametyperequireddescription
langStringYLanguage code. (Example) xml:lang="ko"
Sample
$w.setDocumentLang("ko");
setDomain( domain )
Sets document.domain property.
Changing "www.inswav.com" into "inswave.com" is possible, but not to "support.inswave.com".
In most cases, a host is used for the data communication between different domains when interfacing with frames and popups. (Define the domain of the parent or the opener same as the domain of the popup.)
What is cross-domain? Cross-domain occurs when the calling domain and the called domain are separate. In other words, when a domain accesses another domain through JavaScript or has AJAX communication with a server, the access is denied for security reasons. In this case an error message such as "Not authorized" will be displayed.
Parameter
nametyperequireddescription
domainStringYCommon domain
Sample
// The URL is www.inswave.com. $w.setDomain("inswave.com"); // Possible. $w.setDomain("support.inswave.com"); // Not possible.
setInterval( func , options )
Regularly executes the function. (Supports setInterval of JavaScript.) Automatically removed upon page changing in the SPA mode.
Parameter
nametyperequireddescription
funcFunctionYFunction to execute
optionsJSONNOptions are as shown below.
<String:N> options.key : Key value to specify the interval. If not specified, func.toString().slice(0,30) will be used. <Number:N> options.delay : The interval to execute the function. The default is 1ms. The second argument of JavaScript setInterval. <Object:N> options.caller : Object to be defined as "this" in the function (including WebSquare5 components.) <Object:N> options.args : Arguments of the "func" in the array format. <function:N> options.before_call : The function to be called right before execution of the "func". Receives the return of the "func" as parameters. <function:N> options.callback :The function to be called right after execution of the "func". Receives the return of the "func" as parameters.
Sample
// Alerts the value of input1 component every two seconds. $w.setInterval(function(){alert(this.getValue());}, {caller:input1, delay:2000, key:"interval1"});
setTimeout( func , options )
Executes the "func" after a certain period of time. Clears the "func" upon time-out in the SPA mode.
Parameter
nametyperequireddescription
funcFunctionYFunction to execute
optionsJSONNOptions are as shown below.
<String:N> options.key : Key value to specify time-out. If not specified, func.toString().slice(0,30) will be used. <Number:N> options.delay : The interval to execute the "func". The default is 1ms. The second argument of JavaScript setInterval. <Object:N> options.caller : Object to be defined as "this" in the function (including WebSquare5 components.) <Object:N> options.args : Arguments of the "func" in the array format. <function:N> options.before_call : The function to be called right before execution of the "func". Receives the return of the "func" as parameters. <function:N> options.callback :The function to be called right after execution of the "func". Receives the return of the "func" as parameters.
Sample
// Displays an alert message after five minutes. $w.setTimeout(function(){alert('Five minutes have passed. Remain logged-in?');}, {delay:300000, key:"loginTimeout"});
showModal( popupComponents )
Shows the modal layer and sets (enables) the popup for the component.
Parameter
nametyperequireddescription
popupComponentsArrayNArray containing IDs of the components to pop up
Sample
var popupComponents=["input1", "trigger1"]; $w.showModal( popupComponents );
toTimestampString( dateObj )
Returns the Date object of JavaScript i the same format with that of the Timestamp of Java SQL. (yyyy-mm-dd hh:mm:ss.fffffffff)
Parameter
nametyperequireddescription
dateObjDatetYJavaScript date object
Return
typedescription
StringString in the format of yyyy-mm-dd hh:mm:ss.fffffffff
Sample
var dateObj = new Date(); var dateStr = $w.toTimestampString (dateObj); (Return Example) dateStr : 2014-03-11 11:01:47.219000
url( w2xPath , options )
Sends only the WebSquare page (w2xPath) for page changing.
Add additional arguments in the options to use the SPA mode.
Parameter
nametyperequireddescription
w2xPathStringYXML file path
optionsJSONNAdditional SPA settings
<Boolean:N> options.spa : [default:false, true] In case of true, w2xPath is sent as hash (#). Otherwise, w2xPath is sent as a search (?). If SPA options are not specified, the SPA setting (default: false) in config.xml will be used. <Boolean:N> options.forceReload : Whether to force reloading of the browser after page changing. Relevant only when SPA setting is true. Changing pages in SPA will result in accumulation of global resources and may cause memory leak. In this case, initialize the global resources and refresh the browser by setting forceReload as true. <Boolean:N> options.replaceHistory : Whether to overwrite the browser history. In case of true, location.replace will be called internally. In case of false, location.assign will be called. <JSON:N> options.param : Additional argument required for page changing are sent in JSON. Note only string can be sent in JSON. $w.getParameter and $w.getAllParameter can also get the additional arguments. <Boolean:N> options.shortURL : Whether to send the w2xPath URL or the entire path starting with http://. If not specified, will be decided by the WebSquare5 Engine.
Sample
var param1 = { "name":"WebSquare", "ID":"tmpVal1" }; $w.url("/bar.xml", {"spa" : true, "replaceHistory" : true, "param" : param1}); // Sends namd and ID parameters while moving to bar.xml in SPA. // Get param1 from bar.xml. $w.getParameter("name"); // (Return Example) WebSquare $w.url("/bar.xml", {"spa" : true, "forceReload" : true, "param" : param1}); // Refresh the browser and send name and ID parameters while moving to bar.xml in SPA.
URLEncoder( str )
Converts the given character string into application/x-www-form-urlencoded MIME format.
Parameter
nametyperequireddescription
strStringY
Return
typedescription
StringReturns the converted character string in application/x-www-form-urlencoded MIME.
Sample
var encodeStr = $w.URLEncoder( "String" ); // (Return Example) "%b9%ae%c0%da%bf%ad"