or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

data-providers.mdexpressions.mdform-management.mdindex.mdintegration-extensions.mdmodels-services.mdsecurity-validation.mdstorage-io.mdtemplates.md
tile.json

tessl/maven-com-liferay--com-liferay-dynamic-data-mapping-api

Liferay Dynamic Data Mapping API provides comprehensive APIs for creating, managing, and processing dynamic forms and data structures within Liferay Portal.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/com.liferay/com.liferay.dynamic.data.mapping.api@35.2.x

To install, run

npx @tessl/cli install tessl/maven-com-liferay--com-liferay-dynamic-data-mapping-api@35.2.0

index.mddocs/

Liferay Dynamic Data Mapping API

The Liferay Dynamic Data Mapping (DDM) API provides comprehensive functionality for creating, managing, and processing dynamic forms, data structures, and templates within Liferay Portal. This OSGi bundle enables developers to build flexible form-based applications with support for complex field types, data validation, expression evaluation, template rendering, and external data integration.

Package Information

  • Package Name: com.liferay.dynamic.data.mapping.api
  • Package Type: maven
  • Language: Java (OSGi Bundle)
  • Installation:
    <dependency>
      <groupId>com.liferay</groupId>
      <artifactId>com.liferay.dynamic.data.mapping.api</artifactId>
      <version>35.2.1</version>
      <scope>provided</scope>
    </dependency>

Core Imports

import com.liferay.dynamic.data.mapping.model.DDMStructure;
import com.liferay.dynamic.data.mapping.model.DDMTemplate;
import com.liferay.dynamic.data.mapping.model.DDMFormInstance;
import com.liferay.dynamic.data.mapping.model.DDMForm;
import com.liferay.dynamic.data.mapping.model.DDMFormLayout;
import com.liferay.dynamic.data.mapping.service.DDMStructureLocalService;
import com.liferay.dynamic.data.mapping.service.DDMTemplateLocalService;
import com.liferay.dynamic.data.mapping.service.DDMFormInstanceLocalService;
import com.liferay.dynamic.data.mapping.storage.DDMFormValues;
import com.liferay.dynamic.data.mapping.util.DDMFormFactory;
import com.liferay.dynamic.data.mapping.form.field.type.DDMFormFieldType;

Basic Usage

@Component
public class MyDDMService {
    
    @Reference
    private DDMStructureLocalService ddmStructureLocalService;
    
    @Reference 
    private DDMFormInstanceLocalService ddmFormInstanceLocalService;
    
    public DDMStructure createStructure(long groupId, String name, String definition) 
        throws PortalException {
        
        ServiceContext serviceContext = new ServiceContext();
        serviceContext.setScopeGroupId(groupId);
        
        Map<Locale, String> nameMap = new HashMap<>();
        nameMap.put(LocaleUtil.getDefault(), name);
        Map<Locale, String> descriptionMap = new HashMap<>();
        descriptionMap.put(LocaleUtil.getDefault(), name);
        
        return ddmStructureLocalService.addStructure(
            null, // externalReferenceCode
            0L, // userId
            groupId,
            0L, // parentStructureId
            PortalUtil.getClassNameId(DDMContent.class),
            null, // structureKey - auto-generated
            nameMap,
            descriptionMap,
            definition,
            "json", // storageType
            serviceContext
        );
    }
    
    public DDMFormInstance createFormInstance(long groupId, long structureId, 
        String formName) throws PortalException {
        
        DDMStructure structure = ddmStructureLocalService.getStructure(structureId);
        DDMForm ddmForm = structure.getDDMForm();
        
        ServiceContext serviceContext = new ServiceContext();
        serviceContext.setScopeGroupId(groupId);
        
        Map<Locale, String> nameMap = new HashMap<>();
        nameMap.put(LocaleUtil.getDefault(), formName);
        Map<Locale, String> descriptionMap = new HashMap<>();
        descriptionMap.put(LocaleUtil.getDefault(), formName);
        
        DDMFormValues settingsDDMFormValues = createDefaultSettings();
        
        return ddmFormInstanceLocalService.addFormInstance(
            0L, // userId
            groupId,
            structureId,
            nameMap,
            descriptionMap,
            settingsDDMFormValues,
            serviceContext
        );
    }
}

Architecture

The DDM API is built around several key architectural components:

  • Model Layer: Entity models representing structures, templates, forms, and data records
  • Service Layer: Local and remote services providing CRUD operations and business logic
  • Storage Abstraction: Pluggable storage backends for form data with JSON as the default
  • Expression Engine: Rule evaluation system supporting complex conditional logic
  • Form Field Framework: Extensible field type system with built-in and custom field types
  • Template Engine: Template processing system supporting multiple template languages
  • Data Provider Framework: External data source integration for dynamic field options
  • Security Layer: Comprehensive permission system with fine-grained access control

Capabilities

Core Data Models & Services

Primary entity models and CRUD services for structures, templates, forms, and data records. Essential for all DDM operations.

// Core models
interface DDMStructure extends DDMStructureModel, PersistedModel;
interface DDMTemplate extends DDMTemplateModel, PersistedModel;
interface DDMFormInstance extends DDMFormInstanceModel, PersistedModel;

// Core services
interface DDMStructureLocalService extends BaseLocalService;
interface DDMTemplateLocalService extends BaseLocalService;
interface DDMFormInstanceLocalService extends BaseLocalService;

Models & Services

Form Management Framework

Comprehensive form building, rendering, field types, validation, and lifecycle management capabilities.

interface DDMFormRenderer {
    String render(DDMForm ddmForm, DDMFormLayout ddmFormLayout, 
        DDMFormRenderingContext ddmFormRenderingContext) throws DDMFormRenderingException;
    Map<String, Object> getDDMFormTemplateContext(DDMForm ddmForm, DDMFormLayout ddmFormLayout,
        DDMFormRenderingContext ddmFormRenderingContext) throws Exception;
}

interface DDMFormFieldType {
    String getName();
    Class<? extends DDMFormFieldTypeSettings> getDDMFormFieldTypeSettings();
    String getModuleName();
    String getESModule();
    boolean isCustomDDMFormFieldType();
}

interface DDMFormEvaluator {
    DDMFormEvaluatorEvaluateResponse evaluate(DDMFormEvaluatorEvaluateRequest request);
}

Form Management

Data Provider Framework

External data source integration for populating form field options dynamically from REST APIs, databases, and other sources.

interface DDMDataProvider {
    DDMDataProviderResponse getData(DDMDataProviderRequest ddmDataProviderRequest) throws DDMDataProviderException;
    Class<?> getSettings();
}

class DDMDataProviderRequest {
    String getDDMDataProviderInstanceId();
    Map<String, String> getParameters();
}

Data Providers

Expression Engine

Rule evaluation system with support for complex conditional expressions, calculations, and form field interactions.

abstract class Expression {
    public abstract <T> T accept(ExpressionVisitor<T> expressionVisitor);
}

interface DDMExpression<T> {
    T evaluate() throws DDMExpressionException;
    Map<String, Object> getVariables();
    void setVariable(String name, Object value);
}

interface DDMExpressionFactory {
    <T> DDMExpression<T> createExpression(CreateExpressionRequest createExpressionRequest) throws DDMExpressionException;
}

Expression Engine

Storage & I/O Framework

Pluggable storage abstraction for form data with support for JSON storage, import/export operations, and custom storage adapters.

interface DDMStorageAdapter {
    long create(DDMStorageAdapterSaveRequest request) throws StorageException;
    void deleteByClass(long ddmStructureId) throws StorageException;
    DDMStorageAdapterGetResponse get(DDMStorageAdapterGetRequest request) throws StorageException;
}

Storage & I/O

Template Engine & Rendering

Template processing system supporting FreeMarker, Velocity, and custom template languages for form and content rendering.

interface DDMTemplateManager {
    Map<String, Object> getAutocompleteVariables(HttpServletRequest httpServletRequest, 
        HttpServletResponse httpServletResponse, Language language) throws Exception;
    String[] getRestrictedVariables(Language language);
}

Templates & Rendering

Security & Validation

Permission system, access control, data validation framework, and security policy enforcement.

interface DDMPermissionSupport {
    String getResourceName(String className);
    boolean contains(PermissionChecker permissionChecker, String name, 
        long primaryKey, String actionId) throws PortalException;
}

interface DDMValidator {
    void validate(DDMValidatorValidateRequest request) throws DDMValidatorException;
}

Security & Validation

Integration & Extensions

Info framework integration, WebDAV support, utilities, comparators, and extensibility APIs.

interface DDMFormValuesInfoFieldValuesProvider<T> {
    InfoFieldValue<Object> getInfoFieldValue(T model, String fieldName, Locale locale);
}

interface DDMStructureInfoItemFieldSetProvider {
    InfoFieldSet getInfoFieldSet(String itemClassName, long itemClassPK, long structureId);
}

Integration & Extensions