Release: Validation Plugin 1.7

An update for the jQuery validation plugin is available. Most important: Its now fully compatible with jQuery 1.4.2, and still fully compatible with jQuery 1.3.2. I didn’t test with 1.2.6, but it should work, too.

There are four new localizations: Lithuanian, Greek, Latvian and Hebrew. The Spanish localization got a few improvements (I fully trust my contributors on that). Someone also contributed phoneUK and mobileUK methods, which can be found in additional-methods.js (while adding those, I renamed the phone-method to phoneUS).

And as a first proof of concept, there is now a demo styled with jQuery UI Themeroller classes. I’ll improve that when form support gets better in jQuery UI (planned for 1.9).

Download this release.

The full changelog:

The right place for support changed a bit – the mailinglist is no more, replaced by a much cooler forum:

  • Please post questions to the official Using jQuery Plugins Forum, tagging your question with (at least) “validate”. Keep your question short and succinct and provide code when possible; a testpage makes it much more likely that you get an useful answer in no time.
  • Please post bug reports and other contributions (enhancements, features, eg. new validation methods) to the plugins.jQuery.com bug tracker (requires registration).

Enjoy!

Java Tricks: Find out who invoked you

There is a setting in the log4j framework that allows you to log the exact location of where the logger was invoked (I’d provide a link to the related documentation, but I can’t find it; the lo4j site is a horrible mess). I always wondered how that works, here’s how:

public class Invoker {

        public static void main(String[] args) {
                System.out.println("Invoked from: " + invoker());
                System.out.println("A bit more indirect: " + test());
        }
       
        private static String test() {
                return invoker();
        }

        public static String invoker() {
                try {
                        throw new RuntimeException();
                } catch(RuntimeException e) {
                        return e.getStackTrace()[1].toString();
                }
        }
}

The output format matches the Exception#printStackTrace format, so that you can click on the result in the Eclipse console and it opens the file at the correct line:

Invoked from: Invoker.main(Invoker.java:4)
A bit more indirect: Invoker.test(Invoker.java:9) 

Based on the comment attached to the code where I found this, there is an easier way to obtain the stack in Java 1.5. And with a bit of searching, I found the getStackTrace method, added to Thread in 1.5. With that, the code becomes even simpler:

public class Invoker {

        public static void main(String[] args) {
                System.out.println("Invoked from: " + invoker());
                System.out.println("A bit more indirect: " + test());
        }
       
        private static String test() {
                return invoker();
        }

        public static String invoker() {
                return Thread.currentThread().getStackTrace()[2].toString();
        }

} 

Note that the call to Thread#getStackTrace ends up on the stack, too, so the interesting StackTraceElement is at index 2, not 1 as before.

A final warning: While this is immensly helpful for log-based debugging, the performance hit should be kept in mind. The log4j documentation warns about that as well, though I suspect that the Java 1.5 methods will have less impact than the try-catch approach. And some very primitive benchmarking proved me wrong…

Reboot?

I’m thinking about rebooting this blog: Create a new .com site with my jQuery stuff and posting about technical/programming stuff there, while relaunching this site into a german blog, posting about non-technical stuff, music, politics…

If you read this, please let me know what you think: leave a comment, or send me a mail at [email protected]

Wallraff Interview, Sozialdebatte, Religion

Hier sind drei Artikel auf zeit.de, ich die allesamt sehe empfehlen kann.

Zum einen ein Streitgespräch mit Günter Wallraff, zu dessen Buch Aus der schönen neuen Welt (ebenfalls sehr empfehlenswert) und den zugehörigen Film, Schwarz auf Weiss. Auch die am Ende erwähnte Titanic-Satire dazu lesen!

Dann wäre da ein Artikel zur Sozialdebatte, auch wenn in der URL Armutsdebatte steht. Es sollte schwer fallen, dem uneingeschränkt zuzustimmen, aber als Denkanstoß sehr gut.

Wieder was ganz anderes: Der Bericht von Jemand, der wegen das Papstes aus der Kirche austreten will, und dies zunächst mit Pfarrern aus ganz Deutschland bei der Beichte bespricht.