[Original] Java Tips: Distributed JTABLES Processing [2]
data
The general Table requirement can be classified according to the ascending or descending order of the column. The JTBale component does not have a fixed function classification; it must be executed in a TableModel execution (see: http://www.javaworld.com/javaworld/javatips/jw-javatip137.html? # Resources # resources). You must have all the data used to classify. Since all data is on the server, the classification must be done on the server. It is convenient to send a classification message via the DistributeTableDataSource interface to the server. You can use SQL Order operators to implement manual classification or database complex operations. The client's data cache will be invalid, and table is updated. JTABLE drop immediately requests to populate the Table section shown. This reduces the new download of new data for server-side data. A problem occurs in the sorting process. What happened to the user selected? Of course, the part of the choice is not accepted. In JTABLE, the selection operation is executed by using the ListSerectionModel interface recorded in the selected row index. If a selection changes the data of the TBalemodel background, ListSelectionModel will not have index information about the new selection section, and the selection will include some old data. In any case, if you know some new row indexes, you can perform manual operations. Record the selected rows before the arrangement operation. After the arrangement operation, Table selects clearly then selects the new index set in ListSelectionModel. The arrangement method in the DistributedTableDataSource interface takes the following form: int [] sort (int SortColumn, Boolean Ascending, int [] selectedRows "THROWS Exception takes the rising order, the row index must be selected, and then returned to sort Data corresponding indexes. Three methods are used for full execution sorting methods: setSelectedRowsandColumns (), getSelectedRows () and getSelectedColumns (). These methods are synchronized between servers and clients. Figure 3 Scheduled and selection operation flowchart Figure 3 Sorting operation of distributed JTABLE Simplify Table operation The following describes a method, which can quickly display a table without waiting for downloading large blocks. If the user scrolls down the entire table, all the data must be downloaded quickly or slowly. However, there is always one balance between downloading all data and fast display. This skill method has the following benefits: • Table Component Quick Display · Client Program does not use too much memory, because the client just stores a few data · a Table or spreadsheet rich interface is maintained · When the user is for some When the data after the line is not interested, the data source does not have to spend too much resources for data downloads. In the demo, a client contains read-only can be sorted JTABLE, which includes 200,000 row data, which is obtained as XML from servlset, which is stored in a distributed table mode DistributeTableModel. By expanding this demo, you can easily implement unit selection, data editing, and so on.