IndexNews.java~67~
上传用户:zghglow
上传日期:2022-08-09
资源大小:27227k
文件大小:6k
源码类别:

WEB源码(ASP,PHP,...)

开发平台:

JavaScript

  1. package com.chinacannel.xlchemical.Tag;
  2. import java.util.*;
  3. import javax.servlet.jsp.*;
  4. import javax.servlet.jsp.tagext.*;
  5. import com.chinacannel.entity.*;
  6. import com.chinacannel.xlchemical.service.*;
  7. import java.text.SimpleDateFormat;
  8. public class IndexNews extends TagSupport  {
  9.     private Long menuID = new Long(0);
  10.     private String webPath = "";
  11.     public int doStartTag() throws JspException {
  12.         try {
  13.             MenuService ms = new MenuService();
  14.             InformationService is = new InformationService();
  15.             Information imageInfo = null;
  16.             Menu menu = null;
  17.             ms.beginTran();
  18.             menu = ms.GetMenuById(this.getMenuID());
  19.             String Language = "CN";
  20.             String more = "";
  21.             if(menu != null){
  22.                 imageInfo = is.GetIndexImgInformationByMenu(menu);
  23.                 List list = is.GetIndexInformation(menu);
  24.                 ms.commit();
  25.                 String title = "";
  26.                 String time = "";
  27.                 String summary = "";
  28.                 StringBuilder sb = new StringBuilder();
  29.                 sb.append("<table width="287" border="0" cellspacing="0" cellpadding="0">" + "n");
  30.                 sb.append("<tr><td><table width="100%" border="0" cellspacing="0" cellpadding="0">" + "n");
  31.                 sb.append("<tr><td width="4%">&nbsp;</td>" + "n");
  32.                 sb.append("<td width="96%"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>" + "n");
  33.                 sb.append("<td width="84%" class="Title"><img src="images/Index_PD_Title.jpg" width="11" height="9"> " + menu.getMen_Name() + "</td>" + "n");
  34.                 if(menu.getMen_Language().equals("CN")){
  35.                     more = ":";
  36.                 }
  37.                 sb.append("<td width="16%"><a href="" + this.getWebPath() + "/Index.do?todo=OpenIndexMenu&fMenuID=" + menu.getMen_Superior() + "&cMenuID=" + menu.getMen_ID() + "">" + more + "&gt;&gt;</a></td></tr></table></td></tr>" + "n");
  38.                 sb.append("<tr><td height="4" bgcolor="FE0000"></td><td height="4" bgcolor="E9E9E9"></td></tr></table></td></tr>" + "n");
  39.                 sb.append("<tr><td height="133" valign="top" style="padding-top:;">" + "n");
  40.                 sb.append("<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="E9E9E9">" + "n");
  41.                 if(imageInfo != null){
  42.                     sb.append("<tr><td width="29%" style="padding:5px;"><img src="" + imageInfo.getImage().getPath() + "/" + imageInfo.getImage().getReallyname() + "" width="79" height="62" alt="" /></td>" + "n");
  43.                 }else{
  44.                     sb.append("<tr><td width="29%" style="padding:5px;"><img src="" width="79" height="62" alt="" /></td>" + "n");
  45.                 }
  46.                 sb.append("<td width="71%"><table width="100%" border="0" cellspacing="0" cellpadding="0">" + "n");
  47.                 if (imageInfo != null) {
  48.                     if (imageInfo.getInf_Title().length() > 6) {
  49.                         title = imageInfo.getInf_Title().substring(0, 6);
  50.                     } else {
  51.                         title = imageInfo.getInf_Title();
  52.                     }
  53.                     title = "<a href='" + this.getWebPath() +
  54.                             "/Index.do?todo=OpenInfo&infID=" +
  55.                             imageInfo.getInf_ID() + "&type=" +
  56.                             imageInfo.getMenu().getMen_Type() + "&fMenuID=" +
  57.                             imageInfo.getMenu().getMen_Superior() + "'>" + title +
  58.                             "</a>";
  59.                 }
  60.                 sb.append("<tr><td width="50%"><strong>" + title + "</strong></td>" + "n");
  61.                 if (imageInfo != null) {
  62.                     time = new SimpleDateFormat("yyyy-MM-dd").format(imageInfo.
  63.                             getInf_Time());
  64.                 }
  65.                 sb.append("<td width="50%" class="Date">[" + time +
  66.                           "]</td></tr>" + "n");
  67.                 if (imageInfo != null) {
  68.                     if (imageInfo.getInf_Summary().length() > 20) {
  69.                         summary = imageInfo.getInf_Summary().substring(0, 20);
  70.                     } else {
  71.                         summary = imageInfo.getInf_Summary();
  72.                     }
  73.                 }
  74.                 sb.append("<tr><td colspan="2">" + summary + "...</td></tr></table></td></tr></table>" + "n");
  75.                 sb.append("<table width="100%" border="0" cellspacing="0" cellpadding="0">" + "n");
  76.                 for (int i = 0; i < list.size(); i++) {
  77.                     Information inf = (Information) list.get(i);
  78.                     sb.append("<tr><td width="6%"><img src="images/Ft.jpg" width="8" height="9" alt="" /></td>" + "n");
  79.                     String s = "";
  80.                     if (inf.getInf_Title().length() > 20) {
  81.                         s = inf.getInf_Title().substring(0, 20) + "...";
  82.                     } else {
  83.                         s = inf.getInf_Title();
  84.                     }
  85.                     sb.append("<td width="94%"><a href="" + this.getWebPath() +
  86.                               "/Index.do?todo=OpenInfo&infID=" + inf.getInf_ID() +
  87.                               "&type=" + inf.getMenu().getMen_Type() +
  88.                               "&fMenuID=" + inf.getMenu().getMen_Superior() +
  89.                               "" class="News_Link">" + s + "</a></td></tr>" +
  90.                               "n");
  91.                 }
  92.                 sb.append("</table><table width="100%" border="0" cellspacing="0" cellpadding="0">" + "n");
  93.                 sb.append("<tr><td height="2" bgcolor="E4E4E4"></td></tr></table></td></td></table>" + "n");
  94.                 JspWriter out = pageContext.getOut();
  95.                 out.print(sb.toString());
  96.             }else{
  97.                 JspWriter out = pageContext.getOut();
  98.                 out.print("");
  99.             }
  100.         } catch (Exception e) {
  101.             throw new JspException(e);
  102.         }
  103.         return 0;
  104.     }
  105.     public String getWebPath() {
  106.         return webPath;
  107.     }
  108.     public Long getMenuID() {
  109.         return menuID;
  110.     }
  111.     public void setWebPath(String webPath) {
  112.         this.webPath = webPath;
  113.     }
  114.     public void setMenuID(Long menuID) {
  115.         this.menuID = menuID;
  116.     }
  117. }