Monthly Archive for May, 2008

FCKeditor – inline html editor

fckeditor logo FCKeditor   inline html editor

Should you need provide inline html editor feature in your web application (WYSIWYG editor), have a look at FCKeditor.

FCKeditor is very useful and functional. Let me cite a couple of its features:

  • Integration with ASP, ASP.NET, Java, ColdFusion, Perl, PHP, JavaScript and more
  • Complete toolbar customization
  • Skins support
  • Plugins support
  • Multi-language support with automatic user language detection
  • Lightweight and fast
  • Font formatting: type, size, color, style, bold, italic, etc
  • Text formatting: alignment, indentation, bullets list, etc
  • Link and anchors support
  • Image insertion, with upload and server browsing support
  • Table creation and editing (add, delete rows, etc) – one of the best systems on the market
  • Right click context menus support

I believe it’s worth recommending.

 FCKeditor   inline html editor

ASP.NET AJAX In Action

If you’re about to start playing with AJAX in ASP.NET it’s a good idea to read this book: ASP.NET AJAX In Action by Alessandro Gallo, David Barkol, Rama Krishna Vavilala (see on amazon).

It very well describes basics of AJAX and shows basic and more advanced techniques of applying it in ASP.NET. There are exaplanations of Microsoft Ajax Library, UpdatePanel, ASP.NET AJAX client components, bulding AJAX-enabled controls, and much, much more. All well written and supported with extensive examples.

FOAF.Vix – the way to visualise your FOAF file

Foaf FOAF.Vix   the way to visualise your FOAF fileImage via Wikipedia

If you use Friend of a Friend (FOAF) files to describe your profile and want to provide it to the reader in a readable way FOAF.Vix is a perfect service. Let me cite the description created by its authors:

FOAF.Vix is a visualizer and relation explorer for FOAF (Friend of a Friend) files. Although this file format is designed first of all to be machine readable, it is often desirable to be able to browse it as if it were a usual Web page. FOAF.Vix gives you this possibility, presenting the data from a FOAF file in an easy to understand form and allowing to follow links to other Web resources it contains, including links to other FOAF pages, thereby allowing you to explore the network of human relations.

Of course I decided tp use that tool icon smile FOAF.Vix   the way to visualise your FOAF file So have a look at my readable FOAF profile

 FOAF.Vix   the way to visualise your FOAF file

Tricky example with polymorphism

Example

Can you predict the output of the following code?

class SubTest extends Test {
    public int aNumber;

    public SubTest() {
        aNumber = 17;
    }

    public void doubleANumber() {
        System.out.println("Inside SubTest.doubleANumber()");
        aNumber *= 2;
    }
}

public class Test {
    public int aNumber;

    public Test() {
        aNumber = 6;
    }

    public void doubleANumber() {
        System.out.println("Inside Test.doubleANumber()");
        aNumber *= 2;
    }

    public static void main(String[] args) {
        Test t = new SubTest();
        t.doubleANumber();
        System.out.println("The value of aNumber is " + t.aNumber);
    }
}

Result

The output is:
Inside SubTest.doubleANumber()
The value of aNumber is 6

As you see, it was not the reference type but the real object type of t variable that decided which method was invoked at runtime. This way, aNumber of SubTest class was modified. This variable shadowed aNumber of Test class. Therefore, Test.aNumber variable was untouched (didn’t change at all).

Threads: multiple call to run() method

You can call run() method of a thread many times. However, not a single new thread will be started. This way JVM will only execute the code from run() method. And this will not probably be what you tried to achieve.

Remember: to start a new thread, you need to call start() method, which among others, will execute run() method in a new concurrent context.

java.util.IllegalFormatConversionException when using System.out.format()

A few weeks ago I described how to format output using System.out.printl() and System.out.println() methods

Try to run the code below:

double avgAge = 245 / 34;
System.out.format("Average age is %d.", avgAge);

Without doubts you’ll get an exception thrown at runtime:

Average age is Exception in thread "main"
java.util.IllegalFormatConversionException:
d != java.lang.Double
    at java.util.Formatter$FormatSpecifier.failConversion(Unknown Source)
    at java.util.Formatter$FormatSpecifier.printInteger(Unknown Source)
    at java.util.Formatter$FormatSpecifier.print(Unknown Source)
    at java.util.Formatter.format(Unknown Source)
    at java.io.PrintStream.format(Unknown Source)

The reason is becase wrong conversion label was used. To recall, conversion label is ‘%’ sign followed by a letter b, c, d, f, or s inside System.out.format().

In the above example, %d meant that an integral type (byte, Byte, short, Short, int, Integer, long, Long, BigInteger) would be used. However, finally there was a floating point passed (avgAge). This example would work if this conversion label were used: %f.

So, remember to be careful with conversion label!