A good series at IBM
http://www.ibm.com/developerworks/java/library/j-dyn0916.html
Thursday, October 28, 2010
Excellent class loader article
http://www.javaworld.com/javaworld/javaqa/2003-07/02-qa-0725-classsrc2.html?page=3
Can show all classes loaded and all class loaders.
Can show all classes loaded and all class loaders.
Friday, October 1, 2010
Grails database transaction
This is my experience so far.
If transactional is set to true, Grails will always do a real commit when the public method exits. Even using save(flush:true), it won't commit to database until method exits.
Using withTransaction to scope block of code for which you want to commit it when block ends. But be sure to change transactional to false. I think transactional=true will override withTransaction, i.e. it will still try to commit when the method exits.
If transactional is set to true, Grails will always do a real commit when the public method exits. Even using save(flush:true), it won't commit to database until method exits.
Using withTransaction to scope block of code for which you want to commit it when block ends. But be sure to change transactional to false. I think transactional=true will override withTransaction, i.e. it will still try to commit when the method exits.
Thursday, September 2, 2010
Patching Grails
If you want to add a fix to Grails without waiting for next release, here is what I have done to patch it's jars. Basically it's two steps. First, compile patched source code to classes. Second, sneak patched classes into Grails distributed jar file.
1. Create a normal Grails project and add patched source based on same package structure of Grails source code. Compile it to get the classes.
2. Recreate the Grails jar file which contains classes you want to patch. Replace same jar file at $GRAILS_HOME/dist/. Note, Grails cache those jars under $USER_HOME/.ivy2/cache/org.grails. So make sure delete the cached jar file.
Just a side note: Thread.dumpStack() is quite useful to see stack trace.
1. Create a normal Grails project and add patched source based on same package structure of Grails source code. Compile it to get the classes.
2. Recreate the Grails jar file which contains classes you want to patch. Replace same jar file at $GRAILS_HOME/dist/. Note, Grails cache those jars under $USER_HOME/.ivy2/cache/org.grails. So make sure delete the cached jar file.
Just a side note: Thread.dumpStack() is quite useful to see stack trace.
Tuesday, February 23, 2010
Odd font size in quirks mode
If don't specify DOCTYPE, browser will rend the page in quirks mode. It can cause some weird problem. One problem I ran into: font-size seems mystically changed in some cases. Finally it turns out that browser(ff) is rendering in quirks mode, and in quirks mode, for the any table, it applies some styles to table. One of them is font-size: -moz-init;. This overrides your pages font-size style and use any font size from your browser's font setting, which by default is 16px. After changing to standard mode, it won't add extra styles.
Tuesday, January 19, 2010
jQuery jsonp support
It's still not supporting the error handling in 1.4 for jsonp request.
some useful links:
http://remysharp.com/2007/10/08/what-is-jsonp/
http://www.ibm.com/developerworks/library/wa-aj-jsonp1/?ca=dgr-jw64JSONP-jQuery&S_TACT=105AGY46&S_CMP=grsitejw64
some useful links:
http://remysharp.com/2007/10/08/what-is-jsonp/
http://www.ibm.com/developerworks/library/wa-aj-jsonp1/?ca=dgr-jw64JSONP-jQuery&S_TACT=105AGY46&S_CMP=grsitejw64
Thursday, January 7, 2010
Javascript Closure to remember variable in context
Closure can be used to remember variable in the context. e.g.
<script>
$().ready(function() {
var ts = $('.t');
for(var i = 0; i < ts.length; i++) {
var onClick = function(i) {
return function() {
alert(i);
return false;
}
}
$(ts.get(i)).bind('click', onClick(i));
}
});
</script>
<body>
<p><a class='t' href=''>Google</a></p>
<p><a class='t' href=''>Yahoo</a></p>
</body>
Member Not Found in IE when accessing event in callback
http://javascriptfixer.com/member-not-found.php
I spent a couple of hours trying to fix it and finally I found the same solution as the article above mentioned. In my case, the function is from an ajax onSuccess callback.
I spent a couple of hours trying to fix it and finally I found the same solution as the article above mentioned. In my case, the function is from an ajax onSuccess callback.
Subscribe to:
Posts (Atom)