Search in sources :

Example 1 with ViewMaker2

use of org.nutz.mvc.ViewMaker2 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());
}
Also used : ViewMaker(org.nutz.mvc.ViewMaker) ViewMaker2(org.nutz.mvc.ViewMaker2) View(org.nutz.mvc.View)

Aggregations

View (org.nutz.mvc.View)1 ViewMaker (org.nutz.mvc.ViewMaker)1 ViewMaker2 (org.nutz.mvc.ViewMaker2)1