📄 doclistitemtag.java
字号:
package cn.js.fan.module.cms;import javax.servlet.jsp.tagext.*;import org.apache.log4j.Logger;import cn.js.fan.util.StrUtil;import cn.js.fan.util.DateUtil;public class DocListItemTag extends BodyTagSupport{ DocBlockIterator ir; String field; Logger logger = Logger.getLogger(DocListItemTag.class.getName()); String mode = "simple"; int length = -1; public DocListItemTag () { ir = null; } public void setField (String field) { this.field = field; } public void setMode(String m) { this.mode = m; } public void setLength(String l) { if (StrUtil.isNumeric(l)) length = Integer.parseInt(l); } public int doStartTag () { DocListTag dlt = (DocListTag)this.findAncestorWithClass(this,DocListTag.class); if (dlt != null) { ir = dlt.ir; } else { logger.error("get iterator failed!"); } return EVAL_BODY_BUFFERED; } public int doEndTag () { try { if (field!=null && ir!=null && ir.hasNext()) { Document doc = (Document) ir.next(); if (doc==null) { logger.info("doc=null"); return EVAL_PAGE; } String body = ""; if (mode==null || !mode.equals("detail")) { if (length!=-1) body = "<a href='doc_show.jsp?id=" + doc.getID() + "'>" + StrUtil.getLeft(doc.get(field), length) + "</a>"; else body = "<a href='doc_show.jsp?id=" + doc.getID() + "'>" + doc.get(field) + "</a>"; } else { BodyContent bc = getBodyContent(); body = bc.getString(); String t = doc.getTitle(); if (length!=-1) t = StrUtil.getLeft(t, length); if (DateUtil.compare(new java.util.Date(), doc.getExpireDate())==2) { if (doc.isBold()) t = "<B>" + t + "</B>"; if (!doc.getColor().equals("")) { t = "<font color=" + doc.getColor() + ">" + t + "</font>"; } } body = body.replaceAll("\\#title", doc.getTitle()); body = body.replaceAll("\\$title", t); body = body.replaceAll("\\$id", "" + doc.getID()); body = body.replaceAll("\\$hit", "" + doc.getHit()); body = body.replaceAll("\\$modifiedDate", doc.getModifiedDate()); body = body.replaceAll("\\$dirCode", doc.getDirCode()); body = body.replaceAll("\\@dirCode", StrUtil.UrlEncode(doc.getDirCode())); if (doc.getIsNew() == 1) { body = body.replaceAll("\\$isNew", "<img src='images/i_new.gif' width='18' height='7'>"); } else body = body.replaceAll("\\$isNew", ""); } pageContext.getOut().print(body); } } catch (Exception e) { logger.error("doEndTag: " + e.getMessage()); e.printStackTrace(); } return EVAL_PAGE; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -