PropertyEventMethodIndex
$p - 5.0_4.4547B.20211124.201933

Provides utilities frequently used in WebSquare5.
Each utility is a package belonging to a WebSquare5 object, and provided as an API for developer's convenience.

Type

engine

Property Summary

Event Summary

Method Summary

$( )
Receives a jQuery selector as an argument and returns a jQuery object.
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 )
deleteSubmission( submissionID )
Deletes submissions.
download( actionUrl , XML , sendMethod )
Provides interfaces to call the URL in which a download module exists and to download a file.
dynamicCreate( id , tagName , options , parent , itemSet )
Dynamically generate Websquare objects.
executeParallel( submission , processMsg , resolveCallback , rejectCallback , id )
Executes the submissions in parallel without creating a workflow.
executeSerial( submission , processMsg , resolveCallback , rejectCallback , id )
Executes the submissions in serial without creating a workflow.
executeSubmission( submissionID , requestData , obj )
Executes the submission of the corresponding ID.
executeWhilst( submission , 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.
getComponentById( )
Returns the corresponding WebSquare component for the given ID.
getCurrentServerDate( pattern )
Gets the present time of the WAS.
getEventTarget( )
Returns the information of the component that triggered the corresponding event.
getFormattedDate( dateObj , pattern )
Receives a JavaScript Date object and returns it in the specified format.
getFrame( )
Returns the WFrame object wrapping the function itself when called by the script in the WFrame.
getFrameId( )
Returns the ID of the WFrame wrapping the function itself when called by the script in the WFrame.
getIntervalKeyList( )
Returns all keys registered by setInterval as an array.
getMaxMinYear( )
Returns maxYear and minYear in the config file in JSON format.
getMetaValue( key )
Returns the value corresponding to the meta key defined in the head area.
getParameter( param )
Returns get type parameters or data defined in dataObject of openPopup method.
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.
getPopupWindowList( )
Returns all popup windows created by openPopup.
getRunningWorkflow( workflowID )
Returns the object of the currently running first workflow.
getRunningWorkflowID( )
Returns the ID of the currently running workflow.
getRuntimeId( id )
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( closest )
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.
main( )
Returns the scope object of the highest-level page within the current window.
mirrorView( )
Mirrors the current screen to a new screen.
openPopup( url , options , params , target )
Creates a popup according to the specified properties.
parent( )
Returns the frame window of the parent.
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.
setFullView( zoomResolve )
Sets the fullview feature in the current screen.
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.
top( )
Returns the top-level frame window in the nested structure of the frame object.
toTimestampString( dateObj )
Returns the JavaScript Data object in the Timestamp format of Java SQL.
updateServerTime( pattern , resource )
Updates the time data of the WAS.
updateSuffix( options )
suffix
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.
watermark( str )
Adds the watermark to the current screen.

Property Detail

Event Detail

Method Detail

$( )
Receives a jQuery selector as an argument and returns a jQuery object.
In case the id selector is received and the id is for a WebSquare object within the page where the function was called, the id will be converted into the actual id of the WebSquare object before the called function is executed.
Return
typedescription
ObjectjQuery object
Sample
$p.$("#group1").wq("invoke", "setDisabled", "true"); // Traces the group1 of the page where the script was executed and runs group1.invoke("setDisabled", "true");.
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); }; $p.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. ( $p.setInterval )
Parameter
nametyperequireddescription
keyNameStringYDefined by the key. (Key name defined in the options upon calling of $p.setInterval API.)
forceBooleanNWhether to execute the function before clearing the Interval object of the corresponding keyName. The default is false.
Sample
// options.key is defined as "timer1" upon calling of $p.setInterval API. $p.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 $p.url(WebSquare.baseURI + "blank.xml", {spa:true, forceReload:true});.
Sample
<body> <script type="javascript" ev:event="onpageunload"><![CDATA[ $p.clearPage(); // 브라우저를 갱신하여 초기상태로 되돌린다. 이 경우 웹스퀘어 엔진 및 리소스를 새로 로딩하게 된다. ]]></script> </body>
clearTimeout( key , force )
Clears the functions registered by setTimer of WebSquare5 after time-out. ($p.setTimer )
Parameter
nametyperequireddescription
keyStringYKey value defined in options.key by the $p.setTimer.
forceBooleanNWhether to execute the setTimer function or not. The default is false.
Sample
// options.key is defined as "timer1" for $p.setTimer API. $p.clearTimeout("timer1");
closePopup( id )
Closes the popup based on the ID allocated by openPopup or createPopup.
Parameter
nametyperequireddescription
idStringYPopup ID
Sample
$p.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 ev:event="xforms-submit" <Function:N> submissionObj.submitDoneHandler : Function for ev:event="xforms-submit-done" <Function:N> submissionObj.submitErrorHandler : Function for 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); } }; $p.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 = $p.dateAdd( 20120102, 7 ); (Return Example) tmpDate1 : 20120109 var tmpDate2 = $p.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 = $p.dateDiff( "20120120", "20120210" ); (Return Example) diff : 21
deleteSubmission( submissionID )
Deletes submissions.
Parameter
nametyperequireddescription
submissionIDStringYID of the submission to delete
Sample
$p.deleteSubmission( "submission1" ); Deletes "submission1". Calling $p.executeSubmission("submission1"); will not make any effect.
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.) $p.download( url );
dynamicCreate( id , tagName , options , parent , itemSet )
Dynamically generate Websquare objects.
When calling $p.dynamicCreate in a child page with the WFrame using scope=true setting, WFrame prefix will be automatically added and the objects will be added as a WFrame scope.
Parameter
nametyperequireddescription
idStringYelement ID
tagNameStringYelement tagName
optionsObjectYCreation options of the element
parentObjectYHigher node of the element
itemSetObjectYelement itemset
Return
typedescription
ObjectNewly created WebSquare element
Sample
// (Example) Dynamically created Input and Calendar in the Group. // Create a Group component. $p.dynamicCreate("group1", "group", { style: "border: solid black; width:300px; height:400px; float:left; margin : 20px;" }); // Create an Input in the Group. $p.dynamicCreate("input1", "input", { style: "width:120px; height:40px; float:left; margin : 20px;" }, group1); var comObj = WebSquare.util.getComponentById("input1"); comObj.setValue("Input"); // Create a Calendar in the Group. $p.dynamicCreate("calendar1", "calendar", { style: "border: solid gray; width:120px; height:120px; float: left; margin : 20px;" }, group1);
executeParallel( submission , processMsg , resolveCallback , 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
resolveCallbackfunctionNfunction
rejectCallbackfunctionNfunction
idStringN
Sample
$p.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 , resolveCallback , 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
resolveCallbackfunctionNfunction
rejectCallbackfunctionNfunction
idStringN
Sample
$p.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
$p.executeSubmission ("submission1") ; Execute submission1.
executeWhilst( submission , condFn , maxRepeat , processMsg , resolveCallback , rejectCallback , id )
Repeatedly calls a certain submission without creating a workflow.
Parameter
nametyperequireddescription
submissionStringYID
condFnfunctionYpre function checking the execution status
maxRepeatintYMaximum execution count. Can be used to control infinite loops when the workflow can be identified only by the condition.
processMsgStringN
resolveCallbackfunctionNfunction
rejectCallbackfunctionNfunction
idStringN
Sample
$p.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
$p.executeWorkflow ("workflow1") ; workflowCollection/Run the workflow of which ID is workflow1. Or var workflowObj= {"id":"workflow1", "processMsg" : "Running.. ", "step" : [{ "type":"submit", "action" : "submission1"}, { "type":"submit","pre": cond, "action" : "submission2"}, { "type":"submitDone", "action" : "submission1", "post":post}, { "type":"submitDone", "action" : "submission2", "post":post} ], "resolveCallback" : final_callback, "rejectCallback": reject_callback }) ; $p.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
$p.getAllBASE64Parameter();
getAllParameter( )
Returns all get-type parameters in JSON format.
Sample
var getParam = $p.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
$p.getBASE64Parameter("name");
getComponentById( )
Returns the corresponding WebSquare component for the given ID.
In a multiple WFrame structure with the scope setting, the components in the page under the $p scope will be traced based on its original ID.
Return
typedescription
ObjectComponent object of the corresponding ID. (In the multiple WFrame structure, the component of the given ID in the WFrame page will be returned.)
Sample
$p.getComponentById("trigger1"); // Returns “trigger1” object of the corresponding scope of $p in a multiple WFrame structure.
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 = $p.getCurrentServerDate(); //yyyyMMdd (Return Example) dateStr : 20111225 var dateStr = $p.getCurrentServerDate("yyyy-MM-dd HH:mm:ss"); (Return Example) dateStr : 2014-11-07 15:49:10:080
getEventTarget( )
Returns the information of the component that triggered the corresponding event.
Return
typedescription
ObjectReturns the name, the component ID, and the full ID of the WebSquare component.
Sample
(Example) scwin.trigger01_click = function(e) { var info = $p.getEventTarget(this); } (Returned Info) { "pluginName": "Component name", "id": "component ID" }
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 = $p.getFormattedDate ( dateObj, “MM.yyyy” ); (Return Example) dateStr : 11.2014
getFrame( )
Returns the WFrame object wrapping the function itself 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'/> $p.getFrame(); // When run by sub.xml, wframe1 object will be returned. // When run by main.xml, null will be returned.
getFrameId( )
Returns the ID of the WFrame wrapping the function itself 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'/> $p.getFrameId(); // When run by sub.xml, 'wframe1' will be returned. // When run by main.xml, null will be returned.
getIntervalKeyList( )
Returns all keys registered by setInterval as an array.
Return
typedescription
ArrayKey array registered by setInterval
Sample
var IntervalKeyList = $p.getIntervalKeyList(); for(var i = 0; i &lt; IntervalKeyList.length; i++) { $p.clearInterval(IntervalKeyList[i]); } // Removes 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 = $p.getMaxMinYear(); // (Return Example) maxMinYear.maxYear : 2099 (yyyy) // (Return Example) maxMinYear.minYear : 1000 (yyyy)
getMetaValue( key )
Returns the value corresponding to the meta key defined in the head area.
Parameter
nametyperequireddescription
keyStringYMeta data key
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 = $p.getParameter("userID"); // (Return Example) "1234" // Define dataObject properties of $p.openPopup as shown below. //dataObject : { type : "json", data : {name:"WebSquare",addr:"Seoul"}, name : "rowObj" } var popRowObj = $p.getParameter("rowObj"); // (Return Example) {name:"WebSquare",addr:"Seoul"} //type : JSON Object
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 $p.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 = $p.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 = $p.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();
getPopupWindowList( )
Returns all popup windows created by openPopup.
Can the components and the global variables within the popup.
In multiple WFrame structure with scope=true setting, returns all popups for $w scope.
Return
typedescription
ArrayWindow list
Sample
// Return all popup windows. var popWinObj = $p.getPopupWindowList();
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 = $p.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 = $p.getRunningWorkflowID( );
getRuntimeId( id )
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.
Parameter
nametyperequireddescription
idstringYComponent ID of the page
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. // Calling $p.getRuntimeId("input2") in sub.xml will return 'wframe1_input2'. // Calling $p.getRumtimeId('input1') in sub.xml will return 'input1'. // Calling $p.getRuntimeId("input2") in main.xml will return ''. // Calling $p.getRuntimeId("input1") in main.xml will return 'input1'.
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 = $p.getStringByteSize("websquare"); // (Return Example) dataLength : 9 var dataLength2 = $p.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 = $p.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 = $p.getTimeoutKeyList(); for(var i = 0; i &lt; timeoutKeyList.length; i++) { $p.clearTimeout(timeoutKeyList[i]); } // Removes 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 = $p.getWorkflow( "workflow1" );
hideModal( )
Hides the modal layer of WebSquare5.
Sample
$p.hideModal();
isPopup( closest )
Checks whether the present window is a pop-up.
Parameter
nametyperequireddescription
closestBooleanNChecks whether the parent of the current page is a wframePopup or browserPopup.
Return
typedescription
boolean"true" for popup. "false" otherwise.
Sample
var ispopup = $p.isPopup(); // (Return Example) false Checks whether the parent of the current page is a wframePopup or browserPopup. var ispopup = $p.isPopup(true);
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 = $p.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. $p.openPopup("w1.xml", {"type" : "litewindow", "frameMode" : "iframe"}); $p.openPopup("w2.xml", {"type" : "litewindow", "frameMode" : "wframe"}); // Executing $p.isWFramePopup() in main.xml will return false. // Executing $p.isWFramePopup() in w1.xml will return false. // Executing $p.isWFramePopup() in w2.xml will return true. // Execute $p.isWFramePopup(true) to check if the parent WFrame is a popup.
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
$p.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
$p.log('Log Test');
main( )
Returns the scope object of the highest-level page within the current window.
Return
typedescription
Objectscope object
Sample
$p.main().input1.setValue("test"); // Set the value of input1 component in the main page as "test".
mirrorView( )
Mirrors the current screen to a new screen. (Uses Canvas and does not function on the old-version browsers.)
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: browserPopup] Type of the pop-up. Depending on the pop-up rendering method, iframePopup, wframePopup, or browserPopup can be set. (Functions same as existing properties frameMode and useIFrame.) <String:N> options.width : [default: 500px] Popup width <String:N> options.height : [default: 500px] Popup height <String:N> options.top : [default: 100px] Top position of the pop-up. Top position of the pop-up. When the pop-up is IFrame or WFrame, the position will be calculated based on the browser, or when the pop-up is a browser-native window, the position will be calculated based on the monitor. <String:N> options.left : [default: 100px] Left-position of the popup. When the pop-up is IFrame or WFrame, the position will be calculated based on the browser, or when the pop-up is a browser-native window, the position will be calculated 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.frameModal : [default: ""] modal frame (wframe, tabControl, windowContainer). "top", "parent", "frame", frame id <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.) <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] Resizability. (Valid when the pop-up is IFrame or WFrame.) <String:N> options.status : [default: false] Status display. (Valid when the pop-up is on the browser-native window.) <String:N> options.menubar : [default: false] Menu-bar display. (Valid when the pop-up is on the browser-native window.) <String:N> options.scrollbars : [default: false] Scroll bar display. (Valid when the pop-up is on the browser-native window.) <String:N> options.title : [default: false] Title display (Valid when the pop-up is on the browser-native window.) <String:N> options.useMaximize : [default: true] When the popup type is iframe or wframe, useMaximize = "true" will allow double-clicking the title to maximize the pop-up. <String:N> options.useModalDisable : [default: false] Disables all components in the parent window upon creation of a litewindow pop-up. <String:N> options.closeAction : [default: ""] Name of the customized function to be called upon the end user’s clicking the Close button. Valid when the pop-up is IFrame or WFrame. Closes the popup if the user-defined function returns true. <String:N> options.className : [default: ""] Name of the class to be applied to the popup. Valid when the pop-up is IFrame or WFrame. <String:N> options.fullscreen : [default: false] When the pop-up is IFrame or WFrame, opens the pop-upon full screen (fullscreen: true). (For IE only.) <String:N> options.useControl : [default: false] When the pop-up is IFrame or WFrame, the developer can add Min, Max, and Close buttons(useControl: true). <String:N> options.foldOnMinimized : [default: false] Folds the pop-up upon the pop-up being monimized. When using "minimize:true" in the controls option, use "foldOnMinimize:true". <Object:N> options.controls : [default: { minimize: false, maximize: false, close: false }] Shows or hides certain controls or buttons. (Valid when useControl is true.) In order to use "minimize:true", add "foldOnMinimized:true". Using "foldOnMinimize:false" alone will make the screen disappear instead of being folded. <Object:N> options.foldSize : [default: { width: 500 }] foldSize: Sets the size of being minimize or folded. (Valid when "minimize:true" and "foldOnMinimize:true" settings are defined.) <Object:N> options.useATagBtn : [default: false] “useATagBtn:true” is to use a tag for the Close button, and “useATagBtn:false” is to use div tag for the Close button. <Object:N> options.disableCloseButton : [default: false] “disableCloseButton:true” is to disable the Close button when the popup-up type is window or litewindow. “disableCloseButton:false” is to use the Close button. <Object:N> options.alwaysOnTop : [default: true] “alwaysOnTop:true” is to display the existing pop-up always on the top when the pop-up type is window or litewindow. In case of “alwaysOnTop:false” setting, the Close button will be used. <Object:N> options.popupUrl : [default: "popup.html"] URL of the popup page. The default is popup.html. <Object:N> options.windowDragMove : [default: false] Generates animation effects of a window moving when the user drags the popup window. <Object:N> options.processMsgFrame : [default: false] Displays the processMessage within the wframePopup.
paramsNullNUnused parameter. Enter null to use the fourth parameter.
targetObjectNwindow object. The default is window.
Sample
requires("uiplugin.popup"); // Must be added to create a popup. // Define the actual data to pass. var rowJSON = { "Personal Info" : { "Name": "Lee", "Age": 50, "Married" : false}, "Region": "Seoul", "Carrier": true }; // Pass data to the newly created popup (through the dataObject.) var dataObject = { "type" : "json", // Data type. "json" is recommended. "name" : "paramTest", // Key to get the data. The newly created popup can access the passed data through $p.getParameter( "paramTest" ). "data" : rowJSON // Actual data to pass. }; // Popup creation options. var options = { id : "popup1", type : "wframePopup", width: "230px", height: "250px", top: "130px", left: "200px", popupName : "testPopup", modal : true, resizable : true, status : true, menubar : false, scrollbars : false, title : false, dataObject : dataObject }; // Create a popup. $p.openPopup("/sub_popup.xml", options ); // (Example) The new popup accesses the passed data. // var paramData = $p.getParameter("paramTest"); // var data = JSON.stringify(paramData); // alert(data);
parent( )
Returns the frame window of the parent.
Returns the iframe window when the parent is of the iframe.
Returns the scope object of the WFrame if the paranet has the setting of scope=true.
Return
typedescription
ObjectGlobal window object or the scope object of the WFrame
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 = $p.parseDate ("20120101"); // (Result) Sun Jan 01 2012 00:00:00 GMT+0900 (KST) var dateObj = $p.parseDate("2012-01-01"); // (Result) Sun Jan 01 2012 00:00:00 GMT+0900 (KST) var dateObj = $p.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 = $p.parseDate("2012-01-01","yyyy-MM-dd"); // (Result) null - Script error. var dateObj = $p.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
$p.reinitialize(); // Reloads the page without refreshing the browser. $p.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 = $p.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
$p.setDisabled({"disabled":true}); // Disable all. $p.setDisabled({"disabled":false}); // Disable all. $p.setDisabled({"componentId":"group1", "disabled":true}); // Disable components under group1. $p.setDisabled({"componentId":"", "disabled":true, "excludeIdList": ["output10"]}); // Disable all compnents except output10. $p.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
$p.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. $p.setDomain("inswave.com"); // Allowed. $p.setDomain("support.inswave.com"); // Not allowed.
setFullView( zoomResolve )
Sets the fullview feature in the current screen. fullview is to control the zoom feature by calculating the ratio between the reference width/height and the browser width/height.
Parameter
nametyperequireddescription
zoomResolveFunctionYReturns an object containing baseWidth and baseHeight, or a zoom value.
Sample
scwin.zoomResolve = function() { var width = window.innerWidth || document.body.clientWidth; var height = window.innerHeight || document.body.clientHeight; var ratio = height / width; var baseRatio = 0.5625; // In case of 16:9, the ratio between the width and the height is 0.5625. if(ratio > baseRatio) { wrapper.addClass("hideWidget"); return {"baseWidth" : 1440, "baseHeight" : 979}; } else { wrapper.removeClass("hideWidget"); return {"baseWidth" : 1920, "baseHeight" : 979}; } } $p.setFullView(zoomResolve);
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. $p.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. $p.setTimeout(function(){alert('5 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"]; $p.showModal( popupComponents );
top( )
Returns the top-level frame window in the nested structure of the frame object.
Returns the top when the IFrames overlap.
Returns the top when the WFrames overlap. (Subject to change in the future.)
Return
typedescription
Objecttop object
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 = $p.toTimestampString (dateObj); (Return Example) dateStr : 2014-03-11 11:01:47.219000
updateServerTime( pattern , resource )
Updates the time data of the WAS. Updates through asynchronous network requests. Note that only the header request is sent.
Parameter
nametyperequireddescription
patternStringN[default:yyyyMMdd] Date format
resourceStringN[default:/favicon.ico] Sends the path when sending a network request for server time update.
Return
typedescription
ObjectReturns a promise object that contains the server time data in the resolve.
Sample
var promiseObj = $p.updateServerTime("yyyyMMddHHmmssSSS"); promiseObj.then(function(serverTime){console.log(serverTime)}); // Requests the favicon.ico header asynchronously and displays the the server time on the console. Check the favicon.ico request on the Network tab.
updateSuffix( options )
Updates suffix.txt file.
Parameter
nametyperequireddescription
optionsJSONYAn object that can set the callback function.
<String:Y> options.callback : Name of the callback function to be called upon suffix.txt file being updated.
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. $p.getParameter and $p.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" }; $p.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. $p.getParameter("name"); // (Return Example) WebSquare $p.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 = $p.URLEncoder( "String" ); // (Return Example) "%b9%ae%c0%da%bf%ad"
watermark( str )
Adds the watermark to the current screen. (Uses Canvas and does not function on older-version browsers.)
Parameter
nametyperequireddescription
strStringYString to be used in the watermark