Selector inside widget

9 views
Skip to first unread message

Scott Helvick

unread,
May 15, 2011, 2:51:34 PM5/15/11
to webl...@googlegroups.com
I'm trying to write a custom widget containing a navigation widget, e.g. for tabbed panel navigation.  But when I do this, I'm having trouble getting the actual panes to display.  Does anyone have some example code with a custom widget containing a nav or selector?  TIA.

radisb

unread,
Jul 7, 2011, 3:18:25 AM7/7/11
to webl...@googlegroups.com
I am doing it without nav or selector, by delegating the creation of pane titles and the active pane content to external code. In pseudo code:

(defwidget dynamic-tabs()
   (pane-titles-fn)   ;; e.g '((1 . "employees") (2 . some-widget))
   (active-pane-id)
   (active-pane-content-fn)

(defmethod render-widget-body  ((self dynamic-tab))
   
   (with-html
       (dolist (title (funcall (pane-titles self)))
           (if (equal (active-pane-id self) (car title))               
              (:span (cdr title))                                   
              (render-link (lambda (title) (setf (active-pane-id self) (car title)) (cdr title)))    
      (setf (widget-children self) (funcall (active-pane-content-fn self) (car title)))


I know there is a lot of indirection but it suit my specific needs. PRoblem is that the url reflects nothing of this, which I dont need, so I dont consider it a generic solution.
Also instead of 
      
(if (equal active-pane-id (car title))               
              (:span (cdr title))                                   
              (render-link (lambda (title) (setf (active-pane-id self) (car title)) (cdr title)))    

you could have 
  (if (equal active-pane-id (car title))               
       (render-active title)                                   
       (render-other title self)
so that you can have whole widgets as titles,
taking care to render a link that will setf the active pane of the parent somewhere in render-other in order to be able to switch panes. (thats why I pass self as an argument). 


   


Reply all
Reply to author
Forward
0 new messages