Showing posts with label web. Show all posts
Showing posts with label web. Show all posts

Monday, 8 June 2009

Apache Tomcat service fails if running on a 64bit JVM

Our deployment platform is Windows 200x, 64 bit. Don't ask why - I too am a Linux fan boy. Anyway, installing tomcat as a service works, but trying to start said service fails. Turns out that unless you want to jump through a few hoops you need to install the 32bit JDK. (don't forget to update the windows environment variable and then open a new console to pick up the new environment variable ;))

Wednesday, 27 May 2009

Javascript plus and minus operator gotchas

So I am using the joy that is jquery to ajaxify our web application, and we have a calendar component.

The component has a "next" and "previous" which lets you move between weeks. So I had the following code:
/**
 * Calendar functions
 */
function addEventHandlersToCalendarComponent() {
    $('#previousWeekButton').click(function() {
        $("#calendarViewInMs").val($('#calendarViewInMs').val() - MILLISECONDS_IN_A_WEEK);
        refreshCalendar();
        return false;
    });

    $('#nextWeekButton').click(function() {
       $("#calendarViewInMs").val($('#calendarViewInMs').val() + MILLISECONDS_IN_A_WEEK);

        refreshCalendar();
        return false;
    });

    $('#calendarDateGoButton').click(function() {
        refreshCalendar();
        return false;
    });
}
The previous week worked perfectly, but clicking the next week broke with the server saying it couldn't parse the number.

Hmm.

After thinking about, and seeing the actual value being sent to the server, it was obvious: "-" operators convert both operands into a number, the "+" operator however, does no such goodness, it simple does a string concatenation. The solution was simple, to use the parseInt to coerce the result of the "val()" method into an actual int.