displaytag标签库的使用说明

displaytag标签库的使用说明


版 本 号: 1.0 

功      能:表格处理 

参考文档: displaytag.pdf 

实 例 包: displaytag.war 

  

简要说明 

1.  已知条件: 

1 )存在一个 JavaBean : Computer(id , mainboard , cpu , keyboard , mouse , buyTime) 

2 )存在一个 Collection( 包含五条 Computer 记录 ) : computer 

       3 ) request 存放该 Collection : request.setAttribute(“test” , computer) ; 

       

2.  将 Collection 里的记录生成一张表 

代码: <display : table  name=”test”/> 

说明:该表中包含以 test 命名的 Collection 的五条记录,显示的列为该 Computer 

类的所有属性。 

  

3.  有选择的显示列 

代码: 

<display : table  name=”test” > 

               <display : column  property=”id” title=”ID” /> 

               <display : column  property=”mainboard” /> 

               <display : column  property=”cpu” /> 

               <display : column  property=”buyTime” /> 

      </display : table> 

说明: property :代表要显示的列,若不指定 title 则列名默认为 property 指定的属性名。 

     也可以增加其它自定义列,例如: 

<display:column title=" 操作 "> 删 除 </display:column> 

  

4.  指定以某列值进行排序 

代码: 

<display : table  name=”test” defaultsort="1" defaultorder="descending" > 

               <display : column  property=”id” title=”ID”  sortable="true"/> 

               <display : column  property=”mainboard” /> 

               <display : column  property=”cpu” /> 

               <display : column  property=”buyTime”  sortable="true"/> 

      </display : table> 

  

说明: defaultsort : 在还未点击可排序列时的默认状态 

      defaultorder :指明默认是升序还是降序进行排序( ascending /descending ) 

      sortable :在要进行排序的列上指明该属性为 true ,则每点击一次该列都会以升序或降序进行表格重排。 

  

5.  创建动态连接 

代码: 

<display : table  name=”test” > 

     <display : column  property=”id” title=”ID” href=”details.jsp” paramId=”id” /> 

     <display : column  property=”mainboard”  href=”details.jsp”                                                 paramId=”action”  paramName=”testparam” /> 

     <display : column  property=”cpu”  href=”details.jsp” paramId=”id” 

paramScope =”request” paramProperty=”id”/> 

  <display : column  property=”buyTime”  /> 

</display : table> 

说明: 

href : the base URL used to construct the dynamic link 

paramId: the name of the parameter that gets added to the URL specified above 

paramName: name of the bean that contains the data we want to tack on the the URL 

(typically null, indicating the current object in the List) 

paramProperty: property to call on the object specified above to return the value that 

                      gets tacked onto the URL. 

paramScope: specific scope where the databean lives, typically null 

  

  

6.  翻页功能 ( 每页显示 2 条记录 ) 

<display : table  name=” test” pagesize ="2" /> 

  

7.  表头、表尾说明 

表头: <display : caption>this is a table caption</display : caption> 

  

表尾: 

<display:footer> 

     <tr> 

        <td colspan="3">sample footer</td> 

        <td>any sum or custom code can go here</td> 

     </tr> 

</display:footer> 

  

8.  列表所处范围 

pageScope 

requestScope ( 默认 ) ,前面所介绍的 test 都是从 request 中取出。 

sessionScope 

applicationScope 

例:从 sessionScope 中取出列表 test2 

               <display : table sessionScope.test2”/>  
 




文章来自: 本站原创
引用通告地址: http://www.is21.cn/trackback.asp?tbID=27
Tags:
评论: 0 | 引用: 0 | 查看次数: 2685
发表评论
你没有权限发表留言!