How To Load and Sort On Demand using Custom AbstractListModel and Sortable"
Line 21: | Line 21: | ||
This is my build.gradle file: | This is my build.gradle file: | ||
+ | https://github.com/EACUAMBA/loading_and_sorting_on__demand/blob/main/build.gradle | ||
+ | <syntaxhighlight lang='groovy'> | ||
+ | buildscript { | ||
+ | repositories { | ||
+ | mavenCentral() | ||
+ | } | ||
+ | dependencies { | ||
+ | classpath("org.springframework.boot:spring-boot-gradle-plugin:2.5.12") | ||
+ | } | ||
+ | } | ||
+ | |||
+ | apply plugin: 'java' | ||
+ | apply plugin: 'war' | ||
+ | apply plugin: 'org.springframework.boot' | ||
+ | apply plugin: "idea" | ||
+ | |||
+ | idea{ | ||
+ | module { | ||
+ | setDownloadSources(true) | ||
+ | setDownloadJavadoc(true) | ||
+ | } | ||
+ | } | ||
+ | |||
+ | repositories { | ||
+ | mavenLocal() | ||
+ | maven { url "https://mavensync.zkoss.org/maven2" } | ||
+ | maven { url "https://mavensync.zkoss.org/eval" } | ||
+ | mavenCentral() | ||
+ | } | ||
+ | |||
+ | sourceCompatibility = '1.8' | ||
+ | targetCompatibility = '1.8' | ||
+ | |||
+ | ext { | ||
+ | zkspringbootVersion = '2.5.12' | ||
+ | springbootVersion = '2.5.12' | ||
+ | zkspring = '4.0.0' | ||
+ | zkVersion = '9.6.0' | ||
+ | zatsVersion = '3.0.0' | ||
+ | junitVersion = '4.13.1' | ||
+ | searchJPAHibernateVersion = '1.2.0' | ||
+ | lombokVersion = '1.18.24' | ||
+ | mysqlVersion = '8.0.31' | ||
+ | javaxServerletAPIVersion='4.0.1' | ||
+ | commonsLang3Version='3.12.0' | ||
+ | } | ||
+ | |||
+ | configurations.testImplementation { | ||
+ | // conflicts with ZATS (which is using jetty) | ||
+ | exclude module: "spring-boot-starter-tomcat" | ||
+ | } | ||
+ | |||
+ | dependencies { | ||
+ | implementation ("org.zkoss.zkspringboot:zkspringboot-starter:${zkspringbootVersion}") | ||
+ | providedRuntime("javax.servlet:javax.servlet-api:${javaxServerletAPIVersion}") | ||
+ | |||
+ | implementation ("org.zkoss.zk:zkspring-core:${zkspring}") | ||
+ | implementation("org.zkoss.zk:zkplus:${zkVersion}") | ||
+ | implementation ("org.springframework.boot:spring-boot-starter-data-jpa:${springbootVersion}") | ||
+ | compileOnly ("org.springframework.boot:spring-boot-devtools:${springbootVersion}") | ||
+ | implementation ("com.googlecode.genericdao:search-jpa-hibernate:${searchJPAHibernateVersion}") | ||
+ | implementation("mysql:mysql-connector-java:${mysqlVersion}") | ||
+ | |||
+ | compileOnly("org.projectlombok:lombok:${lombokVersion}") | ||
+ | annotationProcessor("org.projectlombok:lombok:${lombokVersion}") | ||
+ | testImplementation "org.springframework.boot:spring-boot-starter-test:${springbootVersion}" | ||
+ | implementation("org.apache.commons:commons-lang3:${commonsLang3Version}") | ||
+ | |||
+ | testImplementation "org.zkoss.zats:zats-mimic-ext96:${zatsVersion}" | ||
+ | testImplementation "junit:junit:${junitVersion}" | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | These are some of the dependencies I like to use, so feel free to remove the ones you don't need. | ||
+ | Now let’s build our Custom AbstractListModel<T>. | ||
== code snippet == | == code snippet == |
Revision as of 13:14, 24 November 2022
Edilson Alexandre Cuamba, Software Engineer, EXI - Engenharia e Comercialização de Sistemas Informáticos
November 18, 2022
ZK 9.6.1-Eval
Overview
Sometimes when you want to display data with a table structure, you use Listbox. This component is appropriate to it and works fine until your data gets huge and passes millions of rows; you will notice a little delay when you open the view with this component. For that reason, I needed to create a custom AbstractListModel that supports fetching only the data for the current page on the screen. In this article, I will show you how to build your own CustomAbstractListModel<T> that supports pagination at the database layer. Let’s do it!
Dependencies
To build this, we will need some functions. First is dependency injection (you can use other frameworks, but I personally like Spring) provided by Spring Framework. Second is the capacity to preserve the query structure, and change the structure during the pagination, for this, I use a library called search-jpa-hibernate. Relax, and I will show you how to configure this!
This is my build.gradle file: https://github.com/EACUAMBA/loading_and_sorting_on__demand/blob/main/build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.5.12")
}
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'org.springframework.boot'
apply plugin: "idea"
idea{
module {
setDownloadSources(true)
setDownloadJavadoc(true)
}
}
repositories {
mavenLocal()
maven { url "https://mavensync.zkoss.org/maven2" }
maven { url "https://mavensync.zkoss.org/eval" }
mavenCentral()
}
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
ext {
zkspringbootVersion = '2.5.12'
springbootVersion = '2.5.12'
zkspring = '4.0.0'
zkVersion = '9.6.0'
zatsVersion = '3.0.0'
junitVersion = '4.13.1'
searchJPAHibernateVersion = '1.2.0'
lombokVersion = '1.18.24'
mysqlVersion = '8.0.31'
javaxServerletAPIVersion='4.0.1'
commonsLang3Version='3.12.0'
}
configurations.testImplementation {
// conflicts with ZATS (which is using jetty)
exclude module: "spring-boot-starter-tomcat"
}
dependencies {
implementation ("org.zkoss.zkspringboot:zkspringboot-starter:${zkspringbootVersion}")
providedRuntime("javax.servlet:javax.servlet-api:${javaxServerletAPIVersion}")
implementation ("org.zkoss.zk:zkspring-core:${zkspring}")
implementation("org.zkoss.zk:zkplus:${zkVersion}")
implementation ("org.springframework.boot:spring-boot-starter-data-jpa:${springbootVersion}")
compileOnly ("org.springframework.boot:spring-boot-devtools:${springbootVersion}")
implementation ("com.googlecode.genericdao:search-jpa-hibernate:${searchJPAHibernateVersion}")
implementation("mysql:mysql-connector-java:${mysqlVersion}")
compileOnly("org.projectlombok:lombok:${lombokVersion}")
annotationProcessor("org.projectlombok:lombok:${lombokVersion}")
testImplementation "org.springframework.boot:spring-boot-starter-test:${springbootVersion}"
implementation("org.apache.commons:commons-lang3:${commonsLang3Version}")
testImplementation "org.zkoss.zats:zats-mimic-ext96:${zatsVersion}"
testImplementation "junit:junit:${junitVersion}"
}
These are some of the dependencies I like to use, so feel free to remove the ones you don't need. Now let’s build our Custom AbstractListModel<T>.
code snippet
public class ImageSaver {
public void save(String imageDataUrl) throws IOException {
//Sample Code for code syntax
}
}
Inline Code
This is an Inline Code
Download
put your github code link etc.
Summary
A short conclusion, welcome feedback
Comments
Copyright © {{{name}}}. This article is licensed under GNU Free Documentation License. |
</includeonly>