0

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

  • You don't need `doall`. The panel will need to realize the list to use it (not the problem here though). – Carcigenicate Dec 19 '17 at 17:04
  • And you probably shouldn't have the `:rows` wrapped in a vector if you expect `(apply prn` to evaluate to a list of rows. I wouldn't expect that to cause that error, but if strikes me as wrong. If should probably be just `:rows (apply prn (pm.models.db/list-projects))`. – Carcigenicate Dec 19 '17 at 17:12
  • 1
    Thanks for the hints. The solution is :rows (pm.models.db/list-projects) mig-panel requires vector or map, I can use the vector queried out directly. – Mortimer Cladwell Dec 19 '17 at 17:50

1 Answers1

1
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.