[Bese-devel] AJAX teaser

Henrik Hjelte henrik at evahjelte.com
Wed Feb 1 12:56:05 UTC 2006


On tis, 2006-01-31 at 23:15 +0200, Evrim ULU wrote:
> Assume a button changes the color of a dojo component, one may use
> javascript methods to set the style of the component. I'm looking for a
> solution to send these style changes to server, if it is the case with
> LiveConnect (java+js ipc) it seems its easy. Just pass the style objects
> and persist it. Other types of data may need also persistence.
> 
> I couldn't figure out how to do this with dojo,ucw. 
It takes time..

> Do you have any
> idea? Then I may use ajax to transport data and i'll be very cool:)

I'm finishing a little Lisp library for the Json data format, which is
really convenient for this. Coming very soon...

Use parenscript. Use dojo.io.bind to send a string (for example json) as
a get parameter.
Collect the string in UCW.
Be inspired by the Ajax teaser from Hoan Ton-That or the macros / LoL
from Drew Crampsie, or my code below.

/Henrik Hjelte

My version in an experimental state looks like this:

in a render method:
(defmethod render ((p user-page))
  ;; Do stuff
  ;; Use this url for dojo.io.bind, send parameters as "content"
   (action-href  (lambda () (some-ajax-fn p)))

Another method:
(defmethod some-ajax-fn((p user-page))
  ;; grab a get parameter
  ;; Do stuff with it, return msg back to javascript
(setf (context.window-component *context*)
            (make-instance 'ajax-answer :text msg))
)
(defun ajax-request-parameter(parameter-name)
   (ucw::get-parameter (ucw::context.request *context*) parameter-name))

(defcomponent ajax-answer (window-component)
  ((text :initarg :text :accessor ajax-answer.text))
  (:default-initargs
   :content-type "text/plain"))

(defmethod render((a ajax-answer))
  (<:as-is (ajax-answer.text a)))






More information about the bese-devel mailing list