/*******************************************************************************
 * This file is part of hommkmessage.
 * 
 * hommkmessage is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * hommkmessage is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with hommkmessage.  If not, see <http://www.gnu.org/licenses/>.
 ******************************************************************************/
package com.appspot.hommkmessage.client.view;

import com.appspot.hommkmessage.client.LocalStorage;
import com.appspot.hommkmessage.shared.DateFormatter;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;

public class Hommk_message implements EntryPoint {

	@Override
	public void onModuleLoad() {
		String password = Window.Location.getParameter("key");
		validateParameters(password);

		final ListView listView = createListView(password);

		SearchHandler search = initSearch(listView);
		search.submitSearch();
	}

	private void validateParameters(String password) {
		if (password == null) {
			throw new IllegalArgumentException("parameter key is not set");
		}
	}

	private ListView createListView(String password) {
		RootPanel.get("listViewContainer").getElement().setInnerHTML("");
		RootPanel.get("listViewContainer").add(
				new HTML("<b>Nachrichten sortiert nach Upload-Datum:</b>"));

		DateFormatter dateFormatter = new DateFormatter();
		LocalStorage localStorage = new LocalStorage();
		final ListView listView = new ListView(dateFormatter, localStorage,
				password);
		RootPanel.get("listViewContainer").add(listView);
		return listView;
	}

	private SearchHandler initSearch(final ListView listView) {
		final Button searchButton = new Button("Suche");
		final TextBox searchTextField = new TextBox();
		searchTextField.setText("");
		searchTextField.setFocus(true);
		searchButton.addStyleName("sendButton");
		HorizontalPanel searchPanel = new HorizontalPanel();
		searchPanel.add(searchTextField);
		searchPanel.add(searchButton);
		RootPanel.get("searchLineContainer").add(searchPanel);

		SearchHandler handler = new SearchHandler(listView, searchTextField);
		searchButton.addClickHandler(handler);
		searchTextField.addKeyUpHandler(handler);
		return handler;
	}
}

@@ -1737,16 +1737,217 @@
 null) %7B%0A
+%09%09%09String error = %22parameter key is required%22;%0A%09%09%09RootPanel%0A%09%09%09%09%09.get(%22listViewContainer%22)%0A%09%09%09%09%09.getElement()%0A%09%09%09%09%09.setInnerHTML(%0A%09%09%09%09%09%09%09%22%3Cp class=%5C%22serverResponseError%5C%22%3E%22 + error%0A%09%09%09%09%09%09%09%09%09+ %22%3C/p%3E%22);%0A
 %09%09%09throw
@@ -1980,34 +1980,13 @@
 ion(
-%22parameter key is not set%22
+error
 );%0A%09

Improve error message.