 (defroute home-path "/" []
   (let [onres (fn [json]
                 (let [dt (getdata json)]
-                  (reset! documents (.-data dt))
-                  (r/render [render-documents @documents]
+                  (set-key-value :documents (.-data dt))
+                  (r/render [render-documents (get-value! :documents)]
                             (.getElementById js/document "app1"))
-                  (r/render [shared-state (get-total-rec-no
-                                           (.-totaldocuments(first
-                                                             (.-totaldocuments dt))))]
-                            (.getElementById js/document "pindex"))))]
+                  (r/render [shared-state 0]
+                            (.getElementById js/document "pindex"))
+                  (set-key-value :total-pages (get-total-rec-no
+                                               (.-totaldocuments(first
+                                                                 (.-totaldocuments dt)))))))]
     (http-get "http://localhost:8193/documents/paging/1/10" onres)))
 
 (defroute documents-path "/documents/add" []

  (:import goog.History
           goog.json.Serializer))

(def documents (r/atom nil))

(def document (r/atom {}))

(defn get-total-rec-no [nos]
  (let [totrec (quot nos 10)]

(defn getd [indexNo]
  (let [onres (fn [json]
                (let [d (.-data (getdata json))]
                  (set-key-value :documents d)
                  (r/render [render-documents (get-value! :documents)]
                            (.getElementById js/document "app1"))))]
    (http-get (str (str "http://localhost:8193/documents/paging/" indexNo) "/10") onres)))

(defn pager [value total-rec]
  [pager-elem {:bsSize "large"
               :prev true
               :next true
               :first true
               :last true
               :ellipsis true
               :items (:total-pages @storage)
               :activePage (:current-page @storage)
               :maxButtons 5
               :onSelect (fn [s1 s2]
                           (let [i (.-eventKey s2)]
                             (getd i)
                             (set-key-value :current-page i)))}])


(defn shared-state [totalRec]
