use of com.web.framework.common.wrapper.ElementTagWrapper in project spring-boot-web by wangchengming666.
the class AbstructTableProcessor method doProcess.
/**
* <tr fwk:role="" id="11" var="it">
*/
@Override
protected void doProcess(ITemplateContext context, IProcessableElementTag tag, AttributeName attributeName, String attributeValue, IElementTagStructureHandler structureHandler) {
WebEngineContext _context = null;
if (context instanceof WebEngineContext) {
_context = (WebEngineContext) context;
}
ElementTagWrapper tagHelper = new ElementTagWrapper(tag);
String iterableName = tagHelper.getString("_var", "it");
String statName = tagHelper.getString("_stat", "stat");
String varPageName = tagHelper.getString("_page", "page");
Long count = tagHelper.getLong("_count", 10);
Long index = tagHelper.getLong("_index", 1);
String[] asc = tagHelper.getStringArray("_asc");
String[] desc = tagHelper.getStringArray("_desc");
Page page = new Page(index, count);
page.setAsc(asc);
page.setDesc(desc);
IPage resultPage = tableProcess(context, tagHelper, page, structureHandler);
structureHandler.iterateElement(iterableName, statName, resultPage.getRecords());
structureHandler.removeAttribute("_var");
structureHandler.removeAttribute("_stat");
// XXX 可能有更好的方法
if (_context.getRequest().getAttribute(varPageName) != null) {
logger.warn("当前页码,存在同名的page变量名,自动+1");
String number = StringUtils.substringAfterLast(varPageName, "_");
if (StringUtils.isBlank(number)) {
_context.getRequest().setAttribute(varPageName + "_1", resultPage);
} else {
_context.getRequest().setAttribute(varPageName + "_" + Integer.parseInt(number) + 1, resultPage);
}
} else {
_context.getRequest().setAttribute(varPageName, resultPage);
}
}
Aggregations