Apache Wicket Interview Questions & Answers

Apache Wicket Interview Questions

Searching for Apache Wicket jobs? Need interview questions to prepare well for the job interview. Then you are at the right place. We have provided a detailed and tricky Apache Wicket Job Interview Questions and Answers in our page. Apache Wicket, commonly referred to as Wicket, is a lightweight component-based web application framework for the Java programming language conceptually similar to JavaServer Faces and Tapestry. There are many leading companies that offer jobs in various positions of Apache Wicket. Some Important role are Java Developer, Java technical lead, Senior Java Developer, Web application developer, Software Engineer II, Computer Scientist and many other interesting roles. Looking for a job can be stressful and tiring, especially if you don’t know how to apply and where to search and how prepare well for the job interviews. So, to clear all your confusions visit our site wisdomjobs.com.

Apache Wicket Interview Questions And Answers

Apache Wicket Interview Questions
    1. Question 1. What Is Wicket Framework?

      Answer :

      • Wicket is one of the most recent in a long line of Java web development frameworks.Wicket is a component-basedframework, which puts it in stark contrast to some of the earlier solutions to the sometimes monotonous task of web programming.Wicket builds on top of Sun's servlet API. Wicket is mostly removed from the request/response nature that is inherent with the web and Servlets. Instead of building controllers that must service many users and threads simultaneously, taking in requests, returning responses, and never storing any state, the Wicket developer thinks in terms of stateful components. Instead of creating a controller or action class, he or she creates a page, places components on it, and defines how each component reacts to user input.
      • It is a lightweight component-based web application framework for the Java programming.

    2. Question 2. What Are Wicket Models?

      Answer :

      A Model holds a value for a component to display and/or edit :

      • Simple Models
      • Dynamic Models
      • Property Models
      • Compound Property Models
      • Wrapped Object Models
      • Resource Models
      • Detachable Models
      • Chaining models

    3. Question 3. What Are The Ways To Create A Page In Wicket?

      Answer :

      There are 2 ways to Create New Wicket Page.

      • create a Page Extending "WebPage" Class.
      • create a Page Extending  "BasePage" ( BasePage Should Extend "WebPage").
      • IF you are using first Way you should Create Whole page with thier Header,Footer and other parts
      • and that HTML file's content may be large (complicated).This is an Unreliable way to create Page. suppose you have to change some content in Header part then you have to edit all pages that having Header Content 
      • If you are using second way, first Create your BasePage then you can extend these page to other while creating new page. in that page you have to add only Body part (Content that you want to show on that Page) Using <wicket:child />

    4. Question 4. What Is About Web Application In Wicket?

      Answer :

      A web application is a subclass of Application which associates with an instance of WicketServlet to serve pages over the HTTP protocol. This class is intended to be subclassed by framework clients to define a web application.

    5. Question 5. What Is Base Class For Html Pages?

      Answer :

      Base class for HTML pages: Webpage Class.

    6. Question 6. Dependency To Start Wicket?

      Answer :






      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.

    7. Question 7. How To Create A Textfield In Apache-wicket?

      Answer :

      final TextField username = new TextField("username",Model.of(""));


      username.add(new Username  Validator());

    8. Question 8. How To Submit A Form In Apache-wicket?

      Answer :

      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);



    9. Question 9. Tell Me The Example Of Username Validation In Apache-wicket?

      Answer :

      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_-]+"));



    10. Question 10. How To Create A Password Field In Apache-wicket?

      Answer :

      create a password field

      final PasswordTextField password = new PasswordTextField("password", Model.of(""));

      //for properties file


    11. Question 11. How To Create A Textarea In Apache-wicket?

      Answer :

      //create a textarea field for address

      final TextArea<String> address = new TextArea<String>("address",Model.of(""));


    12. Question 12. How To Create Checkbox In Apache-wicket?

      Answer :

      final CheckBox chk0 = new CheckBox("checkbox0", Model.of(Boolean.TRUE));

       final CheckBox chk1 = new CheckBox("checkbox1",

      new PropertyModel<Boolean>(this, "checkbox1"));

      final CheckBox chk2 = new CheckBox("checkbox2",

      new PropertyModel<Boolean>(this, "checkbox2"));

    13. Question 13. How To Create Multiple Checkboxes In Apache-wicket?

      Answer :

      private static final List<String> LANGUAGES = Arrays.asList(new String[] {"Java", ".NET", "PHP", "Python", "C/C++" });

      // hold the checkbox values

      private ArrayList<String> languagesSelect = new ArrayList<String>();

      final CheckBoxMultipleChoice<String> listLanguages = new CheckBoxMultipleChoice<String>("languages", new Model(languagesSelect), LANGUAGES);

    14. Question 14. How To Create Radio Button In Apache-wicket?

      Answer :

      //choices in radio button

      private static final List<String> TYPES = Arrays.asList(new String[] { "Shared Host", "VPN", "Dedicated Server" });

      RadioChoice<String> hostingType = new RadioChoice<String>("hosting", new PropertyModel<String>(this, "selected"), TYPES);

    15. Question 15. How To Create Single Selected Listbox?

      Answer :

      // single list choice

      private static final List<String> FRUITS = Arrays.asList(new String[] { "Apple", "Orange", "Banana" });

      ListChoice<String> listFruits = new ListChoice<String>("fruit", new PropertyModel<String>(this, "selectedFruit"), FRUITS);


    16. Question 16. How To Create Multiple Selected Listbox In Apache-wicket?

      Answer :

      //choices in list box

      private static final List<String> NUMBERS = Arrays.asList(new String[] {"Number 1", "Number 2", "Number 3", "Number 4", "Number 5", "Number 6" });

      //variable to hold the selected multiple values from listbox, 

      //and make "Number 6" selected as default value

      private ArrayList<String> selectedNumber = new ArrayList<String>(

      Arrays.asList(new String[] { "Number 6" }));

       ListMultipleChoice<String> listNumbers = new ListMultipleChoice<String>(

      "number", new Model(selectedNumber), NUMBERS);

       //HTML for multiple select listbox

      <select wicket:id="number"></select>

    17. Question 17. How To Create Dropdown Choice In Apache-wicket?

      Answer :


      import org.apache.wicket.markup.html.form.DropDownChoice;

      //choices in dropdown box

      private static final List<String> SEARCH_ENGINES = Arrays.asList(new String[] {

      "Google", "Bing", "Baidu" });

       //variable to hold the selected value from dropdown box,

      //and also make "Google" is selected by default

      private String selected = "Google";

       DropDownChoice<String> listSites = new DropDownChoice<String>(

      "sites", new PropertyModel<String>(this, "selected"), SEARCH_ENGINES);

       //HTML for dropdown box

      <select wicket:id="sites"></select>

    18. Question 18. How To Create Fileupload Field In Apache-wicket?

      Answer :


      import org.apache.wicket.markup.html.form.upload.FileUploadField;


      form.add(fileUpload = new FileUploadField("fileUpload"));


      <input wicket:id="fileUpload" type="file"/>

    19. Question 19. How To Create Select Option As Menu Wise In Apache-wicket?

      Answer :


      import org.apache.wicket.extensions.markup.html.form.select.Select;

      import org.apache.wicket.extensions.markup.html.form.select.SelectOption;

              //variable to hold the selected value from dropdown box,

              //and also make "jQuery" selected by default

              private String selected = "jQuery";

        Select languages = new Select("languages", new PropertyModel<String>(this, "selected"));


      languages.add(new SelectOption<String>("framework1", new Model<String>("Wicket")));

      languages.add(new SelectOption<String>("framework2", new Model<String>("Spring MVC")));

      languages.add(new SelectOption<String>("framework3", new Model<String>("JSF 2.0")));

      languages.add(new SelectOption<String>("Script1", new Model<String>("jQuery")));

      languages.add(new SelectOption<String>("Script2", new Model<String>("prototype")));

       //HTML for dropdown box

      <select wicket:id="languages">

      <optgroup label="Frameworks">

      <option wicket:id="framework1" >Wicket (1.4.7)</option>

      <option wicket:id="framework2" >Spring MVC (3.0)</option>

      <option wicket:id="framework3" >JSF (2.0)</option>


      <optgroup label="JavaScript">

      <option wicket:id="Script1" >jQuery (1.6.1)</option>

      <option wicket:id="Script2" >prototype (1.7)</option>



    20. Question 20. What Is Pallet Component In Apache-wicket?

      Answer :

      Wicket extension comes with a special “Palette” component, which render two select boxes, and allow user to move items from one select box into another.


      import org.apache.wicket.extensions.markup.html.form.palette.Palette;

       final Palette<Hosting> palette = new Palette<Hosting>("palette",

      new ListModel<Hosting>(selected),

      new CollectionModel<Hosting>(listHosting),

      renderer, 10, true);


      <span wicket:id="palette"></span>

    21. Question 21. How To Create Custom Validator In Apache-wicket?

      Answer :

      See summary steps to create a custom validator :

      1. Implements IValidator.

      import org.apache.wicket.validation.IValidator;

       public class Strong PasswordValidator implements IValidator<String>{



      2. Override validate(IValidatable validatable).

      public class StrongPasswordValidator implements IValidator<String>{



      public void validate(IValidatable<String> validatable) {

        //get input from attached component

      final String field = validatable.getValue();



      3. Attached custom validator to form component.

      public class CustomValidatorPage extends WebPage {

        public CustomValidatorPage(final PageParameters parameters) {

             final PasswordTextField password = new PasswordTextField("password",Model.of(""));

      //attached custom validator to password field

      password.add(new StrongPasswordValidator());




    22. Question 22. How To Integrate Apache-wicket With Spring?

      Answer :

      Override Wicket application init() method with this “addComponentInstantiationListener(new SpringComponentInjector(this));“.

      File : Wicket application class

      package com.withoutbook;

       import org.apache.wicket.protocol.http.WebApplication;

      import org.apache.wicket.spring.injection.annot.SpringComponentInjector;

      import com.withoutbook.user.SimplePage;

       public class WicketApplication extends WebApplication {


      public Class<SimplePage> getHomePage() {

        return SimplePage.class; // return default page



      protected void init() {


      addComponentInstantiationListener(new SpringComponentInjector(this));



      Now, you can inject Spring bean into Wicket component via @SpringBean.

    23. Question 23. How To Get Servletcontext In Apache-wicket Application?

      Answer :

      Yes, you can get the ServletContext class via Wicket’s WebApplication class like this :

      import javax.servlet.ServletContext;

      import org.apache.wicket.Page;

      import org.apache.wicket.protocol.http.WebApplication;

      import com.withoutbook.hello.Hello;

       public class CustomApplication extends WebApplication {


      public Class<? extends Page> getHomePage() {

        ServletContext servletContext = WebApplication.get().getServletContext();

      return Hello.class; //return default page



    24. Question 24. How To Keep File Validation In Apache-wicket If No File Has Been Selected?

      Answer :

      To fix it, just override the validateOnNullValue() method like this :

      FileUploadField fileUpload = new FileUploadField("fileupload",new Model<FileUpload>());

       fileUpload .add(new AbstractValidator() { 

              public boolean validateOnNullValue(){

              return true;


        protected void onValidate(IValidatable validatable) { 

      FileUpload fileUpload = (FileUpload) validatable.getValue();


           protected String resourceKey() {

          return "yourErrorKey";



      Now, when no file is selected, and submit button is clicked, validation will be performed.

    25. Question 25. How To Create 404 Error Page?

      Answer :











      public class WicketApplication extends WebApplication {


      protected void init() {

        mount(new QueryStringUrlCodingStrategy("error404",ErrorPage404.class));



Popular Interview Questions

All Interview Questions

All Practice Tests

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Apache POI PPT Tutorial