Skip to main content

Posts

Showing posts with the label Pagination

Pagination in Spring Hibernate Mvc application

Points To Remember Create a Pagination Taglib using this example . Add Bootstrap css and js in the jsp you want to do pagination and include the taglib in the jsp. Pagination in Spring Hibernate Application using Bootstrap Create a Domain Person. Create a Service PersonService Create a Dao PersonDao . Create a Controller PersonController . Create a Taglib PaginationTaglib. Person.java package com.ekiras.domain; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; @Entity @Table(name="person") public class Person { public Person(){}; public Person(String name,Integer age){ this.name = name; this.age = age; } @Id @GeneratedValue(strategy=GenerationType.AUTO) @Column(name="id") private Long id; @Column(name="name") private String name; @Column(name="age") private Integer age; ...

How to get results from a fixed position in Hibernate Criteria Query

Points To Remember Offset may be required to do pagination or get the results after a particular result from the database. Using offset you can define the first result to be included in the result set from the database.  You can use setFirstResult  on the CriteriaQuery  to set the first result that you want. Using offset to get the results SampleDAO.java @SuppressWarnings("unchecked") public List<Person> getCategories(Integer offset){ return getSession() .createCriteria(Person.class) .setFirstResult(offset!=null?offset:0) .setMaxResults(10) .list(); } This is how you can set the first result you want to fetch from the database. In this example we have set the first result and the maximum number of records that we need to fetch.

How to create Pagination Taglib in Java, Spring

Points To Remember Bootstrap is one of the major UI componnet used worldwide, So you may want to implemnt pagination using bootstrap in java , j2ee or spring application. So all you need to do is Create a Class that will behave like a taglib. Create a Tld file that will map the tablib class with the jsp's. Use the taglib on jsp using the tld file. Create Pagination Taglib for Jsp with Bootstrap. Following is an example of the a custom taglib built for Bootstrap . This taglib takes in uri -> action to be hit when clicked. offset -> the offset of pagination. count -> total number of elements to be shown. max -> maximum number of pages to be shown in the pagination bar. steps -> maximum number of elements to be shown per page. previous -> text to be shown for previous page link. next -> text to be shown for next page link. PaginationTaglib.java This is a java class that will behave like a taglib on jsp's. package com.ekiras.taglib; import java.io.Writer...