<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 165, comments - 198, trackbacks - 0, articles - 1
      BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

    extremecomponents 初使用

    Posted on 2007-04-24 15:51 G_G 閱讀(1044) 評論(0)  編輯  收藏 所屬分類: ReportformJspTag
    <? xml?version="1.0"?encoding="UTF-8" ?>

    <! DOCTYPE?web-app?PUBLIC?"-//Sun?Microsystems,?Inc.//DTD?Web?Application?2.3//EN"?"http://java.sun.com/dtd/web-app_2_3.dtd" >
    < web-app >

    ????
    < taglib >
    ????????
    < taglib-uri > http://www.extremecomponents.org </ taglib-uri >
    ????????
    < taglib-location > /WEB-INF/extremecomponents.tld </ taglib-location >
    ????
    </ taglib >
    ????
    </ web-app >

    <% @?taglib?prefix = " ec " ?uri = " /WEB-INF/extremecomponents.tld " ? %>

    <% @?taglib?prefix = " c " ?uri = " /WEB-INF/c.tld " ? %>

    <% @?page?language = " java " ?import = " java.util.* " ?pageEncoding = " UTF-8 " %>
    <%
    String ?path? = ?request.getContextPath();
    String ?basePath? = ?request.getScheme() + " :// " + request.getServerName() + " : " + request.getServerPort() + path + " / " ;
    %>

    <! DOCTYPE?HTML?PUBLIC?"-//W3C//DTD?HTML?4.01?Transitional//EN" >
    < html >
    ??
    < head >
    ????
    < base? href ="<%=basePath%>" >
    ????
    ????
    < title > My?JSP?'MyJsp.jsp'?starting?page </ title >
    ????
    ????
    < meta? http-equiv ="pragma" ?content ="no-cache" >
    ????
    < meta? http-equiv ="cache-control" ?content ="no-cache" >
    ????
    < meta? http-equiv ="expires" ?content ="0" >
    ????
    < meta? http-equiv ="keywords" ?content ="keyword1,keyword2,keyword3" >
    ????
    < meta? http-equiv ="description" ?content ="This?is?my?page" >
    ????
    ????????
    < link? rel ="stylesheet" ?type ="text/css" ?href ="<c:url?value=" /extremecomponents.css" /> ">
    ????
    ??
    </ head >
    ??
    ??
    < body >


    ????????????
    <%
    ????????????????List?goodss?
    = ? new ?ArrayList();
    ????????????????
    for ?( int ?i? = ? 1 ;?i? <= ? 10 ;?i ++ )
    ????????????????{
    ????????????????????Map?goods?
    = ? new ?java.util.HashMap();
    ????????????????????goods.put(
    " code " ,? " A00 " + i);
    ????????????????????goods.put(
    " name " ,? " 面包 " + i);
    ????????????????????goods.put(
    " status " ,? " A:valid " );
    ????????????????????goods.put(
    " born " ,? new ? Date ());
    ????????????????????goodss.add(goods);
    ????????????????}
    ????????????????request.setAttribute(
    " goodss " ,?goodss);
    ????????????
    %>
    ????????????
    ????????????
    < ec:table??
    ????????????
    action ="${pageContext.request.contextPath}/test.jsp"
    ????????????items
    ="goodss"
    ????????????cellpadding
    ="1"
    ????????????title
    ="my?bread" >
    ????????????
    < ec:row ></ ec:row >
    ????????????????
    < ec:column? property ="code" />
    ????????????????
    < ec:column? property ="name" />
    ????????????????
    < ec:column? property ="status" />
    ????????????????
    < ec:column? property ="born" ?cell ="date" ?format ="yyyy-MM-dd" />
    ????????????
    </ ec:table >

    ??
    </ body >
    </ html >

    {轉(zhuǎn)}


    關(guān)鍵字: ? java,eXtremeComponents????

    在我開發(fā)的一個通用查詢項目中想把查詢結(jié)果集的顯示部分采用eXtremeComponents組件來處理,但是碰到個問題,就是組件預(yù)先并不知道查詢結(jié)果的列名,也就是必須解決Column列的動態(tài)顯示問題。

    有一種方法就是通過在jsp頁面里羅列一下,但是總感覺不舒服,查文檔發(fā)現(xiàn)eXtremeComponents有一接口AutoGenerateColumns可實現(xiàn)此功能,以下為具體實現(xiàn)步驟:

    一、在應(yīng)用的servlet(或struts action等)里(如sqlAction.do)實現(xiàn)根據(jù)SQL語句的運行結(jié)果獲取字段名稱列表(fieldnames)和查詢結(jié)果集(results)并將其放入httpRequest的屬性中

    代碼
    1. List?fieldnames?=?實現(xiàn)[獲取字段名稱列表]方法;??
    2. List?results?=?實現(xiàn)[獲取查詢結(jié)果集]方法;??
    3. httpRequest.setAttribute("fieldnames",?fieldnames);??
    4. httpRequest.setAttribute("results",?results);??

    results將作為eXtremeTable組件中屬性items的值,fieldnames將用來迭代構(gòu)造Column對象

    二、編寫類AutoGenerateColumnsImpl實現(xiàn)org.extremecomponents.table.core.AutoGenerateColumns接口

    代碼
    1. package?org.boogie.sql.common.ec;??
    2. ??
    3. import?java.util.Iterator;??
    4. import?java.util.List;??
    5. ??
    6. import?org.extremecomponents.table.bean.Column;??
    7. import?org.extremecomponents.table.core.AutoGenerateColumns;??
    8. import?org.extremecomponents.table.core.TableModel;??
    9. ??
    10. public?class?AutoGenerateColumnsImpl?implements?AutoGenerateColumns?{??
    11. ??
    12. ????public?void?addColumns(TableModel?model)?{??
    13. ????????List?fieldnames?=?(List)?model.getContext().getRequestAttribute(??
    14. ????????????????"fieldnames");??
    15. ????????Iterator?iterator?=?fieldnames.iterator();??
    16. ????????while?(iterator.hasNext())?{??
    17. ????????????String?fieldname?=?(String)?iterator.next();??
    18. ????????????Column?column?=?model.getColumnInstance();??
    19. ????????????column.setProperty(fieldname);??
    20. ????????????//?column.setCell((String)?columnToAdd.get(CELL));??
    21. ????????????model.getColumnHandler().addAutoGenerateColumn(column);??
    22. ????????}??
    23. ????}??
    24. }??

    AutoGenerateColumns接口只有一個方法addColumns供實現(xiàn),在此方法中通過傳入的TableModel型參數(shù) model可從其Context中獲取到httpRequest中的fieldnames屬性值,然后根據(jù)fieldnames列表迭代構(gòu)造對應(yīng) Column后添加到model中

    三、在顯示頁文件的eXtremeTable中,配置TableTag的屬性items值為results,配置ColumnTag的屬性autoGenerateColumns值為類AutoGenerateColumnsImpl的全路徑

    代碼
    1. <ec:table???
    2. ????????items="results"??
    3. ????????var="result"??
    4. ????????action="${pageContext.request.contextPath}/sqlAction.do"??
    5. ????????imagePath="${pageContext.request.contextPath}/images/table/*.gif"??
    6. ????????title="查詢結(jié)果"??
    7. ????????width="100%"??
    8. ????????rowsDisplayed="5"??
    9. ????????>??
    10. ??<ec:parameter?name="method"?value="ec"/>??
    11. ??<ec:row>??
    12. ????<ec:columns?autoGenerateColumns="org.boogie.sql.common.ec.AutoGenerateColumnsImpl"/>??
    13. ??</ec:row>??
    14. </ec:table>

    小結(jié)******************************************************************************

    <%@?page?language="java"?pageEncoding="UTF-8"%>
    <%@?taglib?uri="http://jakarta.apache.org/struts/tags-bean"?prefix="bean"%>?
    <%@?taglib?uri="http://jakarta.apache.org/struts/tags-html"?prefix="html"%>
    <%@?taglib?uri="http://jakarta.apache.org/struts/tags-logic"?prefix="logic"%>
    <%@?taglib?uri="http://www.extremecomponents.org"?prefix="ec"?%>?

    <%@?taglib?uri="http://struts.apache.org/tags-tiles"?prefix="tiles"?%>
    <%@?taglib?uri="http://www.jjm.cn/tags-security"?prefix="jjmtag"%>
    ?

    <html>?
    ????
    <head>
    ????????
    <LINK?href="<%=request.getContextPath()%>/css/extremetable.css"?rel="stylesheet"?type="text/css">
    ????????
    <script?language="JavaScript"?src="<%=request.getContextPath()%>/res_others/calendar/calendar.js?">?</script>???? //時間 的 js 插件

    ????????
    <LINK?rel="StyleSheet"?type="text/css"?href="<%=request.getContextPath()%>/css/jjmStyle.css">??????
    ????
    </head>

    ????
    <body>
    ????
    <CENTER>

    ????
    <TABLE?border="1"?class="borderLessTable"?width=100%>
    ????????
    <html:form?action="/tAT.do">
    ????????????????
    <TR>
    ????????????????????
    <TD?class="tdQueryCaption13">
    ????????????????????????
    <CENTER>?時間范圍:</CENTER>
    ????????????????????
    </TD>
    ????????????????????
    <TD?class="tdQueryCaption13">
    ????????????????????
    <CENTER>
    ????????????????????????
    <html:text?property="time"?size="8"?readonly="true"/>?????????????????????//作為 時間 的 javascript 插件
    ????????????????????????????
    <img?alt="彈出日歷下拉菜單"?height="16"?width="16"?align="middle"?
    ????????????????????????????????????src
    ="<%=request.getContextPath()%>/res_others/calendar/img/cal.gif"?
    ????????????????????????????????????style
    ="cursor:hand;"?
    ????????????????????????????????????onclick
    ="fPopUpCalendarDlg(time);return?false"/>
    ????????????????????
    </CENTER>????????????????????????????
    ????????????????????
    </TD>
    ????????????????????
    <tD>
    ????????????????????????
    <CENTER><html:image?src="/rlzy/images/edit/chaxun.gif"></html:image></CENTER>
    ????????????????????
    </tD>
    ????????????????????
    ????????????
    </html:form>
    ????
    </TABLE>
    ????
    </CENTER>
    ????
    ????????
    <ec:table??
    ????????????????
    items?="list"
    ????????????????imagePath
    ="${pageContext.request.contextPath}/images/ectable/*.gif"
    ????????????????cellpadding?
    ="1">
    ?????????????
    <ec:row></ec:row>
    ?????????????
    ????????????????
    <ec:column???property?="入段&調(diào)離"?/>
    ?????????????
    ????????????????
    <ec:column??cell="com.jjm.extremesite.cell.CorpNameCell"?property="段號"/>???//?? (1)?? 標(biāo)簽的重寫

    ????????????????
    ????????????????
    <ec:column??cell="com.jjm.extremesite.cell.CorpNameCell"?property="車間"?/>
    ?????????????????
    ????????????????
    <ec:column??property="姓名"?/>
    ?????????????????
    ?????????????????
    <ec:column???property="入段時間"?cell="date"?format="yyyy-MM-dd"??/>???//時間 的表示 cell="date"?format="yyyy-MM-dd"??
    ?????????????????
    ????????????????
    <ec:column???property="調(diào)離時間"?cell="date"?format="yyyy-MM-dd"/>
    ?????????????????
    ?????????????
    </ec:table?>

    ????
    </body>
    </html>

    package?com.jjm.extremesite.cell;

    import?org.extremecomponents.table.bean.Column;
    import?org.extremecomponents.table.cell.AbstractCell;
    import?org.extremecomponents.table.core.TableModel;

    import?com.jjm.bj.dao.CorpBean;
    import?com.jjm.bj.dao.CorpDao;

    public?class?CorpNameCell?extends?AbstractCell?{

    ????
    public?void?destroy()?{

    ????}


    ????
    /**
    ?????*?
    @param?args
    ?????
    */

    ????
    public?static?void?main(String[]?args)?{

    ????}

    ????
    ????
    private?String?getCorpName(String?id){
    ????????
    if?(id!=null?&&?id.length()>0){
    ????????????CorpBean?obj?
    =null;
    ????????????obj
    =CorpDao.findByID(id);
    ????????????
    if?(obj!=null){
    ????????????????
    return?obj.getCorpName();
    ????????????}
    ????????????
    ????????}
    ????
    ????????
    return?"";
    ????}


    ????
    protected?String?getCellValue(TableModel?tableModel,?Column?column)?{
    ????????CorpNameCell?corpName
    =new?CorpNameCell();
    ????????
    return?corpName.getCorpName(column.getValueAsString());
    ????}


    }


    只有注冊用戶登錄后才能發(fā)表評論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 最近2019中文字幕免费直播| 无码中文字幕av免费放dvd| japanese色国产在线看免费| 亚洲精品偷拍视频免费观看| 少妇性饥渴无码A区免费| 4虎永免费最新永久免费地址| 免费看国产精品3a黄的视频| 国产成人精品免费视频大全五级 | 国产成人精品123区免费视频| 亚洲精品国产高清嫩草影院| 国产精一品亚洲二区在线播放| 亚洲精选在线观看| 亚洲熟妇无码AV| 久草免费福利在线| 久草视频在线免费| 四虎永久在线精品免费影视| 亚洲乱色熟女一区二区三区丝袜| 亚洲人成网站在线观看播放动漫 | 亚洲人成亚洲精品| 亚洲人配人种jizz| 一级毛片在播放免费| 免费人成在线观看网站品爱网| 四虎成人免费大片在线| 丝袜熟女国偷自产中文字幕亚洲| 91情国产l精品国产亚洲区| 蜜芽亚洲av无码一区二区三区| 国产在线国偷精品免费看| 99在线精品视频观看免费| 免费人成在线观看网站品爱网日本 | 在线免费观看一级毛片| 亚洲精品乱码久久久久66| 亚洲国产日韩综合久久精品| av电影在线免费看| 永久免费AV无码国产网站| 久久影视综合亚洲| 亚洲综合久久一本伊伊区| 久久av免费天堂小草播放| 日韩免费一区二区三区| 亚洲嫩草影院久久精品| 黄网站色视频免费看无下截| 国产在线jyzzjyzz免费麻豆|