displaytag in struts page to complete a large amount of data show

sponsored links
Completed application displaytag in struts page shows a large amount of data, Oracle Database

JSP file:

<% @ Taglib uri = "/ WEB-INF/displaytag.tld" prefix = "disp"%>

<Disp: table name = "resultList" export = "true" pagesize = "100" requestURI = "logQueryAction.do" sort = "external" id = "element" partialList = "true" size = "resultSize">
<Disp: column property = "operdate" title = "Operation Time"> </ disp: column>
<Disp: column property = "pername" title = "operator"> </ disp: column>
<Disp: column property = "opertype" title = "Operation Type"> </ disp: column>
</ Disp: table>
...

name = "resultList" set the record exists in the key session or request
export = "true" export options are displayed
pagesize = "100" data 100 per page
requestURI = "logQueryAction.do" struts in action in the name, if the record low, you can directly page
sort = "external" External Sorting
id = "element" form id value, the parameters for the program were related
partialList = "true" sub-read data from the database
size = "resultSize" record the total number of articles used to calculate the total number of pages

struts action:

String pageIndexName = new org.displaytag.util.ParamEncoder ("element"). EncodeParameterName (org.displaytag.tags.TableTagParameters.PARAMETER_PAGE); / / pages of the parameter name
int pageSize = 100; / / the number of bars per page
int pageIndex = GenericValidator.isBlankOrNull (request.getParameter (pageIndexName))? 0: (Integer.parseInt (request.getParameter (pageIndexName)) - 1); / / Current Page
String sqlCount = "select count (*) from user_log a"; / / total number of records for statistical sql statement
String sql = "select * from (select rownum as rid, t1 .* from (select b.pername as pername, to_char (a.operdate, 'yyyy-mm-dd hh24: mi: ss') as operdate," +
"Decode (a.opertype, 'D', 'delete', 'M', 'modify', 'other') as opertype, a.hphm as hphm from user_log a," +
"(Select asuser.userid as userid, nvl (asempmsg.pername, asuser.loginname) as pername from asuser, ASEMPMSG where asuser.perid = ASEMPMSG.perid (+)) b" +
"Where a.userid = b.userid"; / / query

/ / Construct query
StringBuffer sb = new StringBuffer ();
if (logQueryForm.getCzrqStart ()! = null & &! "". equals (logQueryForm.getCzrqStart ())) (
sb.append ("and a.operdate> to_date ('" + logQueryForm.getCzrqStart () + "', 'yyyy-mm-dd')");
)
if (logQueryForm.getCzrqEnd ()! = null & &! "". equals (logQueryForm.getCzrqEnd ())) (
sb.append ("and a.operdate <= to_date ('" + logQueryForm.getCzrqEnd () + "', 'yyyy-mm-dd')");
)
if (logQueryForm.getCzlx ()! = null & &! "". equals (logQueryForm.getCzlx ())) (
sb.append ("and a.opertype = '" + logQueryForm.getCzlx () + "'");
)
if (logQueryForm.getCzry ()! = null & &! "". equals (logQueryForm.getCzry ())) (
sb.append ("and a.userid = '" + logQueryForm.getCzry () + "'");
)

sqlCount + = sb.toString ();
sql + = sb.toString () + "order by a.operdate desc) t1 where rownum <="
+ (PageIndex + 1) * pageSize + ") t2 where t2.rid>" + pageIndex * pageSize; / / page to read statement

/ / System.out.println (sb.toString ());
DBBean db = new DBBean ();
ResultSet rs = null;
PreparedStatement prep = null;
try (
List resultList = db.getResultList (sql); / / the ResultSet stored in the List in Return
request.setAttribute ("resultList", resultList); / / put the results into request
prep = db.getConnection (). prepareStatement (sqlCount);
rs = prep.executeQuery ();
if (rs.next ()) ... (
request.setAttribute ("resultSize", new Integer (rs.getInt (1))); / / Save the total number of records stored in the request into Intger instance in
)
)
catch (Exception ex) (
ex.printStackTrace ();
)
finally (
if (db! = null) ... (
db.closeConnection (); / / close connection
)
) ... ... ... ... ... ... ...

One page navigation is in English, as long as you can modify the configuration file org.displaytag.properties.TableTag.properties English into Chinese. Also can specify the type of export file and file name.

export.excel = true
export.excel.label = <span class = "export excel"> Excel </ span>
export.excel.include_header = true
export.excel.filename = export.xls

If you do not specify a file name, click the Export excel in time, ie the window will be opened in excel file. Very annoying!
After the specified file name can choose to save and open.

If you do not specify a file name, click the Export excel in time, ie the window will be opened in excel file. Very annoying!

This problem seems to have been resolved in 1.1, display will default to the name table as excel file.
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of displaytag in struts page to complete a large amount of data show

  • Hibernate configuration parameters hibernate.hbm2ddl.auto

    Hibernate in the configuration file: <properties> <property name="hibernate.hbm2ddl.auto" value="create" /> </ properties> Parameter Description: validate load hibernate, the authentication to create a database t ...

  • spring + hibernate + oracle9i to read and write CLOB

    Database-driven update classes12-9i.jar Hibernate modify the configuration of the following code <bean/> <bean Lazy-init="true"> <property name="nativeJdbcExtractor"> <ref local="nativejdbcExtractor"/>

  • Build flex + spring + blazeds + hibernate application

    Build flex + spring + blazeds + hibernate application First, set up the project blazeds 1, will blazeds.war extract to a directory, such as: myflex /; 2, set up java works were such as: MyFlex, in the orientation of selection create project from exis ...

  • Ruby on Rails Routing - Simple Examples

    This article contains a list of ruby on rails routing examples. If you find you have any questions please leave a comment. Routes are processed from the top of routes.rb down. If a route is matched it will stop processing the routes.rb file and use that r

  • Hibernate connection pool configuration

    Hibernate connection pool configuration <! - Jdbc -> <property name="connection.driver_class"> oracle.jdbc.driver.OracleDriver </ property> <property name="connection.url"> jdbc: oracle: thin: @ 10.203.14.132:15

  • hibernate generic generic DAO

    package org.lzpeng.dao; import java.io.Serializable; import java.util.List; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.criterion.Criterion; import org.springside.modules.orm.hibernate.Page; /** * * @version 2009-1-10 *

  • Struts2 + hibernate + spring problem user log in

    dao layer services layer action jsp <tr> <td align="center"> <b> user name: </ b> </ td> <td> <s: textfield name = "czyNumber" cssClass = "textstyle" theme = "simple" size = &q

  • Hibernate secondary cache

    Hibernate cache: 2-bit cache, also known as process-level cache or SessionFactory level cache, secondary cache can be shared by all of the session Cache configuration and the use of: Will echcache.xml (the document code in hibernate package directory ...

  • Hibernate's lazy strategy

    hibernate Lazy strategy can be used in: <class> tag, it can be true / false Tags can <PROPERTY> values true / false type of necessary tools to enhance <set> <list> can tag values true / false / extra <many-to-one> <on ...

blog comments powered by Disqus
Recent
Recent Entries
Tag Cloud
Random Entries