Search Results

Search found 7 results on 1 pages for 'colby77'.

Page 1/1 | 1 

  • Java generic return type

    - by Colby77
    Hi, I'd like to write a method that can accept a type param (or whatever the method can figure out the type from) and return a value of this type so I don't have to cast the return type. Here is a method: public Object doIt(Object param){ if(param instanceof String){ return "string"; }else if(param instanceof Integer){ return 1; }else{ return null; } } When I call this method, and pass in it a String, even if I know the return type will be a String I have to cast the return Object. This is similar to the int param. How shall I write this method to accept a type param, and return this type?

    Read the article

  • jQuery mousemove performance

    - by Colby77
    Hi, When I bind a mousemove event to an element it is working smoothly with every browser except Internet Explorer. With IE the CPU usage is way too much and some associated things (eg. tooltip) are ugly. Is there any way I could rid of the performance problem? (yeah I know, don't use IE :))

    Read the article

  • Inserting script from jQuery / Javascript

    - by Colby77
    Hi, I'm trying to insert reCaptcha code into my page from jQuery, but it doesn't work. Here is my code: $("#button").click(function() { $("#loginBox").html($.getRecaptcha()); }) When I try the following, my code doesn't even run. I think it's trying to execute instead of rendering it. $.getRecaptcha = function(){ return '<script type="text/javascript"' + 'src="http://api.recaptcha.net/challenge?' + 'k=6Ld3iAsAAAAAAGyX8QT244GagPEpCDSD-96o4gEi"></script>'; } With the following, the code runs, but when I click to #button I get an empty, full white browser window. $.getRecaptcha = function(){ var captcha = $("<script>") .attr("type", "text/javascript") .attr("src", "http://api.recaptcha.net/challenge?k=6Ld3iAsAAAAAAGyX8QT244GagPEpCDSD-96o4gEi"); return captcha; } I don't want to insert reCaptcha code into my html from the beginning, because it downloads the reCaptcha content from the reCaptcha server even if my users don't want to use it. I could set the visibility of the container that holds the reCaptcha to invisible (display: none;), but it will dowload the content irrespectively of it. I can insert the "noScript" code that reCaptcha gives us, but it doesn't work either, because it can spot that the browser allow javascript but I use noScript. Any suggestions? (I know I put my public reCaptcha key into the code, but it is just for testing purposes, and you could get it from my html or javascript code anyway)

    Read the article

  • Java performance issue

    - by Colby77
    Hi, I've got a question related to java performance and method execution. In my app there are a lot of place where I have to validate some parameter, so I've written a Validator class and put all the validation methods into it. Here is an example: public class NumberValidator { public static short shortValidator(String s) throws ValidationException{ try{ short sh = Short.parseShort(s); if(sh < 1){ throw new ValidationException(); } return sh; }catch (Exception e) { throw new ValidationException("The parameter is wrong!"); } } ... But I'm thinking about that. Is this OK? It's OO and modularized, but - considering performance - is it a good idea? What if I had awful lot of invocation at the same time? The snippet above is short and fast, but there are some methods that take more time. What happens when there are a lot of calling to a static method or an instance method in the same class and the method is not synchronized? All the calling methods have to fall in line and the JVM executes them sequentially? Is it a good idea to have some class that are identical to the above-mentioned and randomly call their identical methods? I think it is not, because "Don't repeat yourself " and "Duplication is Evil" etc. But what about performance? Thanks is advance.

    Read the article

  • XSS attack prevention

    - by Colby77
    Hi, I'm developing a web app where users can response to blog entries. This is a security problem because they can send dangerous data that will be rendered to other users (and executed by javascript). They can't format the text they send. No "bold", no colors, no nothing. Just simple text. I came up with this regex to solve my problem: [^\\w\\s.?!()] So anything that is not a word character (a-Z, A-Z, 0-9), not a whitespace, ".", "?", "!", "(" or ")" will be replaced with an empty string. Than every quatation mark will be replaced with: "&quot". I check the data on the front end and I check it on my server. Is there any way somebody could bypass this "solution"? I'm wondering how StackOverflow does this thing? There are a lot of formatting here so they must do a good work with it.

    Read the article

  • Java generic return tpye

    - by Colby77
    Hi, I'd like to write a method that can accept a type param (or whatever the method can figure out the type from) and return a value of this type so I don't have to cast the return type. Here is a method: public Object doIt(Object param){ if(param instanceof String){ return "string"; }else if(param instanceof Integer){ return 1; }else{ return null; } } When I call this method, and pass in it a String, even if I know the return type will be a String I have to cast the return Object. This is similar to the int param. How shall I write this method to accept a type param, and return this type?

    Read the article

  • Detecting html textarea's change

    - by Colby77
    Hi, I'd like to monitor my textarea's changes with jQuery. I can do this with the keyup event and it works perfectly. But what event I can get when a user click on the textarea (right mouse click), then choose paste? Click event occur only when the user click with the left mouse button on the textarea. How can I handle this situation?

    Read the article

1