{
PreferencesManager preferencesManager = (PreferencesManager) SpringTools.getBean(PreferencesManager.ID);
String currentUserName = UserTools.getCurrentUserName(request);
Integer currentUserId = UserTools.getCurrentUserId(request);
ListContext context = new ListContext();
context.setRequest(request);
context.setListing(listing);
context.setUserName(currentUserName);
context.setUserEnvironment(UserTools.getUserEnvironment(request));
java.util.List configPath = getDerivationPath();
if (request.getParameter("recordsPerPage") != null)
{
int prefRows = preferencesManager.getInt(currentUserId, "gui", "tableRowsPerPage", 15);
context.setResultsPerPage(NumberTools.toInt(request.getParameterAsString("recordsPerPage"), prefRows));
}
else
{
int prefRecordsPerPage = preferencesManager.getInt(currentUserId, "gui", "tableRowsPerPage", 15);
context.setResultsPerPage(ModelTools.getConfigInt(configPath, "recordsPerPage", prefRecordsPerPage));
}
context.setNumPrevPages(ModelTools.getConfigInt(configPath, "numPrevPages", 4));
context.setNumNextPages(ModelTools.getConfigInt(configPath, "numNextPages", 4));
context.setListName(request.getParameterAsString("listId"));
if (StringTools.isEmpty(context.getListName()))
{
context.setListName(ModelTools.getConfigString(configPath, "listId", "list"));
}
context.setDescribe(NumberTools.toBool(request.getParameterAsString("describe"), false));
context.setPage(listing.getPage());
context.setFirstResult((context.getPage() - 1) * context.getResultsPerPage());
return context;
}