Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Apache Wicket Interview Questions and Answers

Ques 6. Dependency to start wicket.


Wicket need SLF4J !
You have to include the slf4j logging implementation, otherwise Wicket will be failed to start.

Wicket need resource filter
Remember to add the resource filter, Wicket puts all files in same package folder, if you didn’t define the resource filter to include everything “<include>*</include>” , “html”, “properties” or other resources files may failed to copy to the correct target folder.

Is it helpful? Add Comment View Comments

Ques 7. A sample web application using apache wicket.

In Wicket, most stuffs are work by convention, you don’t need to configure it. In this case, WebApplication returns a “Hello.class” as the default page, when Wicket see this “Hello.class“, it know the mark up “html” page should be “Hello.html“, and it should be able to find at the same package directory. This is why Wicket need you to put both “html” and “java” class together.

File : – The main application entrance.

package com.withoutbook;
import org.apache.wicket.Page;
import org.apache.wicket.protocol.http.WebApplication;
import com.withoutbook.hello.Hello;
public class WelcomeApplication extends WebApplication {
public Class<? extends Page> getHomePage() {
return Hello.class; //return default page

File :

package com.withoutbook.hello;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.WebPage;
public class Hello extends WebPage {
private static final long serialVersionUID = 1L;
    public Hello(final PageParameters parameters) {
        add(new Label("message", "Hello World, Wicket"));

File : Hello.html

        <title>Wicket Hello World</title>
        <span wicket:id="message">message will be replace later</span>

To make Wicket works, you need to register Wicket filters in your web.xml file.

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="" 
<display-name>Wicket Web Application</display-name>

Is it helpful? Add Comment View Comments

Ques 8. How to create a TextField in Apache-Wicket?

final TextField<String> username = new TextField<String>("username",
username.add(new UsernameValidator());

Is it helpful? Add Comment View Comments

Ques 9. How to submit a form in apache-wicket?

Form<?> form = new Form<Void>("userForm") {
protected void onSubmit() {
final String usernameValue = username.getModelObject();
PageParameters pageParameters = new PageParameters();
pageParameters.add("username", usernameValue);
setResponsePage(SuccessPage.class, pageParameters);

Is it helpful? Add Comment View Comments

Ques 10. Example of Username validation in apache-wicket.

import org.apache.wicket.validation.CompoundValidator;
import org.apache.wicket.validation.validator.PatternValidator;
import org.apache.wicket.validation.validator.StringValidator;
public class UsernameValidator extends CompoundValidator<String> {
private static final long serialVersionUID = 1L;
public UsernameValidator() {
add(StringValidator.lengthBetween(6, 15));
add(new PatternValidator("[a-z0-9_-]+"));

Is it helpful? Add Comment View Comments

Most helpful rated by users:

©2024 WithoutBook