Oct 24

Recently added a Facebook Fan/Like box widget to one of our sites. We used the following code and it worked great in our development environment when we tested it on Firefox and Safari.

<fb:fan href="http://www.facebook.com/obiweb"
   width="210" height="600" connections="0"></fb:fan>

But as is all too often the case when we tested it on IE it failed. No errors just a big blank space.

After some investigation it turns out that IE needs the Facebook namespace defined in the html tag. Adding the namespace as shown below fixed the problem.

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">

The end result can be found on the Obiweb blog.

written by objects \\ tags: , , , , ,

Oct 23

By default a StAX parser will break (typically latge) CHARACTER event into pieces to avoid creating large strings. You have no control over where this break occurs.

You can use a factory property “javax.xml.stream.isCoalescing” to control this behaviour and force it to combine adjacent CHARACTER events into a single event.

   XMLInputFactory.IS_COALESCING, Boolean.TRUE);

written by objects \\ tags: , , , ,

Oct 23

One thing reflection allows you to do is call a method dynamically at runtime. The following example shows how this can be achieved

// Get the Class instance of the object we want to call method on

Class clazz = o.getClass();

// Get the method we want to call
// For this example we'll call a method with this signature
// Double doSomething(String name, Integer[] args)

Method method = clazz.getMethod("doSomething", new String{ String.class, Integer[].class);

// Now invoke the method

Double result = (Double) method.invoke(o, new Object[] {
   new Integer[] { new Integer(1), new Integer(3)});

written by objects \\ tags: , ,