package edu.rit.csh;

import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;


/**
 * Form for the creation of a new Book.
 * @author scott
 *
 */
public class SearchBookForm extends Form {
	private static final long serialVersionUID = 8123125720433269221L;
	
	private final TextField title;
	private final TextField author;
	private final Button submit;

	public SearchBookForm(String id) {
		super(id);
		
		title = new TextField("title");
		title.setDefaultModel(Model.of(""));
		title.setLabel(Model.of("Title"));
		add(title);
		
		author = new TextField("author");
		author.setDefaultModel(Model.of(""));
		author.setLabel(Model.of("Author"));
		author.setRequired(false);
		add(author);
		
		submit = new Button("searchBookSubmit");
		add(submit);
		setDefaultModel(new CompoundPropertyModel<SearchBookForm>(this));
	}
	
	@Override
	public void onSubmit(){
		String titleStr = (String)title.getDefaultModelObject();
		String authorStr = (String)author.getDefaultModelObject();
		PageParameters params = new PageParameters();
		params.add("title", titleStr);
		if (authorStr != null){
			params.add("author", authorStr);
		}
		setResponsePage(PublicSearchResultsPage.class, params);
	}

}

@@ -534,31 +534,22 @@
 private 
-final TextField
+String
  title;%0D
@@ -562,192 +562,191 @@
 ate 
-final TextField author;%0D%0A%09private final Button submit;%0D%0A%0D%0A%09public SearchBookForm(String id) %7B%0D%0A%09%09super(id);%0D%0A%09%09%0D%0A%09%09title = new TextField(%22title%22);%0D%0A%09%09title.setDefaultModel(Model.of(%22%22)
+String author;%0D%0A%0D%0A%09public SearchBookForm(String id) %7B%0D%0A%09%09super(id);%0D%0A%09%09setDefaultModel(new CompoundPropertyModel%3CSearchBookForm%3E(this));%0D%0A%09%09%0D%0A%09%09TextField title = new TextField(%22title%22
 );%0D%0A
@@ -800,24 +800,34 @@
 le);%0D%0A%09%09%0D%0A%09%09
+TextField 
 author = new
@@ -853,49 +853,8 @@
 );%0D%0A
-%09%09author.setDefaultModel(Model.of(%22%22));%0D%0A
 %09%09au
@@ -945,17 +945,12 @@
 %0D%0A%09%09
-submit = 
+add(
 new 
@@ -979,261 +979,57 @@
 it%22)
-;%0D%0A%09%09add(submit);%0D%0A%09%09setDefaultModel(new CompoundPropertyModel%3CSearchBookForm%3E(this));%0D%0A%09%7D%0D%0A%09%0D%0A%09@Override%0D%0A%09public void onSubmit()%7B%0D%0A%09%09String titleStr = (String)title.getDefaultModelObject();%0D%0A%09%09String authorStr = (String)author.getDefaultModelObject();
+);%0D%0A%0D%0A%09%7D%0D%0A%09%0D%0A%09@Override%0D%0A%09public void onSubmit()%7B
 %0D%0A%09%09
@@ -1102,19 +1102,16 @@
 %22, title
-Str
 );%0D%0A%09%09if
@@ -1118,19 +1118,16 @@
  (author
-Str
  != null
@@ -1160,19 +1160,16 @@
 , author
-Str
 );%0D%0A%09%09%7D%0D

Refactor to properly use compound property model.