Monday, June 18, 2007

An introduction to Dojo

Related link:
http://dojotoolkit.org

What is dojo?
Dojo is an Open Source DHTML toolkit that is written in JavaScript. For more information, take a look at this:
http://dojotoolkit.org/book/dojo-book-0-9/introduction/dojo-what-it

Quick intro to general function in Dojo:
  1. dojo.require(String module)
    This is how to include other module file to work with.
    dojo.require("dojo.generalModule");
  2. dojo.byId(String id)
    This sounds like document.getElementById(String id) in standard Javascript.
    dojo.byId("idNumber");
  3. dojo.addOnLoad(Function func)
    This function will be executed after all the HTML is already loaded.
    dojo.addOnLoad(someFunction);
  4. dojo.connect
    This is the way to map an event handler (function) to any property or element or object.
    function sayHello() {
    alert("Hello, everyone.");
    }

    function init() {
    dojo.connect(dojo.byId('helloButton'), 'onclick', 'sayHello');
    }
  5. dojo.declare
    This is all you need when you want to create new widget.
    - Name of widget
    - Extended widget
    - Constructor
    - Variables and functions
    dojo.declare(
    "temp.widget.HelloButton",
    [dijit.base.FormElement, dijit.base.TemplatedWidget],
    {
    required: false,

    templateString: "",

    onclick: function() {
    alert("Hello!!");
    }
    });
Reminder:
postMixInProperties
We can hook any parameters or functions before rendering HTML page here before manager render this page.
postCreate
If you want to hook any parameters or functions after the manager rendered HTML page, do it here.

Thursday, May 10, 2007

How to setup our JAVA project to work with Log4j

  1. First, you will need 2 library files that are log4j-xxxx.jar and commons-logging-xxxx.jar. Which xxxx is version number. Affter that, add them into your project libraries.

  2. Create file name log4j.properties and paste it in your project class path. It will be copied into classes folder automatically.

    For example; If you project class path is src folder. Then this log4j.properties should be in src folder.


    After you already have log4j.properties file. This is the example code in the properties file.

    log4j.rootLogger = DEBUG, A1
    log4j.appender.A1 = org.apache.log4j.ConsoleAppender
    log4j.appender.A1.layout = org.apache.log4j.PatternLayout
    log4j.appender.A1.layout.ConversionPattern = %-7r %d [%t] %-5p %c -%m%n

    In the first line, the first parameter is level of logging that you need to configure. If you need to log DEBUG level, use DEBUG. But if you need to log INFO level, put INFO instead of DEBUG. By the way, DEBUG is rather bigger than INFO.

    In the second line, it means that you need to show log in the console.

    In the last line, you can configure pattern of your log here.

  3. In your java file, all you need is declare log and use it, like this;

    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;

    public class TestLog {

    private static final Log logger = LogFactory.getLog(TestLog.class);

    public static void main(String[] args) {
    logger.debug("This is my first logging.");
    logger.debug("This is my second logging.");
    }

    }

    The parameter that you need in the LogFactory.getLog() is your class name that you want to show when log is presented on the console.

    0 2550-05-10 11:22:02,908 [main] DEBUG TestLog - This is my first logging.
    0 2550-05-10 11:22:02,908 [main] DEBUG TestLog - This is my second logging.

Tuesday, May 1, 2007

My first entry 。(*゜~`*)。

Why did I create this blog?

Actually I got 2 blogs already. Although I had just wanted to create new one that I must pushed myself to publish entry in English version. Because I wanted to practice my english that isn't quite well as it used to be.

Why did I choose blogspot?

I had just noticed that google provides this service to us. So I tried to use this one.

What was my first attiture when using blogspot?

At first, I didn't like themes that they serve but nevermind I must choosed one of them. Later on, I found out that they served many conveniences quite well.

Thus it was so so to me, not positive or negative.

PS. My english is suck. If any grammar is wrong, just tell me. I will correct it. Thanks :D