Die meistgefragten Interviewfragen und Antworten sowie Online-Tests
Lernplattform fur Interviewvorbereitung, Online-Tests, Tutorials und Live-Ubungen

Baue deine Fahigkeiten mit fokussierten Lernpfaden, Probetests und interviewreifem Inhalt aus.

WithoutBook vereint themenbezogene Interviewfragen, Online-Ubungstests, Tutorials und Vergleichsleitfaden in einem responsiven Lernbereich.

Interview vorbereiten

Apache Wicket Interviewfragen und Antworten

Frage 6. Dependency to start wicket.

<dependency>
<groupid>org.apache.wicket</groupid>
<artifactid>wicket</artifactid>
<version>1.4.17</version>
</dependency>

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.

Ist das hilfreich? Kommentar hinzufugen Kommentare ansehen
 

Frage 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 : WelcomeApplication.java – 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 {
 
@Override
public Class<? extends Page> getHomePage() {
return Hello.class; //return default page
}
 
}

File : Hello.java

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

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

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="http://java.sun.com/xml/ns/j2ee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<display-name>Wicket Web Application</display-name>
 
<filter>
<filter-name>wicket.wicketTest</filter-name>
<filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
<init-param>
<param-name>applicationClassName</param-name>
<param-value>com.withoutbook.WelcomeApplication</param-value>
</init-param>
</filter>
 
<filter-mapping>
<filter-name>wicket.wicketTest</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
 
</web-app>

Ist das hilfreich? Kommentar hinzufugen Kommentare ansehen
 

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

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

Ist das hilfreich? Kommentar hinzufugen Kommentare ansehen
 

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

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

Ist das hilfreich? Kommentar hinzufugen Kommentare ansehen
 

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

Ist das hilfreich? Kommentar hinzufugen Kommentare ansehen
 

Am hilfreichsten laut Nutzern:

Copyright © 2026, WithoutBook.