or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

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

form-management.mddocs/

0

# Form Management Framework

1

2

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

3

4

## Capabilities

5

6

### Form Rendering

7

8

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

9

10

```java { .api }

11

interface DDMFormRenderer {

12

/**

13

* Renders a DDM form to HTML with the specified context

14

*/

15

String render(DDMForm ddmForm, DDMFormRenderingContext ddmFormRenderingContext) throws PortalException;

16

}

17

18

class DDMFormRenderingContext {

19

boolean isReadOnly();

20

boolean isShowSubmitButton();

21

String getPortletNamespace();

22

HttpServletRequest getHttpServletRequest();

23

HttpServletResponse getHttpServletResponse();

24

Locale getLocale();

25

}

26

```

27

28

### Form Field Types

29

30

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

31

32

```java { .api }

33

interface DDMFormFieldType {

34

/**

35

* Returns the unique name identifier for this field type

36

*/

37

String getName();

38

39

/**

40

* Returns the set of properties supported by this field type

41

*/

42

Set<String> getSupportedProperties();

43

}

44

45

interface DDMFormFieldTypeSettings {

46

/**

47

* Base interface for field type configuration settings

48

*/

49

}

50

51

// Built-in field types include:

52

// - TEXT: Single line text input

53

// - TEXTAREA: Multi-line text input

54

// - SELECT: Dropdown selection

55

// - CHECKBOX: Single checkbox

56

// - CHECKBOX_MULTIPLE: Multiple checkboxes

57

// - RADIO: Radio button group

58

// - DATE: Date picker

59

// - NUMERIC: Number input

60

// - EMAIL: Email validation

61

// - URL: URL validation

62

// - PASSWORD: Password input

63

// - DOCUMENT_LIBRARY: File upload

64

// - IMAGE: Image upload

65

// - GRID: Grid/table input

66

// - GEOLOCATION: Location picker

67

```

68

69

### Form Evaluation & Rules

70

71

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

72

73

```java { .api }

74

interface DDMFormEvaluator {

75

/**

76

* Evaluates form rules and returns updated form state

77

*/

78

DDMFormEvaluatorEvaluateResponse evaluate(DDMFormEvaluatorEvaluateRequest ddmFormEvaluatorEvaluateRequest);

79

}

80

81

class DDMFormEvaluatorEvaluateRequest {

82

long getCompanyId();

83

long getGroupId();

84

long getUserId();

85

DDMForm getDDMForm();

86

DDMFormValues getDDMFormValues();

87

Locale getLocale();

88

}

89

90

class DDMFormEvaluatorEvaluateResponse {

91

Set<Integer> getDisabledPagesIndexes();

92

Map<String, Set<String>> getHiddenFields();

93

Map<String, Set<String>> getInvalidFields();

94

Map<String, Set<String>> getRequiredFields();

95

}

96

```

97

98

### Form Validation

99

100

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

101

102

```java { .api }

103

interface DDMFormValidationException extends PortalException {

104

/**

105

* Validation errors with field-specific details

106

*/

107

Map<String, List<String>> getErrors();

108

}

109

110

class DDMFormFieldValidation {

111

String getExpression();

112

LocalizedValue getErrorMessage();

113

String getParameterName();

114

String getParameterValue();

115

}

116

117

// Built-in validation types:

118

// - required: Field must have a value

119

// - email: Valid email format

120

// - url: Valid URL format

121

// - numeric: Numeric value within range

122

// - date: Valid date within range

123

// - text: Text length constraints

124

// - regex: Custom regular expression

125

```

126

127

### Form Builder Context

128

129

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

130

131

```java { .api }

132

class DDMFormBuilderContext {

133

boolean isReadOnly();

134

String getPortletNamespace();

135

HttpServletRequest getHttpServletRequest();

136

Map<String, Object> getAdditionalProperties();

137

}

138

139

interface DDMFormBuilderSettings {

140

/**

141

* Configuration for form builder behavior

142

*/

143

boolean isAllowInvalidAvailableLocalesForProperty();

144

String[] getVisibleFields();

145

}

146

```

147

148

## Usage Examples

149

150

### Creating and Rendering a Form

151

152

```java

153

@Component

154

public class FormRenderingExample {

155

156

@Reference

157

private DDMFormRenderer ddmFormRenderer;

158

159

public String renderContactForm(HttpServletRequest request, HttpServletResponse response)

160

throws PortalException {

161

162

// Create form with fields

163

DDMForm ddmForm = new DDMForm();

164

ddmForm.setDefaultLocale(Locale.US);

165

ddmForm.addAvailableLocale(Locale.US);

166

167

// Add name field

168

DDMFormField nameField = new DDMFormField("name", "text");

169

nameField.setLabel(new LocalizedValue(Locale.US, "Full Name"));

170

nameField.setRequired(true);

171

ddmForm.addDDMFormField(nameField);

172

173

// Add email field with validation

174

DDMFormField emailField = new DDMFormField("email", "text");

175

emailField.setLabel(new LocalizedValue(Locale.US, "Email Address"));

176

emailField.setDataType("email");

177

emailField.setRequired(true);

178

179

// Add validation rule

180

DDMFormFieldValidation validation = new DDMFormFieldValidation();

181

validation.setExpression("isEmailAddress(emailField)");

182

validation.setErrorMessage(new LocalizedValue(Locale.US, "Please enter a valid email"));

183

emailField.setDDMFormFieldValidation(validation);

184

185

ddmForm.addDDMFormField(emailField);

186

187

// Create rendering context

188

DDMFormRenderingContext context = new DDMFormRenderingContext();

189

context.setHttpServletRequest(request);

190

context.setHttpServletResponse(response);

191

context.setLocale(Locale.US);

192

context.setPortletNamespace("_myform_");

193

context.setShowSubmitButton(true);

194

context.setReadOnly(false);

195

196

// Render the form

197

return ddmFormRenderer.render(ddmForm, context);

198

}

199

}

200

```

201

202

### Implementing Form Rules and Conditional Logic

203

204

```java

205

@Component

206

public class FormRulesExample {

207

208

@Reference

209

private DDMFormEvaluator ddmFormEvaluator;

210

211

public void evaluateFormRules(DDMForm ddmForm, DDMFormValues formValues, long groupId) {

212

// Create evaluation request

213

DDMFormEvaluatorEvaluateRequest request = new DDMFormEvaluatorEvaluateRequest();

214

request.setCompanyId(CompanyThreadLocal.getCompanyId());

215

request.setGroupId(groupId);

216

request.setUserId(0L);

217

request.setDDMForm(ddmForm);

218

request.setDDMFormValues(formValues);

219

request.setLocale(Locale.US);

220

221

// Evaluate rules

222

DDMFormEvaluatorEvaluateResponse response = ddmFormEvaluator.evaluate(request);

223

224

// Process results

225

Set<String> hiddenFields = response.getHiddenFields().getOrDefault("en_US", Collections.emptySet());

226

Set<String> requiredFields = response.getRequiredFields().getOrDefault("en_US", Collections.emptySet());

227

Set<String> invalidFields = response.getInvalidFields().getOrDefault("en_US", Collections.emptySet());

228

229

System.out.println("Hidden fields: " + hiddenFields);

230

System.out.println("Required fields: " + requiredFields);

231

System.out.println("Invalid fields: " + invalidFields);

232

}

233

}

234

```

235

236

## Types

237

238

### Form Rendering Types

239

240

```java { .api }

241

class DDMFormRenderingContext {

242

void setHttpServletRequest(HttpServletRequest httpServletRequest);

243

void setHttpServletResponse(HttpServletResponse httpServletResponse);

244

void setLocale(Locale locale);

245

void setPortletNamespace(String portletNamespace);

246

void setReadOnly(boolean readOnly);

247

void setShowSubmitButton(boolean showSubmitButton);

248

void setGroupId(long groupId);

249

void setDDMFormInstanceId(long ddmFormInstanceId);

250

}

251

252

class DDMFormFieldValidation {

253

void setExpression(String expression);

254

void setErrorMessage(LocalizedValue errorMessage);

255

void setParameterName(String parameterName);

256

void setParameterValue(String parameterValue);

257

}

258

259

class DDMFormRule {

260

List<String> getActions();

261

String getCondition();

262

boolean isEnabled();

263

}

264

```