ucwTutorialValidationCode

Here's the example code for use of the validation code.

Validation code example 1

(defcomponent get-some-input (simple-window-component)
  ((input-field :accessor input-field
                :initform (make-instance 
                           'string-field
                           :input-size 20
                           :validators (list (make-instance 'not-empty-validator))))))

(defmethod render ((win get-some-input)) ((defentry-point "get-some-input.ucw" (:application *downloader-application*) () (call 'get-some-input)) (defcomponent valid-input-answer (simple-window-component) ())

(defcomponent invalid-input-answer (simple-window-component) ())

(defmethod render ((win valid-input-answer)) (declare (ignore win)) (<:p "The input was valid"))

(defmethod render ((win invalid-input-answer)) (declare (ignore win)) (<:p "The input was invalid"))

(defaction show-answer ((form get-some-input)) (if (validp (input-field form)) (call 'valid-input-answer) call 'invalid-input-answer)))


This page is linked from: ucwTutorialExampleCode   ucwTutorialWritingYourOwnValidator  

CLiki pages can be edited by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively