1. Create a Apache a wicket project
Clik here to get help for create Apache Wicket Project
2. Create Application classes
Apache wicket is working via conventions and there is no configuration needed, but we have to put the class file and html file in right package.
Page java file
This file needs to extend webpage and add the components
package com.mycompany;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.WebPage;
public class HomePage extends WebPage {
private static final long serialVersionUID = 1L;
public HomePage(final PageParameters parameters) {
super(parameters);
add(new Label("message", "Hello world by Java release...."));
}
}
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.WebPage;
public class HomePage extends WebPage {
private static final long serialVersionUID = 1L;
public HomePage(final PageParameters parameters) {
super(parameters);
add(new Label("message", "Hello world by Java release...."));
}
}
Web application file
This file needs to extend Web application and override getHomePage methodIn getHomePage method we have to add our page java file class name
package com.mycompany;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.protocol.http.WebApplication;
/**
* Application object for your web application. If you want to run this
* application without deploying, run the Start class.
*
* @see com.mycompany.Start#main(String[])
*/
public class WicketApplication extends WebApplication {
/**
* @see org.apache.wicket.Application#getHomePage()
*/
@Override
public Class<? extends WebPage> getHomePage() {
return HomePage.class;
}
/**
* @see org.apache.wicket.Application#init()
*/
@Override
public void init() {
super.init();
// add your configuration here
}
}
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.protocol.http.WebApplication;
/**
* Application object for your web application. If you want to run this
* application without deploying, run the Start class.
*
* @see com.mycompany.Start#main(String[])
*/
public class WicketApplication extends WebApplication {
/**
* @see org.apache.wicket.Application#getHomePage()
*/
@Override
public Class<? extends WebPage> getHomePage() {
return HomePage.class;
}
/**
* @see org.apache.wicket.Application#init()
*/
@Override
public void init() {
super.init();
// add your configuration here
}
}
Run Start.java and hit the url
Output


No comments:
Post a Comment