• 首页
  • 产品中心
    • 数式Oinone四大产品

      低代码开发平台无代码开发平台集成开发平台AI大模型开发
    • 数式Oinone体系能力

      用户与组织权限管理文件管理消息中心国际化业务审计
    • 数式Oinone核心产品特性

      低无一体面向软件公司场景无限制应用级扩容可分可合
  • 服务中心
    • 客户服务

      预约演示方案咨询私有部署找人定制
    • 开发者

      问答下载
    • Oinone学院

      社区学习

    《精讲面向软件公司的低代码平台——以Oinone为例》

  • 合作伙伴
    渠道申请伙伴名录专家库
  • 关于数式
0571-88757863

Development Aid:Automatic Form Filling with User-related Information


In practical project business scenarios, there is often a requirement to automatically embed user-related information such as user name and department into forms to achieve automatic form data filling. This article elaborates on the specific implementation steps to achieve this function.

Ⅰ. Implementation Steps

(Ⅰ) Define Base Class Model

  1. Define a base class model (e.g., AbstractDeptModel) containing attributes (fields) that need to be automatically filled; any model requiring automatic user information form filling inherits from this model:
@Model.model(AbstractDeptModel.MODEL_MODEL)
@Model(displayName = "Abstract Model with Login User Information")
@Model.Advanced(type= ModelTypeEnum.ABSTRACT)
public abstract class AbstractDeptModel extends IdModel  {

    public static final String MODEL_MODEL = "hr.simple.AbstractDeptModel";

    @Field.many2one
    @UxForm.FieldWidget(@UxWidget(readonly = "true"))
    @Field(displayName = "Registrant", summary = "Registrant", required = true, priority = 11)
    private PamirsEmployee registrant;

    @Field.String
    @Field(displayName = "Registrant Code", invisible = true, priority = 12)
    private String registrantCode;

    @Field.many2one
    @UxForm.FieldWidget(@UxWidget(readonly = "true"))
    @Field.Relation(relationFields = {"deptCode"}, referenceFields = {"code"})
    @Field(displayName = "Affiliated Department", priority = 13)
    private PamirsDepartment department;

    @Field.String
    @Field(displayName = "Affiliated Department Code", invisible = true, priority = 14)
    private String deptCode;
}
  1. According to Oinone model inheritance rules, sub-models inherit all functions of the parent model; thus, only the data filling logic for the base class AbstractDeptModel needs to be written:

Note:

In the example code below, both the registrant and affiliated department are obtained from the Session.

@Slf4j
@Component
@Model.model(AbstractDeptModel.MODEL_MODEL)
public class AbstractDeptModelAction {

    @Function(openLevel = FunctionOpenEnum.API)
    @Function.Advanced(type = FunctionTypeEnum.QUERY)
    public AbstractDeptModel construct(AbstractDeptModel data) {
        data.setRegistrant(HrSimpleSession.getEmployee());
        data.setDepartment(HrSimpleSession.getDepartment());
        return data.construct();
    }

}

(Ⅱ) Define Business Model

Models requiring automatic user information form filling inherit from this model, i.e., inherit from AbstractDeptModel:

@Model.model(UnitProjectFiling.MODEL_MODEL)
@Model(displayName = "Project Filing Registration", labelFields = {"projectName"})
@Model.Advanced(unique = {"projectNo"})
public class UnitProjectFiling extends AbstractDeptModel {

    public static final String MODEL_MODEL = "hr.simple.UnitProjectFiling";

    @UxForm.FieldWidget(@UxWidget(span = 2))
    @Field(displayName = "Project Name")
    private String projectName;

    @Field(displayName = "Project Number")
    private String projectNo;

    @Field.Text
    @Field(displayName = "Project Overview")
    private String projectDemo;

    // Other attributes

}

(Ⅲ) Running Effect

Through the above steps, models inheriting from the base class AbstractDeptModel will automatically fill in user information (such as registrant and affiliated department) on the creation page:

Tip:

The logic for automatic form filling can be implemented using the思路 (approach) in this article. Prerequisite: The fields to be automatically filled can be obtained based on the system environment and the logged-in user.

Edit this page
Last Updated:1/15/26, 4:02 AM
Prev
Development Aid:Generating API Documentation with GraphQL
Next
Release Process:Back-end release process
默认页脚
Copyright © 2026 Mr.Hope