More Tutorials| Bioinformatics| Open Source| Photoshop| Questions?
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

Lazy Load Application example in Wicket

                         

In this section of Wicket tutorial we are going to describe you how the ajax lazy load component can be added into your application to make your application much effective.

In this application we are using three of the files as:

  1. LazyLoadApplication.java
  2. LazyLoad.java
  3. LazyLoad.html

LazyLoadApplication calls LazyLoad class which is responsible for rendering the lazy load component on the HTML file.

LazyLoadApplication.java

package com.roseindia.wicket;

import org.apache.wicket.protocol.http.WebApplication;
public class LazyLoadApplication extends WebApplication {
    
    public LazyLoadApplication(){
        
    }
    public Class getHomePage(){
        return LazyLoad.class;
    }
}

LazyLoad.java

package com.roseindia.wicket;

import org.apache.wicket.Component;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.extensions.ajax.markup.html.AjaxLazyLoadPanel;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.image.Image;
import org.apache.wicket.model.Model;

public class LazyLoad extends WebPage{
public LazyLoad()
    {
        add(new Image("image"new Model("beach1.gif")));
        add(new AjaxLazyLoadPanel("lazy")
        {
            @Override
            public Component getLazyLoadComponent(String id)
            {
                try{
                    Thread.sleep(3000);
                }
                catch (InterruptedException e){
                    throw new RuntimeException(e);
                }
                return new Label(id, "Beach Image");
            }
        });
    }
}

LazyLoad.html

<html>
  <head>
    <title>Lazy Load - Wicket</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
     <div wicket:id="lazy" id="lazytag"></div>
        <img wicket:id="image"/>   
  </body>
</html>

One most important thing is to make entry of LazyLoadApplication class into the web.xml file. These entry lines are as follows:

<filter>
   <filter-name>LazyLoadApplication</filter-name>
   <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
   <init-param>
     <param-name>applicationClassName</param-name>
     <param-value>com.roseindia.wicket.LazyLoadApplication</param-value>
   </init-param>
   <init-param>
        <param-name>debug</param-name>
        <param-value>2</param-value>
   </init-param>
</filter>
<filter-mapping>
    <filter-name>LazyLoadApplication</filter-name>
   <url-pattern>/wicket/lazy/*</url-pattern>
</filter-mapping>

Output:

Here is the page view after lazy loading.

Download Source Code

                         

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Join and Excel yourself with our Online instructor led training sessions
Training Courses
Tell A Friend
Your Friend Name

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.