package org.nutz.mvc.view;

import org.nutz.ioc.Ioc;
import org.nutz.json.Json;
import org.nutz.json.JsonFormat;
import org.nutz.lang.Strings;
import org.nutz.mvc.View;
import org.nutz.mvc.ViewMaker;

/**
 * 默认的的视图工厂类
 * 
 * @author zozoh(zozohtnt@gmail.com)
 */
public class DefaultViewMaker implements ViewMaker {

	public View make(Ioc ioc, String type, String value) {
		if (type.equals("jsp")) {
			return new JspView(value);
		} else if (type.equals("json")) {
			if (Strings.isBlank(value)) {
				return new UTF8JsonView(JsonFormat.compact());
			} else {
				JsonFormat format = Json.fromJson(JsonFormat.class, value);
				return new UTF8JsonView(format);
			}
		} else if (type.equals("redirect") || type.equals("=>")) {
			return new ServerRedirectView(value);
		} else if (type.equals("void")) {
			return new VoidView();
		} else if (type.equals("ioc")) {
			return ioc.get(View.class, value);
		} else if (type.equals("http")) {
			int sc = Integer.parseInt(value);
			return new HttpStatusView(sc);
		}
		return null;
	}

}

package org.nutz.mvc.view;

import org.nutz.ioc.Ioc;
import org.nutz.json.Json;
import org.nutz.json.JsonFormat;
import org.nutz.lang.Strings;
import org.nutz.mvc.View;
import org.nutz.mvc.ViewMaker;

/**
 * 默认的的视图工厂类
 * 
 * @author zozoh(zozohtnt@gmail.com)
 */
public class DefaultViewMaker implements ViewMaker {

	public View make(Ioc ioc, String type, String value) {
		if (type.equals("jsp")) {
			return new JspView(value);
		} else if (type.equals("json")) {
			if (Strings.isBlank(value)) {
				return new UTF8JsonView(JsonFormat.compact());
			} else {
				JsonFormat format = Json.fromJson(JsonFormat.class, value);
				return new UTF8JsonView(format);
			}
		} else if (type.equals("redirect") || type.equals(">>")) {
			return new ServerRedirectView(value);
		} else if (type.equals("void")) {
			return new VoidView();
		} else if (type.equals("ioc")) {
			return ioc.get(View.class, value);
		} else if (type.equals("http")) {
			int sc = Integer.parseInt(value);
			return new HttpStatusView(sc);
		}
		return null;
	}

}

change redirect alias from "=>" to ">>"