CtrlK
BlogDocsLog inGet started
Tessl Logo

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.

Pending
Overview
Eval results
Files

form-management.mddocs/

Form Management Framework

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

Capabilities

Form Rendering

Core form rendering services that convert DDM forms into HTML markup with proper styling and validation.

interface DDMFormRenderer {
    /**
     * Renders a DDM form to HTML with the specified context
     */
    String render(DDMForm ddmForm, DDMFormRenderingContext ddmFormRenderingContext) throws PortalException;
}

class DDMFormRenderingContext {
    boolean isReadOnly();
    boolean isShowSubmitButton();
    String getPortletNamespace();
    HttpServletRequest getHttpServletRequest();
    HttpServletResponse getHttpServletResponse();
    Locale getLocale();
}

Form Field Types

Extensible field type system supporting various input types with custom properties and validation.

interface DDMFormFieldType {
    /**
     * Returns the unique name identifier for this field type
     */
    String getName();
    
    /**
     * Returns the set of properties supported by this field type
     */
    Set<String> getSupportedProperties();
}

interface DDMFormFieldTypeSettings {
    /**
     * Base interface for field type configuration settings
     */
}

// Built-in field types include:
// - TEXT: Single line text input
// - TEXTAREA: Multi-line text input  
// - SELECT: Dropdown selection
// - CHECKBOX: Single checkbox
// - CHECKBOX_MULTIPLE: Multiple checkboxes
// - RADIO: Radio button group
// - DATE: Date picker
// - NUMERIC: Number input
// - EMAIL: Email validation
// - URL: URL validation
// - PASSWORD: Password input
// - DOCUMENT_LIBRARY: File upload
// - IMAGE: Image upload
// - GRID: Grid/table input
// - GEOLOCATION: Location picker

Form Evaluation & Rules

Dynamic form behavior through expression-based rules and field interactions.

interface DDMFormEvaluator {
    /**
     * Evaluates form rules and returns updated form state
     */
    DDMFormEvaluatorEvaluateResponse evaluate(DDMFormEvaluatorEvaluateRequest ddmFormEvaluatorEvaluateRequest);
}

class DDMFormEvaluatorEvaluateRequest {
    long getCompanyId();
    long getGroupId();
    long getUserId();
    DDMForm getDDMForm();
    DDMFormValues getDDMFormValues();
    Locale getLocale();
}

class DDMFormEvaluatorEvaluateResponse {
    Set<Integer> getDisabledPagesIndexes();
    Map<String, Set<String>> getHiddenFields();
    Map<String, Set<String>> getInvalidFields();
    Map<String, Set<String>> getRequiredFields();
}

Form Validation

Comprehensive validation framework with built-in validators and custom validation rules.

interface DDMFormValidationException extends PortalException {
    /**
     * Validation errors with field-specific details
     */
    Map<String, List<String>> getErrors();
}

class DDMFormFieldValidation {
    String getExpression();
    LocalizedValue getErrorMessage();
    String getParameterName();
    String getParameterValue();
}

// Built-in validation types:
// - required: Field must have a value
// - email: Valid email format
// - url: Valid URL format
// - numeric: Numeric value within range
// - date: Valid date within range
// - text: Text length constraints
// - regex: Custom regular expression

Form Builder Context

Context and configuration for form builder interfaces and form creation workflows.

class DDMFormBuilderContext {
    boolean isReadOnly();
    String getPortletNamespace();
    HttpServletRequest getHttpServletRequest();
    Map<String, Object> getAdditionalProperties();
}

interface DDMFormBuilderSettings {
    /**
     * Configuration for form builder behavior
     */
    boolean isAllowInvalidAvailableLocalesForProperty();
    String[] getVisibleFields();
}

Usage Examples

Creating and Rendering a Form

@Component
public class FormRenderingExample {
    
    @Reference
    private DDMFormRenderer ddmFormRenderer;
    
    public String renderContactForm(HttpServletRequest request, HttpServletResponse response) 
        throws PortalException {
        
        // Create form with fields
        DDMForm ddmForm = new DDMForm();
        ddmForm.setDefaultLocale(Locale.US);
        ddmForm.addAvailableLocale(Locale.US);
        
        // Add name field
        DDMFormField nameField = new DDMFormField("name", "text");
        nameField.setLabel(new LocalizedValue(Locale.US, "Full Name"));
        nameField.setRequired(true);
        ddmForm.addDDMFormField(nameField);
        
        // Add email field with validation
        DDMFormField emailField = new DDMFormField("email", "text");
        emailField.setLabel(new LocalizedValue(Locale.US, "Email Address"));
        emailField.setDataType("email");
        emailField.setRequired(true);
        
        // Add validation rule
        DDMFormFieldValidation validation = new DDMFormFieldValidation();
        validation.setExpression("isEmailAddress(emailField)");
        validation.setErrorMessage(new LocalizedValue(Locale.US, "Please enter a valid email"));
        emailField.setDDMFormFieldValidation(validation);
        
        ddmForm.addDDMFormField(emailField);
        
        // Create rendering context
        DDMFormRenderingContext context = new DDMFormRenderingContext();
        context.setHttpServletRequest(request);
        context.setHttpServletResponse(response);
        context.setLocale(Locale.US);
        context.setPortletNamespace("_myform_");
        context.setShowSubmitButton(true);
        context.setReadOnly(false);
        
        // Render the form
        return ddmFormRenderer.render(ddmForm, context);
    }
}

Implementing Form Rules and Conditional Logic

@Component  
public class FormRulesExample {
    
    @Reference
    private DDMFormEvaluator ddmFormEvaluator;
    
    public void evaluateFormRules(DDMForm ddmForm, DDMFormValues formValues, long groupId) {
        // Create evaluation request
        DDMFormEvaluatorEvaluateRequest request = new DDMFormEvaluatorEvaluateRequest();
        request.setCompanyId(CompanyThreadLocal.getCompanyId());
        request.setGroupId(groupId);
        request.setUserId(0L);
        request.setDDMForm(ddmForm);
        request.setDDMFormValues(formValues);
        request.setLocale(Locale.US);
        
        // Evaluate rules
        DDMFormEvaluatorEvaluateResponse response = ddmFormEvaluator.evaluate(request);
        
        // Process results
        Set<String> hiddenFields = response.getHiddenFields().getOrDefault("en_US", Collections.emptySet());
        Set<String> requiredFields = response.getRequiredFields().getOrDefault("en_US", Collections.emptySet());
        Set<String> invalidFields = response.getInvalidFields().getOrDefault("en_US", Collections.emptySet());
        
        System.out.println("Hidden fields: " + hiddenFields);
        System.out.println("Required fields: " + requiredFields);
        System.out.println("Invalid fields: " + invalidFields);
    }
}

Types

Form Rendering Types

class DDMFormRenderingContext {
    void setHttpServletRequest(HttpServletRequest httpServletRequest);
    void setHttpServletResponse(HttpServletResponse httpServletResponse);
    void setLocale(Locale locale);
    void setPortletNamespace(String portletNamespace);
    void setReadOnly(boolean readOnly);
    void setShowSubmitButton(boolean showSubmitButton);
    void setGroupId(long groupId);
    void setDDMFormInstanceId(long ddmFormInstanceId);
}

class DDMFormFieldValidation {
    void setExpression(String expression);
    void setErrorMessage(LocalizedValue errorMessage);
    void setParameterName(String parameterName);
    void setParameterValue(String parameterValue);
}

class DDMFormRule {
    List<String> getActions();
    String getCondition();
    boolean isEnabled();
}

Install with Tessl CLI

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

docs

data-providers.md

expressions.md

form-management.md

index.md

integration-extensions.md

models-services.md

security-validation.md

storage-io.md

templates.md

tile.json