Hi guys,
I'm trying to define a "PHONE" presentation, to store phone numbers as
a string, but display them is Australian format.
I've defined the classes & methods below - but in a gridedit, none of
this seems to be working.
i.e. phone numbers are displayed without formatting, parser is not
called, error message on invalid input defaults to the standard
message "Please enter a value", and so forth.
Any ideas what I'm missing?
(deftype phone ()
'string)
(defclass phone-printer ()
())
(defclass phone-presentation (phone-printer text-presentation)
())
(defclass phone-input-presentation (phone-printer input-presentation)
())
(defclass phone-parser (text-parser)
())
(defmethod parser-error-message ((parser phone-parser))
"Please enter a valid phone number")
(defmethod typespec->view-field-presentation (scaffold (typespec (eql
'phone)) args)
(declare (ignore args scaffold))
(values t (make-instance 'phone-presentation)))
(defmethod typespec->form-view-field-parser ((scaffold form-scaffold)
(typespec (eql 'phone)) args)
(declare (ignore args))
(values t (make-instance 'phone-parser :error-message "Please enter
a valid phone number")))
(defmethod print-view-field-value (value (self phone-printer) field
view widget obj &rest args)
(declare (ignore field view widget obj args))
(format nil "~A-~A-~A" (subseq value 0 4) (subseq value 4 7) (subseq
value 7)))
(defmethod parse-view-field-value ((parser phone-parser) value obj
view field &rest args)
(declare (ignore obj view field args))
(let ((phone (remove-if-not #'digit-char-p value)))
(values t (= (length phone) 10) (string/= phone "") phone)))
Adam
--
You received this message because you are subscribed to the Google Groups
"weblocks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/weblocks?hl=en.