processUpload(request, response, command, errors, "attachment");
String action = getAction(request);
setSkipAction(false);
T obj = (T) command;
SearchResults results = new SearchResults<T>(pageSize, numLinks);
// perform the action
if (action.equals(UPDATE)) {
showView = getRefreshView();
this.preUpdateAction(request, response, obj, errors);
if (!skipAction)
service.save(obj);
this.postUpdateAction(request, response, obj, errors);
} else if (action.equals(CREATE)) {
showView = getRefreshView();
this.preCreateAction(request, response, obj, errors);
if (!skipAction)
service.save(obj);
this.postCreateAction(request, response, obj, errors);
} else if (action.equals(DELETE)) {
showView = getRefreshView();
this.preDeleteAction(request, response, errors, request
.getParameter(ID));
if (!skipAction)
service.delete(request.getParameter(ID));
this.postDeleteAction(request, response, errors, request
.getParameter(ID));
} else if (action.equals(SEARCH)) {
showView = getSearchView();
this.preSearchAction(request, response, obj, errors);
if (!skipAction) {
long startTime = System.currentTimeMillis();
String strPage = request.getParameter("page");
int currPage = StringUtil.convertToInt(strPage, 1);
results.setCurrPage(currPage);
results.setTotalResults(this.countAction(obj));
int start = results.getStartIndex();
int total = results.getPageSize();
if (supportsPaging) {
if (command == null)
// no command, let's search everything
results.addResults(service.findAll(start, total));
else
// let's do a query by example
results.addResults(service.findByExample(obj,
exactMatch, start, total));
} else if (command == null)
// no command, let's search everything
results.addResults(service.findAll());
else
// let's do a query by example
results.addResults(service.findByExample(obj,
exactMatch));
results.setSearchTime(System.currentTimeMillis()
- startTime);
}
results = this.postSearchAction(request, response, obj, errors,
results);
}