XSP.addOnLoad( listener )
Adds a function "listener" to the code that is executed when loading a page.XSP.attachClientScript(targetClientId, _event, clientScript), xsp.attachClientFunction(targetClientId, _event, clientSideScriptName)
Attaches a function to a client element for a specific event. If the function exists use attachClientFunction. If the code is inside the variable "clientScript" use attachClientScriptXSP.setSubmitValue(value)
Overwrites what a submission is sending back to the server. Use with caution!XSP.canSubmit()
Returns true/false. If a page has been recently submitted it returns false. Good way to prevent submit button double click hazards. To manually set it to true callXSP.allowSubmit()
XSP.addPreSubmitListener(formid, listener, clientId, scriptid)
Adds a function (the listener) that runs before the form (formid) is submitted. Great way to run cleanup code in custom controls to make them self contained. Also a good way to have code run only for a specific button (clientid) rather than onsubmit in any case. The scriptid helps to check if the listener has been loaded already (e.g. on partial page refresh) to avoid duplicate loads. If listener returns false submission does not happen. Runs after the client side validators.XSP.addQuerySubmitListener(formId, listener, clientId, scriptId)
Same as above but runs before the validatorsXSP.alert(message), XSP.error(message), XSP.confirm(question)
Currently this are wrappers around alert() and dojo.confirm(). Using this functions has the advantage of instant beautifications once the XSP object gets upgradedXSP.attachValidator(clientId, validator, converter)
Allows to attach a validator to a client object. The better way to validate than writing code in the onSubmit event. Admittingly a little more complex. The function warrants its own blog entry (stay tuned)XSP.validateAllFields(true|false)
Default for this is false. When set to true all client side validation is executed not only all until the first error. You will get a number of prompts. Makes sense with an overwritten validation function, but that's a story for another time.XSP.attachEvent(clientId, targetClientId, _event, clientSideScriptName, submit, valmode, execId)
Attaches events to client side elements. The clientId is the element, the targetClientId the target for a partial refresh, _event the event to attach. More in a future blog entry.XSP.fireEvent(evt, clientId, targetId, clientSideScriptName, submit, valmode, execId)
Allows to trigger an event script.XSP.attachPartial(clientId, targetId, execId, eventName, scriptName, valmode, refreshId, onStart, onComplete, onError)
Attaches events to client side elements. The clientId is the element, the targetId the target for a partial refresh, eventName the event to attach. on(Start|Complete|Error) the functions to run locally around the ajax event. More in a future blog entry.XSP.partialRefreshGet(refreshId, options), XSP.partialRefreshPost(refreshId, options)
Triggers a partial refresh manually. For POST the refreshId must point to a form, for get it can be any element with a partial refresh defines. The options object is quite interesting to examine. Includes parameters and functions to execute in the life cycle.XSP.attachDirtyListener(clientId)
Listen to a specific field. If it changes consider the form "dirty". (Persil to the rescue). UseXSP.attachDirtyUnloadListener(message)
to set a message. Typically you use that for "Your form has changed, do you really want to navigate away" type of messages.XSP.trim(string), XSP.startsWith(string, seachString), XSP.endsWith(string, searchString)
Convenience functions for string stuff.XSP.serialize(object)
Takes an JavaScript object and returns a textual representation. Currently JSON, but might change.XSP.toJson(object), XSP.fromJson(string)
Convert data from/to JSON format.XSP.log(message)
Send a message to the local log. Used for debug (mostly)
XPage XSP对象
本文由作者按照 CC BY 4.0 进行授权