0

I have a weird one here. I am working on a JSF2 (Java) based system using Primefaces component library (not sure its relevancy), and I have a number of buttons that execute a JavaScript function called checkParams() on a onclick event. I need to edit this function to reivew its code and adapt it to some newly added components but I cannot for the life of me actually find the JavaScript function. I am working in NetBeans & I have performed a project search for this function and the only search results returned are the button references to this component. Similarly I have done a search for the function in Google Chrome's developer console, which again only returned the button references. I have also tried creating a quick dirty function that calls an alert(checkParams()); on the body load, but Chromes console tells me the function is undefined.

However the buttons work perfectly, checking various input boxes and submitting the information to the backing Java files...

Does anyone have any idea where this function may be hiding or how I can locate it?

Mike Samuel
  • 118,113
  • 30
  • 216
  • 245
Ally
  • 1,476
  • 3
  • 19
  • 30
  • 1
    How do you know it's called `checkParams`? Can you show the code that led you to believe that? – Wayne Jan 06 '12 at 19:32

1 Answers1

0

It might be contained in a JavaScript Closure in a script file that is executed and then removed from the DOM. It would be a neat trick to 'hide' it a little bit. But, that is only if the checkParams() in the onclick is not in the onclick attribute. It would have to be assigned in JavaScript.

If this is the case, you would want to see what scripts are loaded initially, and look through those. Also, this is a lot of effort to hide a function for your own site unless you're trying to make sure people don't see how you are validating your parameters. There are ways to obfuscate it to assign the function without having it defined by name directly in the file, but, again, that is a lot of effort.

Outside of the above, I'm not sure there is a lot I can say for finding it. But I'm not sure that this is actually the case. One thing to note is that alert(checkParams()) will alert the return value, which means the function could be defined. Try running alert ( typeof ( checkParams ) ) instead. If that is undefined, than your function doesn't exist. If its not, you can also do console.log(checkParams) which should output the toString() of the function, which will often show you the code.

Community
  • 1
  • 1
LoveAndCoding
  • 7,857
  • 2
  • 31
  • 55
  • Thanks you helped me determine that the method doesnt actually exist & upon closer inspection validation was built in to the input field's themselves, which was updated upon submition. The buttons onclick="checkParams()" parameter was either as a placeholder for a method to be developed but never was or was an old function that was deleted and the reference(s) were never removed. Either way you confirmed to me that the function didnt exist. Cheers – Ally Jan 08 '12 at 17:08