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

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