Archive for the ‘- ZK framework’ Category.

HowTo: ZKoss Multiline Messagebox

With followed code you can create a zkoss multi line messagebox which works with line feeds ‘\n’.
Only take the zul template and the controller to your project and set the template path in the controller.

Additionally you can set an empty line before and after the message for a nicer looking.

Home Home
Home

Continue reading ‘HowTo: ZKoss Multiline Messagebox’ »

HowTo: ZKoss Load on Demand with Paging + Sorting

Preface

The ZKoss paging component by default works with the complete list of loaded records. For working with huge tables we need to modify the paging component so that it shows only exact the count of records that the user can see in the page of the listbox at one time. So by paging we can intercept the paging event and do a special call to the database where we can overhanded the actual/next page and the pagesize (count of pulled records). So we became page for page only subsets of the result.

The interesting part to solve is to work with a database oriented paging mechanism AND accept changings of the order triggered by the listheaders.

For an overview how the pagination can be coded look at the Smalltalk from Marcos de Sousa:

Use Load-On-Demand to Handle Hugh Data. http://docs.zkoss.org/wiki/Use_Load-On-Demand_to_Handle_Huge_Data.

I have written an article about paged sorting and filtering of huge data with the zk framework here: Paging and sorting huge data with ZK.

In short: Pagination is a block wise loading of records.

Advantage:

  • reduces DB work;
  • redudes network traffic between Database and the application server;
  • reduces cpu and memory demand
  • reduces the response time;
  • increase the data throughput

Problem Definition

If we want database paged records from a table and would like to allow changing the sort order of these data by clicking on the listheaders we have to consider three things:

  • First we must consequently do the sorting on the database to prevent users confusion if the resultset sorted in the grid.
  • Secondly we need the right place in code where we can catch which of the listheaders is clicked for changing the sorting.
  • Third we need a mechanism to remember what is the originally query that should now be modified for sorting in an other sort order.

Why we need this?

Let us consider what we want from the database side: First we have a sql statement with a where clause. Second we want to add/manipulate the order by clause. By changing the sort order we need to remember what is in the select clause and in the where clause to add the changed ‘order by’.

Continue reading ‘HowTo: ZKoss Load on Demand with Paging + Sorting’ »