Recent Notes
Displaying notes 1 - 10
Created by Fang on May 17, 2012 19:31:39
Last update: May 17, 2012 19:31:39
To inject ServletContext into a Spring bean:
implement ServletContextAware :
import javax.servlet.ServletContext;
import...
Define bean in Spring application context:
<beans:bean id="myBean"
class="com.example.M...
Created by Fang on May 15, 2012 13:04:24
Last update: May 15, 2012 13:04:44
Set the warnLogCategory attribute to log uncaught exception stacktrace:
<bean
class="org.springframework.web.servl...
Created by Fang on May 03, 2012 15:07:17
Last update: May 03, 2012 15:07:52
Scaling an image with default Java API loses quality (horribly!):
public static BufferedImage resizeImage(Buffer...
The imgscalr library does the job beautifully. And its' very easy to do:
// import org.imgscalr.Scalr;
public static...
To import the library in Maven:
<dependency>
<groupId>org.imgscalr</groupId>
...
Created by James on May 03, 2012 14:54:46
Last update: May 03, 2012 14:54:46
History.js gracefully supports the HTML5 History/State APIs (pushState, replaceState, onPopState) in all browsers. For HTML4 browsers it will revert back to using the old onhashchange functionality. All major browsers are supported.
This is a simple test page to get started:
<html>
<head>
<title>Test History</title>
...
Note: state url must be provided for IE to generate a unique hash. YOu can prefix the state url with '?' ('#' does not work).
Created by James on May 02, 2012 13:01:24
Last update: May 02, 2012 13:01:24
Use the .prev() function to find the previous sibling of the current element:
$(this).prev()
or
$(this).prev('.selected')
Created by Dr. Xi on June 22, 2011 13:23:19
Last update: April 30, 2012 11:40:06
This is a utility to convert a byte array to hex string, and to convert a hex string back to the original.
To convert a String to hex, you must call String.getBytes() first. The utility does not pretend to know your string encoding.
public class StringHexUtil {
public static ...
This also works:
String binaryToHex(byte[] data) {
StringBui...
Created by zhidao on April 25, 2012 14:56:38
Last update: April 25, 2012 14:56:38
Lacking better alternatives, this is how I render a global validation error:
<spring:bind path="changePasswordForm">
<c:if ...
<form:errors> without path attribute seems to work too:
<form:errors cssClass="ui-error"/>
Created by voodoo on April 25, 2012 11:53:44
Last update: April 25, 2012 11:54:17
To find JSP files containing ' [0] ':
grep -l '\[0]' src/main/webapp/WEB-INF/views/*.jsp
or
grep -l \\[0] src/main/webapp/WEB-INF/views/*.jsp
Created by James on April 25, 2012 08:50:18
Last update: April 25, 2012 08:50:18
All DOM manipulation methods can move an element from one place to another, but the .appendTo() and .insertBefore variations are more convenient:
// moves h2 before .detail if there's one h2 a...
Created by James on April 25, 2012 08:38:05
Last update: April 25, 2012 08:38:05
With no parameters, the .toggle() method simply toggles the visibility of elements. Example:
$(function() {
$('body').click(function() {
...