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

expressions.mddocs/

Expression Engine

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

Capabilities

Expression Evaluation

Core expression evaluation interfaces for processing mathematical and logical expressions.

interface Expression<T> {
    /**
     * Evaluates the expression and returns the result
     */
    T evaluate() throws ExpressionEvaluationException;
    
    /**
     * Returns the set of variable names referenced in this expression
     */
    Set<String> getVariableNames();
    
    /**
     * Sets the value of a variable used in the expression
     */
    void setVariable(String name, Object value);
}

interface ExpressionFactory {
    /**
     * Creates an expression from a string representation
     */
    <T> Expression<T> createExpression(String expressionString);
    
    /**
     * Creates a boolean expression for conditional logic
     */
    Expression<Boolean> createBooleanExpression(String expressionString);
}

class ExpressionEvaluationException extends Exception {
    ExpressionEvaluationException(String message);
    ExpressionEvaluationException(String message, Throwable cause);
}

Expression Model

Data model classes for representing and manipulating expressions.

class ExpressionModel {
    String getExpressionString();
    void setExpressionString(String expressionString);
    Map<String, Object> getVariables();
    void setVariable(String name, Object value);
}

class ExpressionContext {
    Locale getLocale();
    Map<String, Object> getVariables();
    long getCompanyId();
    long getGroupId();
    long getUserId();
}

Usage Examples

Creating and Evaluating Expressions

@Component
public class ExpressionExample {
    
    @Reference
    private ExpressionFactory expressionFactory;
    
    public void evaluateFormRules() throws ExpressionEvaluationException {
        // Create a boolean expression for field visibility
        Expression<Boolean> visibilityExpression = expressionFactory.createBooleanExpression(
            "getValue('country') == 'US' && getValue('age') >= 18"
        );
        
        // Set field values
        visibilityExpression.setVariable("country", "US");
        visibilityExpression.setVariable("age", 25);
        
        // Evaluate the expression
        boolean isVisible = visibilityExpression.evaluate();
        System.out.println("Field should be visible: " + isVisible);
        
        // Create a calculation expression
        Expression<Number> calculationExpression = expressionFactory.createExpression(
            "getValue('quantity') * getValue('price') * (1 + getValue('tax_rate'))"
        );
        
        calculationExpression.setVariable("quantity", 5);
        calculationExpression.setVariable("price", 19.99);
        calculationExpression.setVariable("tax_rate", 0.08);
        
        Number totalCost = calculationExpression.evaluate();
        System.out.println("Total cost: $" + totalCost);
    }
}

Types

Expression Constants

class ExpressionConstants {
    // Built-in functions available in expressions
    String FUNCTION_BETWEEN = "between";
    String FUNCTION_CONTAINS = "contains";
    String FUNCTION_GET_VALUE = "getValue";
    String FUNCTION_IS_EMAIL_ADDRESS = "isEmailAddress";
    String FUNCTION_IS_URL = "isURL";
    String FUNCTION_MATCH = "match";
    String FUNCTION_SUM = "sum";
    
    // Expression operators
    String OPERATOR_AND = "&&";
    String OPERATOR_OR = "||";
    String OPERATOR_NOT = "!";
    String OPERATOR_EQUALS = "==";
    String OPERATOR_NOT_EQUALS = "!=";
    String OPERATOR_GREATER_THAN = ">";
    String OPERATOR_LESS_THAN = "<";
}

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