Search in sources :

Example 1 with EnumFormType

use of org.camunda.bpm.engine.impl.form.type.EnumFormType in project camunda-bpm-platform by camunda.

the class HtmlFormEngine method renderSelectOptions.

protected void renderSelectOptions(FormField formField, HtmlDocumentBuilder documentBuilder) {
    EnumFormType enumFormType = (EnumFormType) formField.getType();
    Map<String, String> values = enumFormType.getValues();
    for (Entry<String, String> value : values.entrySet()) {
        // <option>
        HtmlElementWriter option = new HtmlElementWriter(OPTION_ELEMENT, false).attribute(VALUE_ATTRIBUTE, value.getKey()).textContent(value.getValue());
        documentBuilder.startElement(option).endElement();
    }
}
Also used : EnumFormType(org.camunda.bpm.engine.impl.form.type.EnumFormType)

Example 2 with EnumFormType

use of org.camunda.bpm.engine.impl.form.type.EnumFormType in project camunda-bpm-platform by camunda.

the class AbstractRenderFormDelegate method renderSelectOptions.

protected void renderSelectOptions(FormField formField, HtmlDocumentBuilder documentBuilder) {
    EnumFormType enumFormType = (EnumFormType) formField.getType();
    Map<String, String> values = enumFormType.getValues();
    for (Map.Entry<String, String> value : values.entrySet()) {
        // <option>
        HtmlElementWriter option = new HtmlElementWriter(OPTION_ELEMENT, false).attribute(VALUE_ATTRIBUTE, value.getKey()).textContent(value.getValue());
        documentBuilder.startElement(option).endElement();
    }
}
Also used : Map(java.util.Map) EnumFormType(org.camunda.bpm.engine.impl.form.type.EnumFormType)

Example 3 with EnumFormType

use of org.camunda.bpm.engine.impl.form.type.EnumFormType in project camunda-bpm-platform by camunda.

the class FormDataTest method testGetFormFieldBuiltInTypes.

@Deployment
public void testGetFormFieldBuiltInTypes() {
    runtimeService.startProcessInstanceByKey("FormDataTest.testGetFormFieldBuiltInTypes");
    Task task = taskService.createTaskQuery().singleResult();
    TaskFormData taskFormData = formService.getTaskFormData(task.getId());
    // validate properties:
    List<FormField> formFields = taskFormData.getFormFields();
    // validate string field
    FormField stringField = formFields.get(0);
    assertNotNull(stringField);
    assertEquals("string", stringField.getTypeName());
    assertNotNull(stringField.getType());
    assertEquals("someString", stringField.getDefaultValue());
    // validate long field
    FormField longField = formFields.get(1);
    assertNotNull(longField);
    assertEquals("long", longField.getTypeName());
    assertNotNull(longField.getType());
    assertEquals(Long.valueOf(1l), longField.getDefaultValue());
    // validate boolean field
    FormField booleanField = formFields.get(2);
    assertNotNull(booleanField);
    assertEquals("boolean", booleanField.getTypeName());
    assertNotNull(booleanField.getType());
    assertEquals(Boolean.valueOf(true), booleanField.getDefaultValue());
    // validate date field
    FormField dateField = formFields.get(3);
    assertNotNull(dateField);
    assertEquals("date", dateField.getTypeName());
    assertNotNull(dateField.getType());
    Date dateValue = (Date) dateField.getDefaultValue();
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(dateValue);
    assertEquals(10, calendar.get(Calendar.DAY_OF_MONTH));
    assertEquals(Calendar.JANUARY, calendar.get(Calendar.MONTH));
    assertEquals(2013, calendar.get(Calendar.YEAR));
    // validate enum field
    FormField enumField = formFields.get(4);
    assertNotNull(enumField);
    assertEquals("enum", enumField.getTypeName());
    assertNotNull(enumField.getType());
    EnumFormType enumFormType = (EnumFormType) enumField.getType();
    Map<String, String> values = enumFormType.getValues();
    assertEquals("A", values.get("a"));
    assertEquals("B", values.get("b"));
    assertEquals("C", values.get("c"));
}
Also used : Task(org.camunda.bpm.engine.task.Task) Calendar(java.util.Calendar) TaskFormData(org.camunda.bpm.engine.form.TaskFormData) FormField(org.camunda.bpm.engine.form.FormField) Date(java.util.Date) EnumFormType(org.camunda.bpm.engine.impl.form.type.EnumFormType) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

EnumFormType (org.camunda.bpm.engine.impl.form.type.EnumFormType)3 Calendar (java.util.Calendar)1 Date (java.util.Date)1 Map (java.util.Map)1 FormField (org.camunda.bpm.engine.form.FormField)1 TaskFormData (org.camunda.bpm.engine.form.TaskFormData)1 Task (org.camunda.bpm.engine.task.Task)1 Deployment (org.camunda.bpm.engine.test.Deployment)1