[Bese-devel] another extension
Friedrich Dominicus
frido at q-software-solutions.de
Thu Sep 1 08:09:12 UTC 2005
Well kind of and not addition without another question.
here's an addition to form.lisp
(defclass attributed-text-field (text-field)
((css-class :accessor css-class :initarg :css-class :initform "ucw-text-field")
(editable :accessor editable :initarg :editable :initform t))
(:metaclass standard-component-class))
(defmethod render-on ((res response) (field attributed-text-field))
(if (editable field)
(<ucw:input :type "text" :class (css-class field) :accessor (client-value field)
:size (size field)
:maxlength (maxlength field))
(progn
;; (inspect field)
(let ((value (if (client-value field)
(client-value field)
ucw::+uninitialized+)))
(<:as-is value)))))
The idea behind is that one can have a read-only and a editable
text-field, the parametrization of the class makes it possible e.g to
emphazise that something is ok or wronr or missing or....
It looks quite nice but there is a small problem:
See the following example code
(defcomponent ir-test (qss-window form-component)
((num :accessor num
:component (integer-range-field :min-value 0 :max-value 20))
(foo-num :accessor foo-num
:type integer-field
:initarg :foo-num
:component (integer-field))
(opt-val :accessor opt-val
:component (select-field :options '('one
'two)))
(a-text-field :accessor a-text-field
:component (text-field :client-value "test"))
(a-val-1 :accessor a-val-1
:component (ucw::attributed-text-field :client-value "100"
:editable nil))
(a-val-2 :accessor a-val-2
:component (ucw::attributed-text-field :client-value "200"
:editable t
:css-class "missing-value"))))
;; (register-application *default-server* *test-app*)
(defentry-point "t1.ucw" (:application *test-app*) ()
(call 'ir-test))
(defmethod render-on ((res response) (tf ir-test))
(render-on res (num tf))
(render-on res (foo-num tf))
(render-on res (opt-val tf))
(render-on res (a-text-field tf))
(render-on res (a-val-1 tf))
(render-on res (a-val-2 tf)))
Well if you look into the sources you'll see taht the text-field is
not wrapped it just is printed as:
><input class="ucw-text-field" maxlength="20" name="cIUYQxMVva"
type="text" value="test"
but if I use the extened attributed-text-field class I got a div around the input
and it looked like this:
/><div class="ucw-text-field"
>100</div
><div class="missing-value"
><input class="missing-value" maxlength="20" name="xgZnLTSOMT" type="text" value="200"
/></div
Of course that is not what I want, but I can not see from where this
div comes.
Am I doing something wrong here or is that some strange bug?
Regards
Friedrich
More information about the bese-devel
mailing list