1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.plugins.dbpage.business.section;
35
36 import fr.paris.lutece.plugins.dbpage.business.DbPageHome;
37 import fr.paris.lutece.portal.service.template.AppTemplateService;
38 import fr.paris.lutece.portal.service.util.AppLogService;
39 import fr.paris.lutece.portal.service.util.AppPropertiesService;
40 import fr.paris.lutece.util.html.HtmlTemplate;
41
42 import java.sql.SQLException;
43
44 import java.util.Collection;
45 import java.util.HashMap;
46 import java.util.List;
47 import java.util.Map;
48
49 import javax.servlet.http.HttpServletRequest;
50
51
52
53
54
55 public class DbPageSectionSelect extends DbPageSection
56 {
57
58
59
60 private static final long serialVersionUID = 672960958632821828L;
61 private static final String MARK_SECTION_TITLE = "section_title";
62 private static final String MARK_SELECT_LIST = "list_select";
63 private static final String PROPERTY_FILES_PATH = "dbpage.files.path";
64 private static final String TEMPLATE_DEFAULT_SELECT = "skin/plugins/dbpage/default_select.html";
65 private static final String TEMPLATE_CREATION_SELECT = "admin/plugins/dbpage/create_section_select.html";
66 private static final String TEMPLATE_MODIFICATION_SELECT = "admin/plugins/dbpage/modify_section_select.html";
67 private static final String MARK_VALUE = "value";
68
69
70
71
72
73 public DbPageSectionSelect( String strDescType )
74 {
75 this.setIdTypeSignature( serialVersionUID );
76 this.setDescType( strDescType );
77 }
78
79
80
81
82
83
84
85
86
87
88 public String getHtmlSection( List<String> listValues, HttpServletRequest request )
89 {
90 HashMap rootModel = new HashMap( );
91 rootModel.put( MARK_SECTION_TITLE, getTitle( ) );
92
93 Collection listSelects;
94
95 try
96 {
97 listSelects = DbPageHome.selectRows( getValuatedQuery( listValues ), getConnectionService( getDbPool( ) ) );
98 rootModel.put( MARK_SELECT_LIST, listSelects );
99 for( int i=0;i<listValues.size();i++)
100 {
101 rootModel.put( MARK_VALUE+(i+1), listValues.get(i) );
102 }
103 }
104 catch ( SQLException e )
105 {
106 AppLogService.error( e );
107 }
108
109 if ( getTemplatePath( ).equals( "" ) )
110 {
111
112 HtmlTemplate tSelect = AppTemplateService.getTemplate( TEMPLATE_DEFAULT_SELECT, request.getLocale( ),
113 rootModel );
114
115 return tSelect.getHtml( );
116 }
117 else
118 {
119 String strFilePath = AppPropertiesService.getProperty( PROPERTY_FILES_PATH );
120
121 HtmlTemplate tSelect = AppTemplateService.getTemplate( getTemplatePath( ), strFilePath,
122 request.getLocale( ), rootModel );
123
124 return tSelect.getHtml( );
125 }
126 }
127
128
129
130
131
132 public long getIdType( )
133 {
134 return getIdTypeSignature( );
135 }
136
137
138
139
140
141 public String getTypeDescription( )
142 {
143 return getDescType( );
144 }
145
146
147
148
149
150 public String getCreationTemplate( )
151 {
152 return TEMPLATE_CREATION_SELECT;
153 }
154
155
156
157
158
159 public String getModificationTemplate( )
160 {
161 return TEMPLATE_MODIFICATION_SELECT;
162 }
163
164
165
166
167 public Map<String, Object> getMarkMap( )
168 {
169 Map map = new HashMap( );
170
171 return map;
172 }
173 }