DWR weirdness

Like many developers I use DWR in my java enterprise app. This facilitates communication between Javascript and backend Java code. However for a new feature I overloaded the Java backend function. I also modified the frontend to add the new parameters where necessary. On my windows machine everything worked fine. I then pulled in the data on my Linux laptop and wanted to start a debug session. However when I tried the app, the filtering wasn’t working. Hmm pretty strange, after a long debugging session I finally found the issue. I’m still not sure why or how, but this is what I noticed.

I’m sending 3 int values to the backend. It seems that for a weird reason on windows he converts the var productId = ‘4’ to an int and on Linux he didn’t do this. What happened was that my old method was executed without the new argument (as he couldn’t convert it). I would have actually expected the ap to also do this on windows as the ‘4’ isn’t an int in my eyes.

From now on I will never use overloading with DWR services. As Javascript doesn’t really check the number of arguments supplied for a function, this can do weird things!

Leave a Reply