Jan 5, 2011

vaadin clojure app (coding onlly)

This is a simple app which get two numeric values and give its sum as a message.

(ns myapp.core
 (import (com.vaadin.ui Layout)))

(defn getSum [tf1 tf2]
(let [a  (Double/parseDouble (. (. tf1 getValue) toString))
      b  (Double/parseDouble (. (. tf2 getValue) toString))
      c (+ a b)]
      (. c toString))

(defn main [args]
  (proxy [com.vaadin.Application] []
    (init []
      (let [app this
            l1  (new com.vaadin.ui.Label "My Application")
            tf1 (new com.vaadin.ui.TextField "Input value one :")
            tf2 (new com.vaadin.ui.TextField "Input value two :")]
        (.setMainWindow this
          (doto (new com.vaadin.ui.Window "Welcome to myapp")
            (.addComponent l1)
            (.addComponent tf1)
            (.addComponent tf2)
              (doto (new com.vaadin.ui.Button "Click Me")
                (.addListener (proxy [com.vaadin.ui.Button$ClickListener] []
                   (buttonClick [event]
                       (. (. app (getMainWindow)) (showNotification "The Sum is :" (getSum tf1 tf2)  )))))))
To get the real output you need to view the previous post.

1 comment:

  1. Wow, thank you so much for your contribution! The information you've provided is a brilliant thing for me! Thanks a million one more time! Everything works like a charm!


Your comments are always welcome ...