Extjs paging Using jsp to pass data example _ extjs-js tutorial

Source: Internet
Author: User
Extjs implements paging and transmits data using jsp. The specific implementation process is as follows.
Ext. onReady (function () {store3 = new Ext. data. jsonStore ({autoDestroy: true, totalProperty: 'totle', url: 'service. do ', storeId: 'mystore', root: 'data', fields: ['id', "name", "pw"]}); var pagingToolbar = new Ext. pagingToolbar ({emptyMsg: "No data", displayInfo: true, displayMsg: "displays {2} pieces of data from {0} to {1} pieces of data ", store: store3, pageSize: 50}); var grade = new Ext. grid. gridPanel ({title: "data list", store: store3, height: 300, bbar: pagingToolbar, columns: [{header: "id", dataIndex: "id", width: 300 },{ header: "name", dataIndex: "name", width: 300 },{ header: "pw", dataIndex: "pw"}], region: 'center'}); var panel = new Ext. viewport ({layout: 'border', items: [grade]}) ;});

Action ********************

protected void service(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {List list = new ArrayList();for (int i = 0; i < 50; i++) {Person p = new Person();p.setId("id" + i);p.setName("name" + i);p.setPw("pw" + i);list.add(p);}StringBuffer info = new StringBuffer();info.append("{totle:2000,data:");info.append(JSONArray.fromObject(list));info.append("}");System.out.println(info.toString());System.out.println("*****doPos");request.setAttribute("info", info.toString());request.getRequestDispatcher("/info.jsp").forward(request, response);}

Info. jsp ************* Note: jsp cannot contain any text except @ page.

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"pageEncoding="ISO-8859-1"%>${info}

Web. xml ***************

<?xml version="1.0" encoding="UTF-8"?>
 
  
   
    test
   
   
    com.aa.TestAction
   
  
  
   
    test
   
   
    *.do
   
  
  
   
    index.jsp
   
  
 
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.