Dynamic menu

32 views
Skip to first unread message

iri...@gmail.com

unread,
Aug 31, 2012, 6:05:51 AM8/31/12
to webl...@googlegroups.com
Hello,

i want to rewrite a php/mysql app with weblocks.

I'm a beginner, so i ask beginner questions.

First i start with weblocks-clsql-demo.

I want to make a page with two part :

1) a menu 'Company'
Menu items will be name companies

2) Employees of the selected company or blank if the company has no employees


Do i have to use navigation widget to the menu (which is not static)?
Can i use an existing view class to get data from DB or create a specific one ?
Which code can i read to learn about this question ?

Thanks,

(i apologize about my english)
--
Fred


iri...@gmail.com

unread,
Aug 31, 2012, 10:54:22 AM8/31/12
to webl...@googlegroups.com
I replaced some code in the layout.lisp file (weblocks-clsql-demo package) (see below),
and it works partially :
within the same session, if i add a new company, the menu is not refreshed,
i need to reset the session.

My Questions :
1) Use of "find-persistent-objects" is it the right way ?
2) How to refresh the menu without reset the session ?

(defun make-company-page (company)
  (make-instance 'composite :widgets
                 (list
                  (lambda ()
                    (with-html (:p "Company data")
                               (:ul
                                (:li "Name : " (str (company-name company)))
                                (:li "ID : " (str (company-id company)))))))))


(defun make-main-page ()
  "Lays out the main page. It consists of a FLASH widget for showing                                                                                                                                                                                                         
initial message, and a NAVIGATION widget with panes that hold                                                                                                                                                                                                                
employees page and companies page."
  (make-instance 'composite :widgets
                 (list
                  (make-instance 'flash :messages
                                 (list "Welcome to weblocks demo - a                                                                                                                                                                                                         
                                       technology demonstration for a                                                                                                                                                                                                        
                                       continuations-based web                                                                                                                                                                                                               
                                       framework written in Common                                                                                                                                                                                                           
                                       Lisp."))
                  (let ((companies (weblocks:find-persistent-objects (class-store 'company) 'company)))
                    (if companies
                      (apply #'make-navigation
                             (cons 'main-menu
                                   (loop for comp in companies
                                      append (list
                                              (company-name comp)
                                              (make-company-page comp)))))
                      "")))))


                  ;; (make-navigation 'main-menu                                                                                                                                                                                                                             
                  ;;               'employees (make-employees-page)                                                                                                                                                                                                          
                  ;;               'companies (make-companies-page)))))                                                                                                                                                                                                      


thanks
--
Fred
Reply all
Reply to author
Forward
0 new messages