use of org.nutz.mvc.View in project nutz by nutzam.
the class ViewZone method makeView.
public static View makeView(NutConfig config, ActionInfo ai, String viewType, boolean allowProxy) {
if (Strings.isBlank(viewType))
return new VoidView();
String str = viewType;
int pos = str.indexOf(':');
String type, value;
if (pos > 0) {
type = Strings.trim(str.substring(0, pos).toLowerCase());
value = Strings.trim(pos >= (str.length() - 1) ? null : str.substring(pos + 1));
} else {
type = str;
value = null;
}
if (allowProxy && "re".equals(type)) {
View dft = null;
if (value != null)
dft = makeView(config, ai, value, false);
return new ViewZone(config, ai, dft);
}
for (ViewMaker maker : ai.getViewMakers()) {
if (maker instanceof ViewMaker2) {
View view = ((ViewMaker2) maker).make(config, ai, type, value);
if (view != null)
return view;
}
View view = maker.make(config.getIoc(), type, value);
if (null != view)
return view;
}
throw Lang.makeThrow("Can not eval %s(\"%s\") View for %s", viewType, str, ai.getMethod());
}
use of org.nutz.mvc.View in project nutz by nutzam.
the class ActionFiltersProcessor method process.
public void process(ActionContext ac) throws Throwable {
for (ActionFilter filter : filters) {
View view = filter.match(ac);
if (null != view) {
ac.setMethodReturn(view);
renderView(ac);
return;
}
}
if (proxyProcessor == null) {
doNext(ac);
} else {
if (lastProcessor != null)
lastProcessor.setNext(next);
proxyProcessor.process(ac);
}
}
use of org.nutz.mvc.View in project nutz by nutzam.
the class ViewZone method render.
public void render(HttpServletRequest req, HttpServletResponse resp, Object obj) throws Throwable {
if (obj == null)
dft.render(req, resp, obj);
else {
View v = makeView(config, ai, obj.toString(), false);
if (index > -1) {
Object re = Mvcs.getActionContext().getMethodArgs()[index];
ViewProcessor.putRequestAttribute(req, re);
v.render(req, resp, re);
} else {
v.render(req, resp, null);
}
}
}
Aggregations