Recent Notes

Displaying keyword search results 1 - 10
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 zhidao on January 23, 2012 15:00:19    Last update: January 23, 2012 15:00:19
The domain object is annotated @Entity , but Java runtime complains that it's not an entity class. Cause: : class not listed in persistence.xml , or persistence.xml misplaced, or multiple persistence.xml files existed.
Created by Dr. Xi on July 11, 2011 12:24:10    Last update: July 11, 2011 12:25:44
This code snippet import java.util.*; public class UncheckedCast ... fails with a compilation error and a warning: $ javac -Xlint:unchecked UncheckedCast.java Unc... Because List<String> is not a reifiable type, the Java Runtime does not have enough information to verify the type or do the type casting. This is fixed by changing List<String> to List<?> (or to the raw type List ): public static void main(String[] args) { Ob...
Created by alfa on May 26, 2011 13:23:30    Last update: May 26, 2011 13:23:30
The operator instanceof returns true if the first operand is an instance of the second operand: if (a instanceof A) { // true if a is an in... If the above is true, then this is also true: A.class.isAssignableFrom(a.getClass()); The only difference is, the second operand to instanceof is the symbol for a class, not a class object: // This is OK if (a instanceof A) { Syst...
Created by jinx on May 03, 2011 11:43:26    Last update: May 03, 2011 11:43:26
The PHP function strval returns the string value of a variable. It does the same thing as casting a variable to string, or automatic conversion where string is expected. Conversion rules: Type String Value Boolean TRUE '1' Boolean FALSE '' (empty string) integer of float string representing the number Array The string 'Array' Object Result of __toString() if defined, error otherwise Resource 'Resource id #n' , where n is a number assigned to the resource. NULL '' (empty string) Example: <?php set_error_handler(function($errno, $errst... Results: bool(true) --------------------- strval: '1'...
Created by jinx on April 26, 2011 21:52:10    Last update: April 26, 2011 21:52:10
PHP offers several ways to check the class type of an object instance at runtime: instanceof operator, is_a function, get_class function. Example: <?php class A { } class B { } ...
Created by jinx on April 25, 2011 12:43:40    Last update: April 25, 2011 12:43:40
Use the PHP function method_exists to check if the class or object has a certain method. It returns TRUE if the method exists (even when the value of the property is NULL), FALSE if the method does not exist. Example: <?php class A { var $p = 'A property'; ... Outputs: Class A has method f1: bool(true) Object $a has... Also note that C++-like method overloading does not exist in PHP. Thus there's no ambiguity about which version of the method exists, i.e., with no argument, with one argument... etc. The following code generates Fatal error: <?php class A { var $p = 'A property'; ...
Created by jinx on April 25, 2011 11:50:09    Last update: April 25, 2011 11:51:53
Use the PHP function property_exists to check if the class or object has a certain property. It returns TRUE if the property exists (even when the value of the property is NULL), FALSE if the property does not exist, or NULL in case of an error. Example: <?php class A { var $p = 'A property'; ... Outputs: Class A has property $p: bool(false) Class A ha...
Created by nogeek on February 03, 2011 13:08:38    Last update: February 03, 2011 13:14:10
The log line was like this: 2011-01-19 15:16:34,842 INFO [STDOUT] (HDScanne... Note that INFO and timestamp were printed twice. Based on my configuration, I was expecting something like this: 2011-01-19 15:16:34,842 INFO [XmlWebApplicationC... i.e., the logger name should have been XmlWebApplicationContext , not STDOUT ! What was the problem? I found this error message in server.log : 2011-01-19 14:34:38,107 ERROR [STDERR] (main) lo... It turned out that org.apache.log4j.Appender was loaded by my web application class loader, whereas org.jboss.logging.appender.FileAppender was loaded by the JBoss bootstrap class loader. Removing the log4j jar from my web application archive fixed the problem (sine log4j is already available in JBoss). Why was the logger changed to STDOUT? JBoss detects that there's a problem with the log4j configuration and routes all...
Created by voodoo on November 24, 2010 23:34:52    Last update: November 24, 2010 23:36:08
PostgreSQL provides two distinct ways to store binary data: Binary data can be stored in a table using the data type bytea . By using the Large Object feature which stores the binary data in a separate table in a special format and refers to that table by storing a value of type oid in your table. Different methods are used to access the BLOBs depending on which storage type you choose: To use the bytea data type you should use the getBytes() , setBytes() , getBinaryStream() , or setBinaryStream() methods. To use the Large Object functionality you can use either the LargeObject class provided by the PostgreSQL JDBC driver, or by using the getBLOB() and setBLOB() methods. Using setBinaryStream on an OID column yields...
Previous  1 2 Next