{:id 1, :name "MyTest" /> {:id 1, :name "MyTest" /> {:id 1, :name "MyTest"/>

Clojure / seeseaw.core/table lazy-seq retrieval failure

73 Views Asked by At

My "(list-projects)" method queries out a map from a SQLITE database.

    (doall (apply prn (pm.models.db/list-projects)))    

pm.core==>{:id 1, :name "MyTestProj", :owner "mbc", :date "2017-12-19 13:12:45"} {:id 2, :name "newproject1", :owner "mbc", :date "2017-12-19 13:12:45"} {:id 3, :name "newproject1", :owner "mbc", :date "2017-12-19 13:12:45"} {:id 4, :name "abc", :owner "def", :date "2017-12-19 13:12:45"} {:id 5, :name "abc", :owner "def", :date "2017-12-19 13:12:45"} {:id 6, :name "abc", :owner "def", :date "2017-12-19 13:12:45"} {:id 7, :name "newproject1", :owner "mbc", :date "2017-12-19 13:12:45"} {:id 8, :name "", :owner "", :date strong text"2017-12-19 13:12:45"}

I would like to populate a seesaw.core/table (a Java JTable) with those results using the :row property when I construct the seesaw.core/frame/mig-panel/table (JFrame/JPanel/JTable).

(def main-panel 
  (mig-panel
  :constraints ["fill, ins 0"]
  :items [[(seesaw.core/table
                  :id :tbl1
                  :size [640 :by 480]
                  :model [:columns [:id :name :owner :date]
                          :rows [(doall (apply prn (pm.models.db/list-projects)))]
                         ]) "grow"]
         ]))

2. Unhandled clojure.lang.Compiler$CompilerException
   Error compiling form-init4108264894568019320.clj at (44:16)
   ang.Thread/run

1. Caused by java.lang.IllegalArgumentException
   row must be a map or vector, got null

If I insert the map {:id 1, :name "MyTestProj", :owner "mbc", :date "2017-12-19 13:12:45"} {:id........}{}{}{}{} directly, it works fine, rows in the table are properly populated, so format of the output of (doall (apply prn (pm.models.db/list-projects))) is what I need.

How do I retrieve the (I presume) lazy-seq in the context of a seesaw.core/mig-panel? Thanks Mortimer

1

There are 1 best solutions below

0
Mortimer Cladwell On BEST ANSWER
pm.core> (pm.models.db/list-projects)
({:id 1, :name "MyTestProj", :owner "mbc", :date "2017-12-19 13:12:45"} {:id 2, :name "newproject1", :owner "mbc", :date "2017-12-19 13:12:45"} {:id 3, :name "newproject1", :owner "mbc", :date "2017-12-19 13:12:45"} {:id 4, :name "abc", :owner "def", :date "2017-12-19 13:12:45"} {:id 5, :name "abc", :owner "def", :date "2017-12-19 13:12:45"} )
pm.core> 

(pm.models.db/list-projects) results in a list that can be used directly as the value for the :rows key (no brackets). :rows (pm.models.db/list-projects)

Thanks to Carcigenicate for the suggestions.