3.4页面干预类


3.4.1重设返回的页面

String interveneForward(String forwardPath, Map<String, Object> model, IEmapPage page)

forwardPath原始的返回页面路径

model需要传递到页面(JSP)中的数据

page当前的页面对象

样例,跳转到另一个JSP:

return page.getContainer().getApp().locateJSP("/temp/test.jsp");

上面这段代码表示将跳转到[应用目录]/web/temp/test.jsp

3.4.2修改页面返回的模型

IEmapModel interveneModel(IEmapModel model, IEmapPage.Action action)

model当前返回的模型

action绑定到页面的动作包装对象

样例,修改某列的标题:

if ("[绑定的动作别名]".equals(action.getAlias())) {
    CustomModel newModel = new CustomModel(model.getName(), model);
    ((CustomModel) newModel.getItem("[标识名称]")).setCaption("[新的标题]");
    return newModel;
}

3.4.3修改动作的执行

Object interveneActionExecute(DaoParam param, IEmapPage.Action action)

param当前执行动作所需的参数

action绑定到页面的动作包装对象

样例,修改动作执行前的参数及返回值:

if ("[绑定的动作别名]".equals(action.getAlias())) {
    param.addParam("参数名", "新的参数值");
    QueryResult<Map<String, ?>> r = (QueryResult<Map<String, ?>>) action.getAction().execute(param);
    r.get(0).put("标识名", "新的返回值");
    return r;
}

另外页面干预类继承了AbstractPageIntervention

这个类中有获取请求参数等相关的方法,具体说明见源码

results matching ""

    No results matching ""