[Bese-devel] Adding a new slot-presentation

Aycan iRiCAN aycan.irican at core.gen.tr
Fri Jan 27 14:32:36 UTC 2006


Hi,

I wanted to make a textarea with a javascript wysiwyg editor (tinymce) for a simple
content editing task. 

I have a simple content class in my package:

(defclass content ()
  ((title :accessor title
	  :initarg :title
	  :initform "Sample Title"
	  :documentation "Title for content")
   (data :accessor data
	 :initarg :data
	 :initform "Data"
	 :documentation "Data for content")))

For the presentation of the title slot, string-slot-presentation
is enough. So I defined it's type as "string". But for the data
slot, I need a textarea presentation. So I defined a new type
that is also in my package:

(defpresentation content-editor (object-presentation)
  ((string :label "Title" :slot-name 'title :max-length 30 :editablep nil)
   (text-content :label "Content" :slot-name 'data :editablep nil)))

To register the new type we need a defslot-presentation. Here it is:

(ucw::defslot-presentation text-content-slot-presentation ()
  ((cols :accessor cols :initarg :cols :initform 40)
   (rows :accessor rows :initarg :rows :initform 20))
  (:type-name text-content))

Finally I defined present-slot method:

(defmethod present-slot ((slot text-content-slot-presentation) instance)
  (if (editablep slot)
      (progn
	(<ucw:textarea :cols (cols slot) :rows (rows slot) :accessor (presentation-slot-value slot instance))
;;;; TODO: fix wwwroot and proper install jscript
	(<:as-is "<script language=\"javascript\" type=\"text/javascript\" src=\"http://www.core.gen.tr/tinymce/jscripts/tiny_mce/tiny_\mce.js\"> </script>")
	(<:as-is "<script language=\"javascript\" type=\"text/javascript\"> tinyMCE.init({ mode : \"textareas\" }); </script>"))
      (<:as-is (presentation-slot-value slot instance))))

Now the problem is I'm getting an error:

Execution of a form compiled with errors. 
Form: 
(SLOT-PRESENTATIONS 
 (STRING LABEL Title SLOT-NAME 'TITLE MAX-LENGTH 30 EDITABLEP NIL) 
 (TEXT-CONTENT LABEL Content SLOT-NAME 'DATA EDITABLEP NIL)) 

Compile-time-error: 
(in macroexpansion of (SLOT-PRESENTATIONS # #)) 
(hint: For more precise location, try *BREAK-ON-SIGNALS*.) Unknown
slot type TEXT-CONTENT.

This is probably because text-content is defined in ucw
package. What is the proper way to add new slot-presentations?

Best Regards,

-- 
Aycan iRiCAN
C0R3 Computer Security Group
http://www.core.gen.tr
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/bese-devel/attachments/20060127/aac8d0fe/attachment.sig>


More information about the bese-devel mailing list