Load data while scrolling down using STRUTS 2 and jquery

Scrolling and loading data
Scrolling and loading data

Unlimited scrolling is very popular now a day. Facebook, flipkart and many more popular sites has the same functionality. It will allow you to load the data from data base and append the result in page, if there is no data available, it will show you message like – no more data available. We can set the limit of data like – every scroll how many record should be added to the page.

If you need same kind of solutions you can follow the below steps.

Step 1

6.Load data while scrolling down
6. Load data while scrolling down

Step 2

scrolling and loading data
scrolling and loading data

Step 3

dynamic data loading
dynamic data loading

 

Step 4

Default data before scrolling
Default data before scrolling

Step 5

Create table called country and insert the data

 

create table country(countryname varchar2(20),countrycode varchar2(5));

 

insert into country(countryname,countrycode) values(‘Afghanistan’,’93’);

insert into country(countryname,countrycode) values(‘Albania’,’355′);

insert into country(countryname,countrycode) values(‘Algeria’,’213′);

insert into country(countryname,countrycode) values(‘American Samoa’,’1684′);

insert into country(countryname,countrycode) values(‘Andorra’,’376′);

insert into country(countryname,countrycode) values(‘Angola’,’244′);

insert into country(countryname,countrycode) values(‘Anguilla’,’1264′);

insert into country(countryname,countrycode) values(‘Antarctica’,’672′);

insert into country(countryname,countrycode) values(‘India’,’91’);

insert into country(countryname,countrycode) values(‘ndonesia’,’92’);

commit;

 

Now run the project and take the mouse inside the div and scroll down.

 

Download Code

Profile photo of Nirmal Dhara
About Nirmal Dhara 28 Articles
Java Developer

5 Comments

  1. I was downloaded, your example very good. i am building website with java using struts. and i had a wrong when i wan to print a list of object. can you check for me? please.
    the folowing is code of country.jsp

    <%

    out.println(" —————————————————————————–");
    out.println(" “);
    out.println(“${l.name} “);
    out.println(“${l.code} “);
    out.println(” “);

    %>
    Thanks you so much!!!

    • Can you change the country.jsp, its looks like your country .jsp having issue.you are trying to print name and code, print only name and test it.
      run the country.jsp separately if output is coming then it should work with my example.

      you can check below code –

      0){
      for(int i=0;i<countryList.size();i++){
      out.println("“+countryList.get(i)+”-“+i+”“);
      }
      }
      }
      catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      }
      %>

Leave a Reply

Your email address will not be published.


*