setPagingInfo(...) 추가

master
mjkhan21 12 months ago
parent 3352eb3541
commit 89c9994f0f

@ -5,6 +5,7 @@ import java.io.FileInputStream;
import java.io.InputStream;
import java.net.URLEncoder;
import java.util.Collection;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
@ -141,6 +142,44 @@ public abstract class AbstractController extends AbstractComponent {
.addObject(prefix + "Total", bounded.getTotalSize());
}
/**ModelAndView list .<br />
* <code>setPagingInfo(mav, list, "prefix")</code>
* mav .
* <pre><code>{
* "prefixList": list,
* "prefixPagingInfo": {
* "start": list.getStart(),
* "fetchSize": list.getFetchSize(),
* "totalSize": list.getTotalSize()
* }
* }</code></pre>
* @param mav ModelAndView
* @param collection Collection
* @param prefix
* @return ModelAndView
*/
protected ModelAndView setPagingInfo(ModelAndView mav, Collection<?> collection, String prefix) {
if (collection instanceof BoundedList) {
BoundedList<?> bounded = (BoundedList<?>)collection;
Map<String, Object> map = Map.of(
"start", bounded.getStart(),
"totalSize", bounded.getTotalSize(),
"fetchSize", bounded.getFetchSize()
);
mav.addObject(prefix + "List", bounded)
.addObject(prefix + "PagingInfo", map);
} else {
Map<String, Object> map = Map.of(
"start", 0,
"totalSize", collection.size(),
"fetchSize", collection.size()
);
mav.addObject(prefix + "List", collection)
.addObject(prefix + "PagingInfo", map);
}
return mav;
}
/** .<br />
* <ul><li>fetchAll true </li>
* <li>

Loading…
Cancel
Save