/* 
 * Qlue Web Application Framework
 * Copyright 2009 Ivan Ristic <ivanr@webkreator.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.webkreator.qlue.example.pages;

import java.io.PrintWriter;

import com.webkreator.qlue.Page;
import com.webkreator.qlue.QlueParameter;
import com.webkreator.qlue.view.View;

/**
 * An example page that has one parameter and produces output
 * by writing directly to the client.
 */
public class helloStranger extends Page {

	@QlueParameter(mandatory = true, maxSize = 10, pattern = "^[a-zA-Z]+$")
	public String name;

	@Override
	public View onGet() throws Exception {
		PrintWriter out = context.response.getWriter();
		
		context.response.setContentType("text/plain");
		
		if (errors.hasErrors()) {
			for (com.webkreator.qlue.Error e : errors.getAllErrors()) {
				out.print(e.getMessage());
				if (e.getField() != null) {
					out.print(" [" + e.getField() + "]");
					out.println();
				}
			}
			
			return null;
		}

		if (name == null) {
			out.println("Hello Stranger!");
		} else {
			out.println("Hello " + name + "!");
		}
		
		throw new Exception("test");

		//return null;
	}
}

@@ -1046,11 +1046,12 @@
 y = 
-tru
+fals
 e, m
@@ -1219,329 +1219,10 @@
 r();
-%0D%0A%09%09%0D%0A%09%09context.response.setContentType(%22text/plain%22);%0D%0A%09%09%0D%0A%09%09if (errors.hasErrors()) %7B%0D%0A%09%09%09for (com.webkreator.qlue.Error e : errors.getAllErrors()) %7B%0D%0A%09%09%09%09out.print(e.getMessage());%0D%0A%09%09%09%09if (e.getField() != null) %7B%0D%0A%09%09%09%09%09out.print(%22 %5B%22 + e.getField() + %22%5D%22);%0D%0A%09%09%09%09%09out.println();%0D%0A%09%09%09%09%7D%0D%0A%09%09%09%7D%0D%0A%09%09%09%0D%0A%09%09%09return null;%0D%0A%09%09%7D
+%09%09
 %0D%0A%0D%0A
@@ -1339,52 +1339,16 @@
 %0A%09%09%7D
+%09%09%0D%0A
 %0D%0A%09%09
-%0D%0A%09%09throw new Exception(%22test%22);%0D%0A%0D%0A%09%09//
 retu

Tidy up.