Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
wicket: submitting a form
<html xmlns:wicket="" >
<title>Wicket Quickstart Archetype Homepage</title>
<form wicket:id="searchform">
<input type="text" wicket:id="textField" name="query"/>
<input type="submit" value="Search"/>
package com.mycompany;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.Model;
import org.apache.wicket.protocol.http.WebRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* Homepage
public class HomePage extends WebPage {
private static final long serialVersionUID = 1L;
private Logger logger = LoggerFactory.getLogger(getClass());
public HomePage(final PageParameters parameters) {
String q = parameters.getString("q");
final Model txtModel = new Model(q) {
public Serializable getObject() {
if (super.getObject() == null)
return "";
return super.getObject();
TextField text = new TextField("textField", txtModel);
Form form = new Form("searchform") {
protected void onSubmit() { + ": onSubmit textField object:" + txtModel.getObject());
PageParameters pp = new PageParameters();
pp.add("q", txtModel.getObject().toString());
setResponsePage(HomePage.class, pp);
form.add(text); + ": HomePage ctor params: " + parameters);
public String getMethod() {
return ((WebRequest) getRequest()).getHttpServletRequest().getMethod();
package com.mycompany;
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 {
* Constructor
public WicketApplication() {
* @see org.apache.wicket.Application#getHomePage()
public Class<HomePage> getHomePage() {
return HomePage.class;
protected void init() {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.