43
43
import java .util .List ;
44
44
import java .util .Map ;
45
45
46
- import jakarta .enterprise .context .SessionScoped ;
46
+ import jakarta .enterprise .context .RequestScoped ;
47
+ import jakarta .inject .Inject ;
47
48
import jakarta .inject .Named ;
48
49
import jakarta .servlet .http .HttpServletRequest ;
49
50
import javax .xml .parsers .SAXParser ;
76
77
import fr .paris .lutece .portal .web .constants .Messages ;
77
78
import fr .paris .lutece .portal .web .constants .Parameters ;
78
79
import fr .paris .lutece .portal .web .upload .MultipartHttpServletRequest ;
79
- import fr .paris .lutece .portal .web .util .LocalizedPaginator ;
80
+ import fr .paris .lutece .portal .web .util .IPager ;
81
+ import fr .paris .lutece .portal .web .util .Pager ;
80
82
import fr .paris .lutece .util .ReferenceList ;
81
83
import fr .paris .lutece .util .file .FileUtil ;
82
- import fr .paris .lutece .util .html .AbstractPaginator ;
83
84
import fr .paris .lutece .util .html .HtmlTemplate ;
84
85
import fr .paris .lutece .util .sort .AttributeComparator ;
85
86
86
87
/**
87
88
* This class provides the user interface to manage StyleSheet features
88
89
*/
89
- @ SessionScoped
90
+ @ RequestScoped
90
91
@ Named
91
92
public class StyleSheetJspBean extends AdminFeaturesPageJspBean
92
93
{
@@ -110,8 +111,6 @@ public class StyleSheetJspBean extends AdminFeaturesPageJspBean
110
111
private static final String MARK_STYLESHEET_LIST = "stylesheet_list" ;
111
112
private static final String MARK_STYLE_LIST = "style_list" ;
112
113
private static final String MARK_STYLESHEET = "stylesheet" ;
113
- private static final String MARK_PAGINATOR = "paginator" ;
114
- private static final String MARK_NB_ITEMS_PER_PAGE = "nb_items_per_page" ;
115
114
private static final String MARK_PORTAL_COMPONENT_NAME = "portal_component_name" ;
116
115
private static final String MARK_PORTLET_TYPE_NAME = "portlet_type_name" ;
117
116
private static final String MARK_STYLE_DESCRIPTION = "style_description" ;
@@ -131,9 +130,11 @@ public class StyleSheetJspBean extends AdminFeaturesPageJspBean
131
130
private static final String LABEL_ALL = "portal.util.labelAll" ;
132
131
private static final String JSP_DO_REMOVE_STYLESHEET = "jsp/admin/style/DoRemoveStyleSheet.jsp" ;
133
132
private static final String JSP_REMOVE_STYLE = "RemoveStyle.jsp" ;
134
- private int _nItemsPerPage ;
135
- private String _strCurrentPageIndex ;
136
133
134
+ @ Inject
135
+ @ Pager ( listBookmark = MARK_STYLESHEET_LIST , defaultItemsPerPage = PROPERTY_STYLESHEETS_PER_PAGE )
136
+ private IPager <StyleSheet , Void > pager ;
137
+
137
138
/**
138
139
* Displays the stylesheets list
139
140
*
@@ -165,11 +166,9 @@ public String getManageStyleSheet( HttpServletRequest request )
165
166
boolean bIsAscSort = Boolean .parseBoolean ( strAscSort );
166
167
167
168
Collections .sort ( listStyleSheets , new AttributeComparator ( strSortedAttributeName , bIsAscSort ) );
169
+
168
170
}
169
-
170
- int defaultItemsPerPage = AppPropertiesService .getPropertyInt ( PROPERTY_STYLESHEETS_PER_PAGE , 50 );
171
- _strCurrentPageIndex = AbstractPaginator .getPageIndex ( request , AbstractPaginator .PARAMETER_PAGE_INDEX , _strCurrentPageIndex );
172
- _nItemsPerPage = AbstractPaginator .getItemsPerPage ( request , AbstractPaginator .PARAMETER_ITEMS_PER_PAGE , _nItemsPerPage , defaultItemsPerPage );
171
+ pager .setList ( listStyleSheets );
173
172
174
173
String strURL = getHomeUrl ( request );
175
174
@@ -182,16 +181,14 @@ public String getManageStyleSheet( HttpServletRequest request )
182
181
{
183
182
strURL += ( "&" + Parameters .SORTED_ASC + "=" + strAscSort );
184
183
}
184
+ pager .setBaseUrl ( strURL );
185
185
186
- LocalizedPaginator <StyleSheet > paginator = new LocalizedPaginator <>( listStyleSheets , _nItemsPerPage , strURL , AbstractPaginator .PARAMETER_PAGE_INDEX ,
187
- _strCurrentPageIndex , getLocale ( ) );
188
-
186
+ Map <String , Object > pagerModel = pager .getPaginatedListModel ( request , getLocale () );
187
+
189
188
Map <String , Object > model = new HashMap <>( );
190
189
model .put ( MARK_MODE_ID , strModeId );
191
- model .put ( MARK_NB_ITEMS_PER_PAGE , "" + _nItemsPerPage );
192
- model .put ( MARK_PAGINATOR , paginator );
193
- model .put ( MARK_STYLESHEET_LIST , paginator .getPageItems ( ) );
194
190
model .put ( MARK_MODE_LIST , listModes );
191
+ model .putAll ( pagerModel );
195
192
196
193
HtmlTemplate template = AppTemplateService .getTemplate ( TEMPLATE_MANAGE_STYLESHEETS , getLocale ( ), model );
197
194
0 commit comments