1. 页面类及内置对象

    1. 所有页面类必须是 AppPage 或 AppSafePage 的子类,且每个应用都需要有继承于这两类的子类做为应用的基础类,如 AgentPage、AgentSafePage;

    2. AppPage 与 AppSafePage 的区别在于 AppSafePage 的 pageValidate 是无逻辑的,一般用于不需要权限的页面;

    3. AppPage 类的 API 及对象说明:

      1. 页面加载流程

        public void pageValidate(PageEvent event)
        

        在页面加载流程中,该方法为第一个执行的结点,用来验证页面的相关逻辑,如组件、权限等;

        public void pageBeginRender(PageEvent event)
        

        在页面加载流程中,该方法为第二个执行的结点,用来初始化相关数据,如 AppContext 就是在这个结点中实例化的;

        protected void cleanupAfterRender(IRequestCycle cycle)
        

        在页面加载流程中,该方法为第三个执行的结点,用来清除页面的相关数据;

        public void pageEndRender(PageEvent event)
        

        在页面加载流程中,该方法为第四个执行的结点,目前无实际操作;

        public void pageDetached(PageEvent event)
        

        在页面加载流程中,该方法为第五个执行的结点,用来释放一些连接资源,如数据库连接,这也是我们实现页面级事务的地方;

        public boolean existContext()
        

        是否已经存在 AppContext;

        public IAppContext getContext()
        

        获取 AppContex

      2. 页面内置对象 page

        public IPage page
        
      3. 页面内置对象 ctx

        public AppContext ctx
        
      4. 页面内置对象 module

        public AppModule module = AppModule.getInstance()
        

        module 为页面内置对象,module 内置了 StringUtil->string,TimeUtil->time,支持原 WADE 3.0 的参数转换,可以在 HTML 中直接使用,如:

        <span jwcid="@Insert" value="ognl:module.string.formatDecimal('#.##', 1243.123)"></span>
        <span jwcid="@Insert" value="ognl:module.time.getSysTime()"></span>
        <select jwcid="SELECT1@PropertySelection" model="ognl:module.getSelection(infos, 'VALUE', 'NAME')" value="ognl:info.SELECT1" desc="单列下拉"/>
        

        参数转换和原 WADE 3.0 一致,API 如下:

        public static IData getStaticData(IAppContext ctx, String type_id)
        public static IDataset getStaticList(IAppContext ctx, String type_id)
        public static IDataset getStaticList(IAppContext ctx, String type_id, String data_id)
        public static IDataset getStaticListByParent(IAppContext ctx, String type_id, String pdata_id)
        public static String getStaticValue(IAppContext ctx, String type_id, String data_id)
        public static String getStaticValue(IAppContext ctx, String table_name, String key, String name, String value)
        public static String getStaticValue(IAppContext ctx, String table_name, String[] keys, String name, String[] values)
        public static IData getStaticData(AppPage page, String type_id)
        public static String getStaticValue(AppPage page, String type_id, String data_id)
        public static String getStaticValue(AppPage page, String table_name, String key, String name, String value)
        public static String getStaticValue(AppPage page, String table_name, String[] keys, String name, String[] values)
        public static IPropertySelectionModel getStaticSelection(AppPage page, String table_name, String key, String name)
        public static IPropertySelectionModel getStaticSelection(AppPage page, String table_name, String key, String name, boolean isfull)
        public static IPropertySelectionModel getStaticSelection(AppPage page, String table_name, String key, String name, String column, String value)
        public static IPropertySelectionModel getStaticSelection(AppPage page, String table_name, String key, String name, String column, String value, boolean isfull)
        public static IPropertySelectionModel getStaticSelection(AppPage page, String table_name, String key, String name, String[] columns, String[] values)
        public static IPropertySelectionModel getStaticSelection(AppPage page, String table_name, String key, String name, String[] columns, String[] values, boolean isfull)
        public static IDataset getStaticList(AppPage page, String type_id)
        public static IDataset getStaticList(AppPage page, String type_id, String data_id)
        public static IDataset getStaticListByParent(AppPage page, String type_id, String pdata_id)
        public static IPropertySelectionModel getStaticSelection(AppPage page, String type_id)
        public static IPropertySelectionModel getStaticSelection(AppPage page, String type_id, boolean isfull)
        public static IPropertySelectionModel getStaticSelection(AppPage page, String type_id, String data_id)
        public static IPropertySelectionModel getStaticSelection(AppPage page, String type_id, String data_id, boolean isfull)
        public static IPropertySelectionModel getStaticSelectionByParent(AppPage page, String type_id, String pdata_id)
        public static IPropertySelectionModel getStaticSelectionByParent(AppPage page, String type_id, String pdata_id, boolean isfull)
        
      5. 页面内置对象 service

        protected NamingService	service	= NamingService.getInstance()
        

        NamingService 替换之前的 HttpHelper 对象

        service.httpService().invoke(String svcName, IData params, Pagination pagination, boolean iscatch)
        service.httpService().invoke(String svcName, IData params, Pagination pagination)
        service.httpService().invoke(String svcName, IData params, boolean iscatch)
        service.httpService().invoke(String svcName, IData params)
        
      6. 页面内置对象 log

        封装 Log4j 里的 Logger 对象,提供 Logger 的原有 API;

        protected ILogger log = LogFactory.getLog(getClass())
        
      7. 页面内置对象 global

        获取 global.properties 文件里的配置信息;

        protected IConfig global = ConfigUtil.global;
        public String getProperty(String name, String defval)
        public String getProperty(String name)
        
      8. 页面内置对象 config

        替换原有的 Common 对象对 xml 文件的读取功能,支持对 module.xml 配置文件的读取功能;

        protected IConfig config = ConfigUtil.module;
        public String getProperty(String path, String defval)
        public IData getProperties(String path)
        public IDataset getElements(String path)
        
      9. 页面内置对象 util

        替换原有的 Common 对象的相关功能

        protected BaseUtil util	= BaseUtil.getInstance();
        public IDataset getArrayByCodingStr(String namestr, String encodestr)
        public IData putDataByEntity(Object entity)
        public Object putEntityByData(Object entity, IData data)
        public Object callBean(String class_name, String method_name)
        public Object callBean(String class_name, String method_name, Object[] params)
        public Object callBean(String class_name, String method_name, Object[] params, Class[] types)
        public Object callBean(Object instance, String method_name, Object[] params, Class[] types)
        public Object reflectInvoke(Object bean, String funcName, Object[] params, Class[] types)
        public String getPartitionId(String id)
        public String getPartitionId(String id, int length)
        public static boolean equalsNVL(Object obj1, Object obj2)
        public static int hashCodeNVL(Object o)
        

      页面跳转方式同 WADE 3.0 无修改,在 WADE 4.0 里支持 Message 自定义 Message 页面;

      public void redirectToMsgByScript(int messageType, String message, String[] buttons, String[] funcs)
      public void redirectToMsgByScript(int messageType, String message, String func)
      public void redirectToMsgByScript(String message, String[] buttons, String[] funcs)
      public void redirectToMsgByScript(String message, String func)
      public void redirectToMsgByPopup(int messageType, String message, String pageName, String listener, String target)
      public void redirectToMsgByPopup(int messageType, String message, String pageName, String listener)
      public void redirectToMsgByPopup(String message, String pageName, String listener, String target)
      public void redirectToMsgByPopup(int messageType, String message, String pageName)
      public void redirectToMsgByPopup(String message, String pageName, String listener)
      public void redirectToMsgByPopup(int messageType, String message)
      public void redirectToMsgByPopup(String message, String pageName)
      public void redirectToMsgByPopup(String message)
      public void redirectToMsg(int messageType, String message, String[] pageNames, String[] listeners, String[] buttons, String[] targets)
      public void redirectToMsg(int messageType, String message, String[] pageNames, String[] listeners, String[] buttons)
      public void redirectToMsg(String message, String[] pageNames, String[] listeners, String[] buttons, String[] targets)
      public void redirectToMsg(int messageType, String message, String[] pageNames, String[] listeners)
      public void redirectToMsg(String message, String[] pageNames, String[] listeners, String[] buttons)
      public void redirectToMsg(String message, String[] pageNames, String[] listeners)
      public void redirectToMsg(int messageType, String message, String pageName, String listener, String target)
      public void redirectToMsg(int messageType, String message, String pageName, String listener)
      public void redirectToMsg(String message, String pageName, String listener, String target)
      public void redirectToMsg(String message, String pageName, String listener)
      public void redirectToMsg(int messageType, String message, String pageName)
      public void redirectToMsg(int messageType, String message)
      public void redirectToMsg(String message, String pageName)
      public void redirectToMsg(String message)
      public void redirectTo(String page_name, String event_name)
      public void redirectTo(String event_name)