Overriding Inbuilt Functions

Occasionally it is useful to replace the standard functionality of an ExtraView inbuilt JavaScript function with a user-defined JavaScript function. You can use JavaScript's ability to return a Boolean answer in response to a query on the existence of a method. As an example, you may want to override the inbuilt ExtraView JavaScript function named SubmitChange. This method lives within a JavaScript file that is accessed from the Add Issue screen, named AddEdit.js.

  • The ExtraView JavaScript functions are located in the main ExtraView code directory on the application server, within the directory name javascript. Within this directory, another directory named user_javascript contains the user-defined JavaScript functions
  • Create a function named userSubmitChange in the file AddEdit.js
  • In the UserJavaScript.js file, create a function named _userSubmitChange, which actually performs the task needed
  • Now you can call userSubmitChange, which will look like the following code snippet –
        /**
         * this will call the _userSubmitChange if 
         * it is defined, else it calls submitChange
         */
        function userSubmitChange(field){
            if(_userSubmitChange){
                _userSubmitChange(field);
            } else {
                submitChange(field);
            }
        }
    

If the function _userSubmitChange doesn't exist in the UserJavaScript.js file, then the standard submitChange function is used instead. Its existence is assured as it is contained in the standard ExtraView distribution file.