//#import Util.js
//#import $owl_common_views:services/modelService.jsx
function main(){
    var params = JSON.parse($body);
    var fromAppId = params.fromAppId;
    var viewId = params.viewId;

    if(fromAppId === 'owl_common_views' && viewId.indexOf('owl_common_views')===0){
        var  view = owl_common_viewsService.get(viewId);
        if(view && view.code){
            var ret = {
                state:'ok',
                view:view.code
            };
            out.print(JSON.stringify(ret));
            return;
        }
        else{
            var ret = {
                state:'err',
                msg:'获取视图模板失败'
            };
            out.print(JSON.stringify(ret));
            return;
        }

    }
    else{
        var view = $.getAppProgram(fromAppId, viewId);
        if(view){
            var ret = {
                state:'ok',
                view:view
            };
            out.print(JSON.stringify(ret));
            return;

        }
        else{
            var ret = {
                state:'err',
                msg:'获取视图模板失败'
            };
            out.print(JSON.stringify(ret));
            return;

        }
    }



}
main();