有问题可以在公众号留言

2020年01月12日 评论 4 条 阅读 2,954 次

有问题可以在公众号留言

4 条留言  访客:0 条  博主:0 条

  1. 无敌龙

    你好,我使用flowable6.4进行开发,在设计表单中,发现表单例如下拉框、复选框和单选框只有填写文本,没有value的设置,于是我使用选择表达式,想通过方法获取后台字典数据,结果,模型部署后,申请任务时,此时应显示设置的表单,没有使用选择表达式时显示成功,使用选择表达式后,显示失败,这个是什么原因呢,要如何完成呢?

    逻辑上代码无措:

    表单设计器上的提示文本:
    可以使用表达式来动态填充选项,例如通过引用这样的变量 ${optionsVariable}. 这个表达式需要产生一个java对象(java.util)。带有选项对象的列表)或其json表示

    我的java代码:
    @Service(“flowFormUtils”)
    public class FlowFormUtils implements Serializable {

    private List getOptionList(String mark) {
    List dictList = DictUtils.getDictList(mark, null);
    List optionList = new ArrayList();
    dictList.forEach(e -> {
    Option option = new Option();
    option.setId(e.getValue());
    option.setName(e.getName());
    optionList.add(option);
    });
    return optionList;
    }
    }

    我的选择表达式:
    ${flowFormUtils.getOptionList(‘if_enable’)}

    • 哼哼的泰迪熊

      没用过自带的Form表单,所以不太清楚问题所在,抱歉

  2. 苏大大

    贴图贴不上,这是什么鬼,交流一下这么困难,刚刷了你几篇文章,写的都在点子上面,哈哈,源码跟出来的感觉是挺爽的,留言就是想说明一下这篇文章中提到的问题,交流一下哈
    这个问题有俩种解决办法
    1、UserTaskActivityBehavior.execute() 这个方法可以重写一下,里面有设置任务分类的地方,感觉不需要在监听器中搞
    2、UserTaskActivityBehavior.execute()里面有段很有意思的代码

    if (StringUtils.isNotEmpty(beforeContext.getCategory())) {
    String category = null;
    try {
    Object categoryValue = expressionManager.createExpression(beforeContext.getCategory()).getValue(execution);
    if (categoryValue != null) {
    category = categoryValue.toString();
    }
    } catch (FlowableException e) {
    category = beforeContext.getCategory();
    LOGGER.warn(“property not found in task category expression {}”, e.getMessage());
    }
    task.setCategory(category);
    }
    意思就是可以在流程变量中取,但是前提是beforeContext.getCategory()不能为空,而beforeContext是这么创建的:
    CreateUserTaskBeforeContext beforeContext = new CreateUserTaskBeforeContext
    因此可以设置userTask.getCategory()不为空,设置为一个常量,在流程启动的时候可以将流程定义中的分类给设置成流程变量,以供这里取值。

    ps:闲着无聊写的,也不知道大神有没有看懂,有兴趣可以给我发邮箱

    • 哼哼的泰迪熊

      谢谢,我去试试看的

给我留言

Copyright © 字痕随行 保留所有权利.   Theme  Ality

用户登录

分享到: