JspÒ³ÃæÁбí×é¼þ¿ò¼ÜÉè¼Æ

¿ª·¢ÕßÔÚÏß Builder.com.cn ¸üÐÂʱ¼ä:2007-11-25×÷Õߣºbuilder.com.cn À´Ô´:À´Ô´ÍøÕ¾

±¾ÎĹؼü´Ê£º JSP

JspÒ³ÃæÁбí×é¼þ¿ò¼ÜÉè¼Æ

                ×÷ÕߣºÀî¿¡½Ü

¸ÅÊö

ΪÁËÌá¸ß¿ª·¢Ð§ÂÊ£¬¼õÉÙÖØ¸´µÄÒ³Ãæ¶à´Î¿ª·¢£¬Ìá¸ßϵͳµÄ¿ÉÅäÖÃÐԺʹúÂëµÄ¿É¸´ÓÃÐÔ£¬Ò²ÊÇΪÁËչʾstruts¡¢hibernate¿ò¼Ü£¬Éè¼ÆÔ­ÔòÊǽµµÍÏÔʾÂß¼­ºÍÊý¾ÝµÄñîºÏ£¬´ïµ½ÏÔʾÂß¼­ºÍÊý¾ÝÍêÈ«·ÖÀ룬¼´ÏàͬµÄÊý¾ÝʹÓò»Í¬µÄÏÔʾÂß¼­£¬ÎÞÐëÐÞ¸ÄÏÔʾÂß¼­£¬Ö»ÐèÖû»²»Í¬µÄÏÔʾģ°æ¼´¿É¡£

ʵÏÖ»úÖÆ

ÆäÖÐSturts  ActionÊǾßÌåµÄÐèÒªµ÷ÓÃÁбíµÄActionÀ࣬TempDataMapÀàÊǾßÌåµÄÁбíÊý¾ÝµÄ·â×°À࣬TempDataÀàÊǾßÌåµÄ±í¼Ç¼À࣬¼´TempDataMapÀ´ÊÊÅäTempData£¬°Ñ±í¼Ç¼ÊÊÅä³ÉÎÒÃÇÐèÒªµÄÁбíÏÔʾÀà¡£

µ÷ÓÃʾÀý£º

Action£º

 

//»ñÈ¡Êý¾Ý¿âÊý¾Ý

listRowCount  = query.findPayItemByParam(paramInfo,paramForm.getPageSize(),paramForm.getPageNo());

                     list = listRowCount.getList();

//µ÷ÓÃÁбí×é¼þ

if(list != null && list.size() > 0)

ColDataMgr    mgr = new ColDataMgr(getDataMaps(list));

//»ñÈ¡ÁбíµÄ±íÁÐÐÅÏ¢£¬Êý¾ÝÐÅÏ¢

ArrayList colMetaInfos = mgr.getColMetaInfos();

ArrayList datas = mgr.getData();

// ½«ÁбíÐÅÏ¢´«µ½ListÒ³Ãæ

                     request.setAttribute(CoreConstant.WEB_DISPLAY_COL_METAT_INFOS_KEY, colMetaInfos);

                     request.setAttribute(CoreConstant.WEB_DISPLAY_DATAS_KEY, datas);

 

ͬÑùµÀÀí£¬¸ø³öµÄÊý¾Ý¿ÉÒÔ·Ö·¢¸ø´òÓ¡×é¼þºÍµ¼³öexcelÁбí×é¼þ£¬¸ù¾ÝÁбíµÄÁÐÐÅÏ¢ºÍÊý¾ÝÐÅÏ¢£¬µ¼³öexcelºÍ´òÓ¡¡£

 

¾ßÌåµÄmapÀàµÄÄÚÈݿɲÎÕÕ¸½¼þReceiveItemAmountQueryMap.javaÎļþ¡£

»ñÈ¡ÏÔʾÁÐÐÅÏ¢£º

/**

  *·µ»ØµÄlistÖÐÿ¸öÔªËØÊÇÁÐÔªÐÅÏ¢Àà¶ÔÏó£¬ÁÐÔªÐÅÏ¢Àà¶ÔÏó°üÀ¨ÁÐÃû³Æ£¬ÁÐÏÔʾÃû³Æ£¬

  *ÁÐÏÔʾ¸ñʽ£¬ÆäÖÐÁÐÃû³ÆÊÇkey

  * µ¼³öexcelºÍ´òÓ¡ÊÇͬÑùµÄµÀÀí

  */

public ArrayList getColMetaInfos()

       {

 

              ArrayList list = new ArrayList();

              list.add(new ColMetaInfo("transCode", " µ¥¾Ý±àºÅ ", true, "height="20" align="center" nowrap"));

              list.add(new ColMetaInfo("transDate", " µ¥¾ÝÈÕÆÚ ", false, "height="20" align="center" nowrap"));

              list.add(new ColMetaInfo("transTypeName", " ÒµÎñÀàÐÍ ", false, "height="20" align="left" nowrap"));

              list.add(new ColMetaInfo("receiveOrgName", " Êտλ ", false, "height="20" align="left" nowrap"));

              list.add(new ColMetaInfo("receiveAccountNo", " ÊÕ¿îÕË»§ºÅ ", false, "height="20" align="center" nowrap"));

              list.add(new ColMetaInfo("receiveBankName", " ÊÕ¿îÒøÐÐ ", false, "height="20" align="left" nowrap"));

              list.add(new ColMetaInfo("extAccountNo", " ¸¶¿îÕË»§ ", false, "height="20" align="center" nowrap"));

              list.add(new ColMetaInfo("extBankName", " ¸¶¿îÒøÐÐ ", false, "height="20" align="left" nowrap"));

              list.add(new ColMetaInfo("amount", " ½ð    ¶î ", false, "height="20" align="right" nowrap"));

              list.add(new ColMetaInfo("memo", " Õª    Òª ", false, "height="20" align="left" nowrap"));

             

              return list;

       }

//ÊÊÅäÊý¾Ý£¬¸ù¾ÝÊý¾ÝµÄÀàÐÍÈçÈÕÆÚÐÍ£¬×°»»³ÉÐèÒªµÄ×Ö·û´®ÐÎʽ£¬½ð¶îÀàÊý¾ÝҲת»»³ÉÏà//Ó¦µÄ×Ö·û´®¸ñʽ£¬±£´æµ½HashMapÖС£

public HashMap getColData()

       {

 

               StringBuffer sb = new StringBuffer("receiveItemAmountQueryAction.do?operation=");

               sb.append(CoreConstant.WEB_OPERATION_TYPE_TO_UPDATE_KEY);

               sb.append("&id=");

               sb.append(String.valueOf(form.getTransApplyItem().getTransApplyID().longValue()));

               String link = sb.toString();

 

              HashMap hm = new HashMap();

              hm.put("transCode"," "+IDataFormat.formatString(form.getTransCode()));

              hm.put("transDate", " "+IDateFormat.toDateString(form.getTransDate()));

              hm.put("transTypeName", " "+IDataFormat.formatString(form.getTransTypeName()));

              hm.put("receiveOrgName", " "+IDataFormat.formatString(form.getReceiveOrgName()));

              hm.put("receiveAccountNo", " "+IDataFormat.formatString(form.getReceiveAccountNo()));

              hm.put("receiveBankName", " "+IDataFormat.formatString(form.getReceiveBankName()));

              hm.put("extAccountNo", " "+IDataFormat.formatString(form.getTransApplyItem().getExtAccountNo()));

              hm.put("extBankName", " "+IDataFormat.formatString(form.getTransApplyItem().getExtBankName()));

             

              if (form.getTransApplyItem().getAmount() != null)

              {

                     String sAmount = " "+IDataFormat.formatDisabledAmount(form.getTransApplyItem().getAmount().doubleValue() );

                     hm.put("amount", sAmount);

              }

              else

              {

                     hm.put("amount", "0.00");

              }

             

              hm.put("memo", " "+IDataFormat.formatString(form.getTransApplyItem().getMemo()));

               hm.put("SUPERLINK", link);

 

              return hm;

       }

¸½Â¼£º

 

DataMap½Ó¿Ú£º

/**

 * @author lijj

 *

 * To change the template for this generated type comment go to

 * Window - Preferences - Java - Code Generation - Code and Comments

 */

public interface DataMap {

       public ArrayList getColMetaInfos();

       public ArrayList getExeclColMetaInfos();

       public ArrayList getPrintColMetaInfos();

       public ArrayList getColSearchs();

       public HashMap getQueryData();

       public String getSearchUrl();

       public HashMap getColData();

}

 

³éÏóʵÏÖÀàDefaultDataMap

import java.util.ArrayList;

import java.util.HashMap;

 

 

 

/**

 * @author lijj

 *

 * To change the template for this generated type comment go to

 * Window - Preferences - Java - Code Generation - Code and Comments

 */

public abstract class DefaultDataMap implements DataMap{

       public abstract ArrayList getColMetaInfos();      

       public abstract HashMap getColData();

       public ArrayList getExeclColMetaInfos()

       {

              return new ArrayList();

       }

       public ArrayList getPrintColMetaInfos()

       {

              return new ArrayList();

       }

       public String getSearchUrl()

       {

              return null;

       }

       public HashMap getQueryData()

       {

              return null;

       }

       public ArrayList getColSearchs()

       {

              ArrayList retList = new ArrayList();

              return retList;

       }

      

}

 

ColDataMgr¹ÜÀíÀࣺ

import java.util.ArrayList;

import java.util.HashMap;

 

/**

 * @author lijj

 *

 * To change the template for this generated type comment go to Window - Preferences - Java - Code Generation - Code and

 * Comments

 */

public class ColDataMgr

{

 

       ArrayList list   = null;

 

       DataMap        map        = null;

 

       public ColDataMgr(ArrayList list)

       {

 

              this.list = list;

       }

 

       public ColDataMgr(DataMap map)

       {

 

              this.map = map;

       }

 

       public ArrayList getColMetaInfos()

       {

 

              if (list != null)

              {

                     return ((DataMap) list.get(0)).getColMetaInfos();

              }

              else

              {

                     return this.map.getColMetaInfos();

              }

       }

 

       public ArrayList getExeclColMetaInfos()

       {

 

              if (list != null)

              {

                     return ((DataMap) list.get(0)).getExeclColMetaInfos();

              }

              else

              {

                     return this.map.getExeclColMetaInfos();

              }

       }

 

       public ArrayList getPrintColMetaInfos()

       {

 

              if (list != null)

              {

                     return ((DataMap) list.get(0)).getPrintColMetaInfos();

              }

              else

              {

                     return this.map.getPrintColMetaInfos();

              }

       }

 

       public ArrayList getData()

       {

 

              ArrayList retList = new ArrayList();

              DataMap dataMap = null;

              if (list != null)

              {

                     for (int i = 0; i < list.size(); i++)

                     {

                            dataMap = (DataMap) list.get(i);

                            retList.add(dataMap.getColData());

                     }

              }

              return retList;

       }

 

       public ArrayList getSearchInfos()

       {

 

              return getDataMap().getColSearchs();

       }

 

       public String getSearchUrl()

       {

 

              return getDataMap().getSearchUrl();

       }

 

       public HashMap getQueryData()

       {

 

              return getDataMap().getQueryData();

       }

 

       private DataMap getDataMap()

       {

 

              if (this.map != null)

              {

                     return map;

              }

              else

              {

                     return ((DataMap) list.get(0));

              }

       }

}

ÁÐÔªÐÅÏ¢Àà ColMetaInfo

/**

 * @author lijj

 *

 * To change the template for this generated type comment go to Window - Preferences - Java - Code Generation - Code and

 * Comments

 */

public class ColMetaInfo

{

 

       private String  name;

 

       private String  displayName;

 

       private boolean       isLink;

 

       private String property;

      

      

       public ColMetaInfo(String name, String displayName, boolean isLink, String property)

       {

 

              this.name = name;

              this.displayName = displayName;

              this.isLink = isLink;

              this.property = property;

       }

      

       public String getDisplayName()

       {

      

              return displayName;

       }

 

      

       public void setDisplayName(String displayName)

       {

      

              this.displayName = displayName;

       }

 

      

       public boolean isLink()

       {

      

              return isLink;

       }

 

      

       public void setLink(boolean isLink)

       {

      

              this.isLink = isLink;

       }

 

      

       public String getName()

       {

      

              return name;

       }

 

      

       public void setName(String name)

       {

      

              this.name = name;

       }

 

      

       public String getProperty()

       {

      

              return property;

       }

 

      

       public void setProperty(String property)

       {

      

              this.property = property;

       }

 

      

}

Ä£°æÎļþlist.jsp

<%@ page contentType="text/html;charset=gb2312"%>

<%@ page import="java.util.ArrayList"%>

<%@ page import="java.util.HashMap"%>

<%@ page import="com.e_chinalife.ecms.frame.component.colmap.ColMetaInfo"%>

<%

       ArrayList colMetaInfos = (ArrayList) request.getAttribute("colMetaInfos");

       ArrayList datas = (ArrayList) request.getAttribute("datas");

       int colLen = colMetaInfos.size();

       int resultCount = datas.size();

%>

<table border="0" width="99%" cellspacing="1" cellpadding="0" align="center" class=ItemList>

       <TBODY>

              <TR align=center>

              <%

                     ColMetaInfo colMeta = null;

                     for (int i = 0; i < colLen; i++)

                     {

                            colMeta = (ColMetaInfo) colMetaInfos.get(i);

 

              %>

                     <TD class=ItemTitle height=20 nowrap>

                            <%=colMeta.getDisplayName()%>

                     </TD>

              <%

                     }

              %>

              </TR>

              <%

                     HashMap hm = null;

                     for (int i = 0; i < resultCount; i++)

                     {

              %>

              <TR align=center borderColor=#999999 class=ItemBody>

              <%

                            hm = (HashMap) datas.get(i);

                            for (int j = 0; j < colLen; j++)

                            {

                                   colMeta = (ColMetaInfo) colMetaInfos.get(j);

              %>

                     <TD <%=colMeta.getProperty()%> >

              <%

                                   if (colMeta.isLink() && hm.get(colMeta.getName()) != null

                                          && !((String) hm.get(colMeta.getName())).equals(""))

                                   {

 

              %>

                     <a href="<%=hm.get("SUPERLINK")%>"> <%=hm.get(colMeta.getName())%></a>

              <%

                                   }

                                   else

                                   {

 

              %>

                                          <%=hm.get(colMeta.getName())%>

              <%                }

 

              %>

                     </TD>

              <%

                            }

              %>

              </TR>

              <%

                     }

              %>

 

              <%

              //ûÓмǼÏÔʾ¿Õ°×ÐÐ

              if (resultCount == 0)

              {

              %>

              <TR align=center borderColor=#999999 class=ItemBody>

              <%

                     for (int i = 0; i < colLen; i++)

                     {

                            colMeta = (ColMetaInfo) colMetaInfos.get(i);

              %>

                     <TD height=20 nowrap class=ItemBody>&nbsp;</TD>

              <%

                     }

              }

              %>

              </TR>

       </TBODY>

</table>

 

JspʹÓÃÁбíÄ£°æµÄƬ¶Ï

<table width="80%" border="0" cellpadding="0" cellspacing="0">

<tr>

       <td>

       <table border="0" width="98%" bgcolor="#0099CC" cellspacing="1" cellpadding="0" align="center">

       <tr>

           <td width="100%" bgcolor="#EFEFEF">

                 <table border="0" width="100%" cellspacing="1" height="20">

                      <tr><td width="100%" colspan="3" height="19" class="FormTitle"><b>¿ª»§ÉêÇë</b></td></tr>

               </table>

                              <hr>

                 <jsp:include page="../common/template/List.jsp" flush="true"/>

                 <jsp:include page="../common/template/PageNavigator.jsp" flush="true"/>

                  </td>

             </tr>

             <tr>

                     <td colspan="6" bgcolor="#EFEFEF">

                            <table border="0" width="100%" cellspacing="1" height="20">

                                   <tr>

                                      <td width="82%" height="30" align="right">

                                             <input type="button" value=" ÐÂ Ôö " name="bt" class=button onClick="JavaScript:to_Add();">&nbsp;&nbsp;

                                       </td>

                                   </tr>

                         </table>  

                     </td>

              </tr>

       </table>

       </td>

</tr>

 

</table>

</form>

</body>

 

½áÊøÓï

Web×é¼þµÄÉè¼ÆºÍʹÓ㬿ÉÄÜ»¹Óв»¾¡ÈËÒâµÄµØ·½£¬ÎÒÃÇÔÚÒÔºóµÄ¿ª·¢ÖУ¬ÓÐʲôÒâ¼ûºÍÒªÇ󣬿ÉÒÔÖØ¹¹ÕâЩ×é¼þ£¬ÒÔÊÊӦеÄÐèÇó¡£Web×é¼þµÄÉè¼ÆÔ­ÔòÊÇÊý¾ÝºÍÏÔʾÍÑñî·ÖÀ룬ÏÔʾÂß¼­ÓÉÏÔʾµÄÄ£°æ¿ØÖÆ£¬Óë¾ßÌåµÄÊý¾ÝûÓÐÈκιØÏµ£¬²»¹ÜÊý¾ÝµÄÀ´Ô´ÊÇÊý¾Ý¿â£¬»¹ÊÇÎı¾Îļþ£¬Ö»ÒªÄÜÊÊÅä³ÉÏà¹ØµÄ½Ó¿Ú£¬¾ÍÄÜÕ¹ÏÖÔÚ²»Í¬·ç¸ñµÄÒ³Ãæ£¨¼´Ê¹Óò»Í¬·ç¸ñµÄÄ£°æ£©¡£

[an error occurred while processing this directive]