书签 分享 收藏 举报 版权申诉 / 34

类型java web 通用的分页组件.docx

  • 文档编号:25395030
  • 上传时间:2023-06-08
  • 格式:DOCX
  • 页数:34
  • 大小:51.68KB

 

2、 

 

 

 

 

 

 

 

 

数据表格类

packagecommons.page;

 

importjava.util.Calendar;

importjava.util.List;

 

importcommons.page.model.ArrayDataModel;

importcommons.page.model.DataModel;

importcommons.page.model.ListDataModel;

 

publicclassHtmlTableextendsHtmlElement{

      privateHtmlElementthead=newHtmlElement("thead");

      privateHtmlElementtbody=newHtmlElement("tbody");

      privateHtmlElementtfoot=newHtmlElement("tfoot");

      privateString[]header=null;

      privateString[]footer=null;

      privateDataModeldataModel=null;

      privateintstartRowIndex=-1;//开始行索引

      privateintmaxRowNum=-1;//最大行数

      privateCellCallBackcallBack;

 

      publicHtmlTable(){

             super("table");

      }

      publicvoidsetCellCallBack(CellCallBackcallBack){

             this.callBack=callBack;

      }

      publicvoidsetMaxRowNum(intmaxRowNum){

             this.maxRowNum=maxRowNum;

      }

      publicvoidsetStartRowIndex(intstartRowIndex){

             this.startRowIndex=startRowIndex;

      }

      publicvoidsetHeader(String[]header){

             this.header=header;

      }

      publicvoidsetHeader(Stringheader){

             this.header=header.split(",");

      }

      publicvoidsetFooter(String[]footer){

             this.footer=footer;

      }

      publicvoidsetFooter(Stringfooter){

             this.footer=footer.split(",");

      }

      publicvoidsetDataModel(DataModeldataModel){

             this.dataModel=dataModel;

      }

      publicvoidsetData(Object[][]data){

             this.dataModel=newArrayDataModel();

             this.dataModel.setWrappedData(data);

      }

      publicvoidsetData(Listdata){

             this.dataModel=newListDataModel();

             this.dataModel.setWrappedData(data);

      }

 

      publicvoidsetTbody(HtmlElementtbody){

             this.tbody=tbody;

      }

 

      publicvoidsetTfoot(HtmlElementtfoot){

             this.tfoot=tfoot;

      }

 

      publicvoidsetThead(HtmlElementthead){

             this.thead=thead;

      }

      

      @Override

      publicStringtoHtml(){

             Stringid=this.getAttributeValue("id");

             if(id==null||"".equals(id)){

                    this.addAttribute("id","table"+Calendar.getInstance().getTimeInMillis());

             }

             this.process();

 

             returnsuper.toHtml();

      }

      privatevoidprocess(){

             if(this.header!

=null){

                    this.thead.getChildren().clear();

                    HtmlElementtr=newHtmlElement("tr");

                    for(Stringheader:

this.header){

                           HtmlElementth=newHtmlElement("th");

                           th.setText(header);

                           tr.addChild(th);

                    }

                    this.thead.addChild(tr);

                    this.addChild(this.thead);

             }

             if(this.dataModel!

=null){

                    if(this.callBack==null){

                           this.callBack=newCellCallBack(){

                                  publicHtmlElementdoCell(Objectdata){

                                         HtmlRowtr=newHtmlRow();

                                         if(datainstanceofString[]){

                                                String[]ds=(String[])data;

                                                intlen=ds.length;

                                                if(header!

=null){

                                                       if(len>header.length){

                                                              len=header.length;

                                                       }

                                                }

                                                for(inti=0;i

                                                       HtmlElementtd=newHtmlElement("td");

                                                       td.setText(ds[i]==null?

"":

ds[i]);

                                                       tr.addChild(td);

                                                }

                                         }elseif(datainstanceofObject[]){

                                                Object[]os=(Object[])data;

                                                intlen=os.length;

                                                if(header!

=null){

                                                       if(len>header.length){

                                                              len=header.length;

                                                       }

                                                }

                                                for(inti=0;i

                                                       HtmlElementtd=newHtmlElement("td");

                                                       td.setText(os[i]==null?

"":

os[i].toString());

                                                       tr.addChild(td);

                                                }

                                         }

                                         returntr;

                                  }

                           };

                    }

                    intstartRow=0;

                    intendRow=0;

                    intj=this.dataModel.getRowCount();

                    if(this.startRowIndex>0){

                           startRow=this.startRowIndex;

                    }

                    if(this.maxRowNum<0){

                           endRow=this.dataModel.getRowCount();

                    }else{

                           endRow=startRow+this.maxRowNum;

                    }

                    if(endRow>j){

                           endRow=j;

                    }

                    this.tbody.getChildren().clear();

 

                    for(inti=startRow;i

                           this.dataModel.setRowIndex(i);

                           HtmlElementtr=this.callBack.doCell(this.dataModel.getRowData());

                           this.tbody.addChild(tr);

                    }

           

配套讲稿:

如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。

特殊限制:

部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。

关 键  词:
java web 通用的分页组件 通用 分页 组件
提示  冰豆网所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。
关于本文
本文标题:java web 通用的分页组件.docx
链接地址:https://www.bdocx.com/doc/25395030.html
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2008-2022 冰点文档网站版权所有

经营许可证编号:鄂ICP备2022015515号-1

收起
展开