Friday, August 19, 2011
Friday, June 10, 2011
ResourceBundles and special characters
Seems that some special characters when used in a ResourceBundle proper file will throw off the parser for substitution. These characters need to be escaped properly, the escape notation is as follows:
See also:
The special chars \', { and }:
| escape ' with another ' | '' | (double-single quote) |
| escape \ with another \ | \\ | (double backslash) |
| enclose } with ' | '}' | |
| enclose { with ' | '{' |
See also:
Tuesday, May 24, 2011
Monday, May 9, 2011
Autowiring objects not instantiated by the Spring Framework
In order to enabled autowiring capabilities, add the following properties to the beans element.
xsi:schemaLocation="http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"
xmlns:context="http://www.springframework.org/schema/context"
And make sure this line is included within the beans element
<context:annotation-config />
Next, in your code, get an instance of AutowireCapableBeanFactory.
Hint: Subclasses of AbstractApplicationContext have a getAutowireCapableBeanFactory, just one way to get such an instance.
Finally call the autowireBean(MyObject) method and like magic, so long as the annotations are correct, Spring will inject the correct instances.
xsi:schemaLocation="http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"
xmlns:context="http://www.springframework.org/schema/context"
And make sure this line is included within the beans element
<context:annotation-config />
Next, in your code, get an instance of AutowireCapableBeanFactory.
Hint: Subclasses of AbstractApplicationContext have a getAutowireCapableBeanFactory, just one way to get such an instance.
Finally call the autowireBean(MyObject) method and like magic, so long as the annotations are correct, Spring will inject the correct instances.
Thursday, May 5, 2011
Steps to add ssl cert to JVM
Found a great link for adding certs to java for windows, Mac, and linux.
http://eclipse.open.collab.net/servlets/ProjectProcess?pageID=3450
http://eclipse.open.collab.net/servlets/ProjectProcess?pageID=3450
Wednesday, April 27, 2011
jquery.dataTables
Great plugin for jQuery that makes creating a dynamically sortable, searchable, and page-able table via JavaScript a snap.
First create a properly formated html table with a unique id: eg. <table id="mytable"><thead></thead><tbody></tbody></table>
Then with one line of JavaScript, the table transforms into the dynamic table described above.
<script>
$('#myTable').dataTable();
</script>
PROS: Super easy with lots of baked in functionality
CONS: Requires all the table data to be written out to html page, possibly eating up unnecessary bandwidth.
See Also:
First create a properly formated html table with a unique id: eg. <table id="mytable"><thead></thead><tbody></tbody></table>
Then with one line of JavaScript, the table transforms into the dynamic table described above.
<script>
$('#myTable').dataTable();
</script>
PROS: Super easy with lots of baked in functionality
CONS: Requires all the table data to be written out to html page, possibly eating up unnecessary bandwidth.
See Also:
Friday, April 22, 2011
How to create a custom TypeConverter in Stripes
Stripes uses TypeConverters to take convert JSP responses (typically a serialized form), and convert it back into Java types. Most conversions that you will need are already provided by default (see like below), but I found with Enums sometimes special cases are needed. There are ways to register customer converts globally, but in this case I just needed it for a specific case.
Once the class is defined, it needs to be wired up in the ActionBean. In the below snipped, note the converter param in the @Validate annotation.
See Also:
Example Custom TypeConverter
public class MyEnumeratedTypeConverter extends EnumeratedTypeConverter{
@Override
public MyEnum convert(String input, Class targetType, Collection errors) {
MyEnum type = //Your conversion logic here.
if(type == null){
errors.add(new ScopedLocalizableError("converter.enum", "notAnEnumeratedValue"));
}
return type;
}
}
@Override
public MyEnum convert(String input, Class targetType, Collection
MyEnum type = //Your conversion logic here.
if(type == null){
errors.add(new ScopedLocalizableError("converter.enum", "notAnEnumeratedValue"));
}
return type;
}
}
Once the class is defined, it needs to be wired up in the ActionBean. In the below snipped, note the converter param in the @Validate annotation.
Example Wire-Up
@Validate(required = false, on={"fetch"}, converter=MyEnumeratedTypeConverter.class)
public void setMyEnums(Collection myenums){
this.myenums = myenums;
}
public void setMyEnums(Collection
this.myenums = myenums;
}
See Also:
Subscribe to:
Posts (Atom)