source: trunk/grails-app/taglib/dbnp/importer/ImporterTagLib.groovy @ 169

Last change on this file since 169 was 169, checked in by tabma, 13 years ago
  • created taglibrary for importer and first implementation detection of (cell) datatypes
  • Property svn:keywords set to Date Author Rev
File size: 1.5 KB
Line 
1/**
2 * Importer tag library
3 *
4 * The importer tag library gives support for automating several 'components'
5 *
6 * @package     importer
7 * @author      t.w.abma@umcutrecht.nl
8 * @since       20100202
9 *
10 * Revision information:
11 * $Rev: 169 $
12 * $Author: tabma $
13 * $Date: 2010-02-03 14:50:14 +0000 (wo, 03 feb 2010) $
14 */
15
16package dbnp.importer
17
18class ImporterTagLib {
19    static namespace = 'importer'
20
21    /**
22    * @param header string array containing header
23    * @param datamatrix two dimensional array containing actual data
24    * @return preview of the data with the ability to adjust the datatypes
25    */
26    def preview = { attrs ->
27       
28        def header = attrs['header']
29        def datamatrix = attrs['datamatrix']
30
31        out << render (template:"common/preview", model:[header:header, datamatrix:datamatrix])
32    }
33
34    /**
35    * @param selected selected celltype
36    * @param name name of the HTML select object
37    * @param celltypes built-in cell types, based on the cell type
38    * @see org.apache.poi.ss.usermodel.Cell
39    * @return HTML select object
40    */
41    def celltypeselector = { attrs ->
42        def selected = attrs['selected']
43        def name = attrs['name']
44        def celltypes = [[celltype:0, name:"Numeric"], [celltype:1, name:"String"], [celltype:2, name:"Formula"],
45                         [celltype:3, name:"Blank"], [celltype:4, name:"Boolean"], [celltype:5, name:"Error"]]
46
47        def res = "<select name=\"${name}\">"
48
49        celltypes.each { c ->
50            res += "<option value=\"${c.celltype}\""
51            res += (c.celltype == selected) ? " selected" : ""
52            res += ">${c.name}</option>"
53        }
54
55        res += "</select>"
56
57        out << res
58    }
59
60}
Note: See TracBrowser for help on using the repository browser.