This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns jwt-examples.hello) | |
(defmacro create-listener [args & body] | |
(let [argsnum (if (< 0 (count args)) (count args) "") ] | |
`(proxy [ ~(symbol (str "Signal" argsnum "$Listener")) ] [] (trigger ~args ~@body)))) | |
(import [eu.webtoolkit.jwt WObject Signal WApplication WBreak WtServlet | |
WEnvironment WLineEdit WPushButton WText Signal$Listener Signal1 | |
EventSignal WWidget Side] | |
[java.util EnumSet]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns jwt-examples.core | |
(:use [jetty-wrapper.core :only [run-server]]) | |
(:use [jwt-examples.hello :only [make-servlet]])) | |
(defn -main [] | |
(run-server {:port 4000} "/*" (make-servlet))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (C) 2009 Emweb bvba, Leuven, Belgium. | |
* | |
* See the LICENSE file for terms of use. | |
*/ | |
package eu.webtoolkit.jwt.examples.hello; | |
import eu.webtoolkit.jwt.Side; | |
import eu.webtoolkit.jwt.Signal; | |
import eu.webtoolkit.jwt.WApplication; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun game-from-name (name) | |
(clsql:locally-enable-sql-reader-syntax) | |
(car (clsql:select 'game | |
:where [= [slot-value 'game 'name] name]))) | |
(defun games () | |
(sort (clsql:select 'game) #'> :key #'(lambda (g) (apply #'game-votes g)))) | |
(defun add-game (name) | |
(unless (game-stored? name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Turn off caching of select queries | |
(setf clsql:*default-caching* nil) | |
;; Connection parameters | |
(defvar *database-type* :odbc) | |
(defvar *database-name* "RetroGames") | |
(defvar *database-user* "sa") | |
(defvar *database-server* "localhost") | |
(defvar *database-password* "password") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(clsql:def-view-class game () | |
((id | |
:db-kind :key | |
:db-type "int identity(1,1)") | |
(name | |
:accessor game-name | |
:db-constraints (:unique :not-null) | |
:db-type "nvarchar(50)" | |
:initarg :name) | |
(votes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define-url-fn (new-game) | |
(standard-page (:title "Add a new game") | |
(:script :type "text/javascript" | |
(str (ps | |
(defun validate () | |
(when (= (@ ((@ document get-element-by-id) "name") value) "") | |
(alert "Please enter a name.") | |
(return false)))))) | |
(:h1 "Add a new game to the chart") | |
(:form :action "/game-added.htm" :method "post" |
NewerOlder