当基于Crystal的静态Portlet开发完成后,在与后台服务联调前,还需要将Portlet转换成基于测试数据的动态Portlet。具体步骤如下:

分步指南

  1. 复制Portlet项目,并修改相关的pom.xml、src/main/webapp/WEB-INF/liferay-plugin-package.xml、src/main/webapp/WEB-INF/liferay-plugin-package.properties文件中的Atifact-ID、module-id等信息,区别原静态Portlet项目,防止两个项目重复,导致不能在一个环境中运行;
  2. 修改src/main/webapp/WEB-INF/portlet.xml、src/main/webapp/WEB-INF/liferay-portlet.xml、/static-development-portlet/src/main/webapp/WEB-INF/liferay-display.xml中的portlet-name等信息,区别原项目的portlet-name信息,防止与原静态portlet不能在一个环境中运行;
  3. 修改src/main/webapp/WEB-INF/spring下****-portlet.xml文件名,保持****部分与相应portlet-name性息(去除横杠)一致;
  4. 查看****-portlet.xml文件中定义的包路径是否是项目所需,否则修改;
  5. 查看src/main/java下的包路径是否跟****-portlet.xml文件中定义的包路径一致,否则修改;

创建测试数据项目:

  1. 创建Java Maven项目****-service-stub,结构如下:

  2. 修改pom.xml文件,添加远程服务api包依赖:
  3. 根据api实现相关服务的实现类,但方法内部只需返回设计的测试数据即可,如下:
    @Service
    public class ApplicationManager implements ApplicationService {
    /* (non-Javadoc)
    * @see com.gsoft.portlet.uum.application.ApplicationService#list()
    */
    @Override
    public List<Application> list() {
    List<Application> list = new ArrayList<Application>();
    for(int i = 0; i < 20; i++){
    Application app = new Application();
    app.setId(new Long(i));
    app.setName("Name " + i);
    app.setCode("code " + i);
    app.setUrl("http://localhsot/" + i);
    app.setDisabled(i %3 == 0 ? true : false);
    list.add(app);
    }
    return list;
    }
    /* (non-Javadoc)
    * @see com.gsoft.portlet.uum.application.ApplicationService#getById(java.lang.Long)
    */
    @Override
    public Application getById(Long id) {
    Application app = new Application();
    app.setId(10L);
    app.setName("Name 10");
    app.setCode("code 10");
    app.setUrl("http://localhsot/10");
    return app;
    }
    }

修改静态Portlet项目为动态测试Portlet:

  1. 在Porltet项目中引入测试数据项目及远程服务接口;
  2. 修改src/main/java下相应Portlet类,调用远程api及测试数据服务,返回测试数据;

    @Controller
    public class ApplicationManagementPortlet extends AbstractCrystalPortlet { @Resource
    private AuthSystemService authSystemService;
    @RequestMapping
    public String view(Model model, RenderRequest request) {
    List<AuthSystemDto> result = authSystemService.finaAllAuthSystemList();
    request.setAttribute("result", result);
    return "view";
    }
    @RequestMapping(params = "action=add")
    public String view4add(Model model, @Param String rediract) {
    model.addAttribute("rediract", rediract);
    return "add";
    } @RequestMapping(params = "action=edit")
    public String view4edit(Model model, @RequestParam String rediract,@RequestParam Long id) {
    model.addAttribute("rediract", rediract);
    AuthSystemDto authSystemDto = authSystemService.findOne(id);
    model.addAttribute("system", authSystemDto);
    return "add";
    } @RequestMapping(params = "action=del")
    public String delete(Model model, RenderRequest request, @RequestParam Long id) {
    authSystemService.deleteAuthSystem(id);
    return "pop_up_success";
    }
    @RequestMapping(params = "action=editState")
    public String editState(Model model, RenderRequest request, @RequestParam Long id,@RequestParam String state) {
    AuthSystemDto authSystemDto = new AuthSystemDto();
    authSystemDto.setId(id);
    if(StringUtils.equals(UserRepConstants.UserRepState.DISABLE, state)) {
    authSystemDto.setState(UserRepConstants.UserRepState.ENABLE);
    } else {
    authSystemDto.setState(UserRepConstants.UserRepState.DISABLE);
    }
    authSystemService.updateAuthSystemState(authSystemDto );
    return "pop_up_success";
    } @RequestMapping(params = "action=save")
    public String save(Model model, @ModelAttribute("authSystem")AuthSystemDto authSystem, @RequestParam String rediract){
    if(StringUtils.isEmpty(authSystem.getState())) {
    authSystem.setState("1");
    }
    if(authSystem.getId() == null) {
    authSystemService.saveAuthSystem(authSystem);
    }else {
    authSystemService.updateAuthSystem(authSystem);
    }
    model.addAttribute("rediract", rediract);
    return "pop_up_success";
    } @RequestMapping(params = "action=check")
    public ModelAndView checkDupCode(Model model, RenderRequest request, @RequestParam Long id,@RequestParam String code) throws JsonProcessingException {
    AuthSystemDto system = new AuthSystemDto();
    system.setCode(code);
    system.setId(id);
    Boolean exists = authSystemService.existsAuthSystemCode(system);
    Map<String, Object> result = new HashMap<String, Object>();
    result.put("success", Boolean.TRUE);
    result.put("data", exists);
    return ajax(result);
    }
    }

      

  3. 修改src/main/webapp/WEB-INF/jsp下相关jsp文件,增加标签,获取后台portlet类返回的数据,并依据原静态HTML代码格式,动态生成相应的代码。

  

开发Portlet第二步:如何将Crystal静态Portlet转变成基于测试数据的动态Portlet?的更多相关文章

  1. 全动态Portlet点击后选中样式

    1  背景概述 在配置公司云平台的帮助信息过程中,由于使用的全动态portlet的数据URL获取到的是静态数据,没有办法在后台做选中的逻辑判断,所以需要在前台来控制选中列表的样式,这里将对前台选中列表 ...

  2. IOS开发中制作属于自己的静态库.a、资源库.bundle、.framework

    一.什么是库        库实际上是一种代码共享的方式,主要用于代码重用和源码隐藏,通常分为动态库和静态库. 静态库:链接时完整的拷贝至可执行文件中,被多次使用就有多份冗余拷贝. 动态库:链接时不复 ...

  3. 目前以lib后缀的库有两种,一种为静态链接库(Static Libary,以下简称“静态库”),另一种为动态连接库(DLL,以下简称“动态库”)的导入库(Import Libary,以下简称“导入库”)。静态库是一个或者多个obj文件的打包

    前以lib后缀的库有两种,一种为静态链接库(Static Libary,以下简称“静态库”),另一种为动态连接库(DLL,以下简称“动态库”)的导入库(Import Libary,以下简称“导入库”) ...

  4. [开发技巧]·Python极简实现滑动平均滤波(基于Numpy.convolve)

    [开发技巧]·Python极简实现滑动平均滤波(基于Numpy.convolve) ​ 1.滑动平均概念 滑动平均滤波法(又称递推平均滤波法),时把连续取N个采样值看成一个队列 ,队列的长度固定为N ...

  5. 【JAVA】JSP+layui框架 静态表格转化成数据表格

    <table lay-filter="demo" class="layui-table" id="excTable"> < ...

  6. Android开发之常用必备工具类图片bitmap转成字符串string与String字符串转换为bitmap图片格式

    作者:程序员小冰,CSDN博客:http://blog.csdn.net/qq_21376985 QQ986945193 博客园主页:http://www.cnblogs.com/mcxiaobing ...

  7. iOS开发——高级篇——换肤、静态库

    一.换肤 1.思路1> 解决方案1,使用颜色作为图片素材的命名关键字 问题1:要保证每套图片的文件名 颜色+ 名称.png的格式比较麻烦 问题2:如果要将某一个图片应用到其他皮肤不方便2> ...

  8. 安卓开发, 遇到WebView不能加载静态网页, WebView显示 "net::ERR_PROXY_CONNECTON_FAILED"

    http://blog.csdn.net/zhouchangshi/article/details/44454695 Android开发中遇到网络连接问题, 要找WebView中显示一个静态的网页, ...

  9. android应用开发-从设计到实现 3-4 静态原型的状态栏

    静态原型的状态栏 状态栏Symbol 状态栏似乎非常复杂,有wifi信号.手机信号.时间.电量等信息,幸好Sketch原生就自带的现成组件,你能够直接拿过来就用了.当然.你也能够自己一个一个去画,只是 ...

随机推荐

  1. Java数组的复制Arrays.copyOf()、System.arraycopy()、nums.clone()

    public static native void arraycopy(Object src, int srcPos, Object dest, int destPos, int length); a ...

  2. jQuery中attr()方法用法实例

    本文实例讲述了jQuery中attr()方法用法.分享给大家供大家参考.具体分析如下: 此方法设置或返回匹配元素的属性值. attr()方法根据参数的不同,功能也不同. 语法结构一: 获取第一个匹配元 ...

  3. LeetCode 242 Valid Anagram

    Problem: Given two strings s and t, write a function to determine if t is an anagram of s. For examp ...

  4. DOM对象与JQUERY对象的相互转化

    普通处理,通过标准JavaScript处理: 1 var p = document.getElementById('imooc') 2 p.innerHTML = '您好!学习jQuery才是最佳的途 ...

  5. mysql 得到重复的记录

    select devicetoken from client_user group by devicetoken having count(devicetoken)>1

  6. poj1703(各种姿势)

    题目链接:http://poj.org/problem?id=1703 题意:有n个人分别属于两个团伙,接下来m组形如 ch, x, y的数据,ch为"D"表示 x, y属于不同的 ...

  7. mysql编码设置

    一:mysql字符集 mysql的字符集支持(Character Set Support)有两个类型:字符集(Character set)和连接校对(Collation).对于字符集的支持细化到四个层 ...

  8. LoadRunner函数

    一.基础函数简介 在VU左边导航栏中,有三个LoadRunner框架函数,分别是vuser_init().Action().vuser_end().这三个函数存在于任何Vuser类型的脚本中. vus ...

  9. CocoaPods 安装

    虽然网上关于CocoaPods安装教程多不胜数,但是我在安装的过程中还是出现了很多错误,所以大家可以照下来步骤装一下,我相信会很好用. 前言 在iOS项目中使用第三方类库可以说是非常常见的事,但是要正 ...

  10. windows重新获取IP

    win+r------->cmd------>ipconfig /release (释放ip) ipconfig /renew  重新获取ip