天翎MyApps技术社区 - 低代码平台 | 流程管理系统 | BPM软件

 找回密码
 注册成为天翎用户
查看: 1896|回复: 0

[源码] 在源码获取表单所有字段名称以及字段的类型【源码-获取表单字段名称及其类型】

[复制链接]
irene 发表于 2012-7-19 00:48:52 | 显示全部楼层 |阅读模式
本帖最后由 bess 于 2012-12-31 15:00 编辑

Q:如何在平台源代码中获取所有表单字段名称以及字段的类型?
A:可在源码中任意新建一个类,添加一个方法,方法的代码如下:
  1. public String tt() throws Exception {
  2.                 // TODO Auto-generated method stub
  3.                 String rtn = "555";//rtn变量只是用于便于测试而添加的,实际操作用可将其去掉
  4.                 DocumentProcessBean dpb = new DocumentProcessBean(
  5.                                 "11de-ef9e-c010eee1-860c-e1cadb714510");//参数为软件应用id
  6.                 Document d = (Document) dpb
  7.                                 .doView("11e1-ce7f-67bd1958-b516-4f113d2b84ed");//参数为表单记录id,即docid
  8.                 FormProcessBean fpb = new FormProcessBean();
  9.                 Form f = fpb.doViewByFormName("字段类型",
  10.                                 "11de-ef9e-c010eee1-860c-e1cadb714510");//参数为软件应用id
  11.                 Collection formfield = f.getAllFields();
  12.                 for (Iterator<FormField> iterator = formfield.iterator(); iterator
  13.                                 .hasNext();) {
  14.                         FormField field = (FormField) iterator.next();
  15.                         String name = field.getName();
  16.                         Item it = d.findItem(name);
  17.                         if (it != null) {
  18.                                 String type = it.getType();
  19.                                 System.out.println(name + "——的类型是:" + type);
  20.                         }
  21.                 }
  22.                 return rtn;
  23.         }
复制代码

本版积分规则

QQ|手机版|天翎MyApps技术社区 ( 粤ICP备11093750号 )

GMT+8, 2026-8-12 16:03

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表