Package com.alibaba.citrus.service.form.support.FormTool

Examples of com.alibaba.citrus.service.form.support.FormTool.FieldHelper


    }

    @Test
    public void field_functions() throws Exception {
        GroupInstanceHelper group = tool.get("group1").getDefaultInstance();
        FieldHelper field = group.get("field1");
        setFieldValues(field, new String[] { "<&\">", "hello" });

        assertEquals("我的字段1", field.getDisplayName());
        assertEquals("_fm.g._0.f", field.getKey());
        assertEquals("_fm.g._0.f.~html", field.getHtmlKey());
        assertEquals("_fm.g._0.f.absent", field.getAbsentKey());
        assertEquals("_fm.g._0.f.attach", field.getAttachmentKey());
        assertEquals("<&\">", field.getValue());
        assertEquals("&lt;&amp;&quot;&gt;", field.getEscapedValue());
        assertArrayEquals(new String[] { "<&\">", "hello" }, field.getValues());
        assertArrayEquals(new String[] { "&lt;&amp;&quot;&gt;", "hello" }, field.getEscapedValues());
    }
View Full Code Here


    }

    @Test
    public void field_absent() throws Exception {
        GroupInstanceHelper group = tool.get("group1").getDefaultInstance();
        FieldHelper field = group.get("field1");

        // absent hidden field
        input hiddenTag = field.getAbsentHiddenField("defaultValue");
        assertThat(hiddenTag.toString(),
                   containsAll("<input", "name='_fm.g._0.f.absent'", "type='hidden'", "value='defaultValue'", "/>"));
    }
View Full Code Here

    }

    @Test
    public void field_attachment() throws Exception {
        GroupInstanceHelper group = tool.get("group1").getDefaultInstance();
        FieldHelper field = group.get("field1");

        // no attachment
        assertEquals(null, field.getAttachment());
        assertEquals("", field.getAttachmentEncoded());
        assertEquals(false, field.hasAttachment());

        input attachmentTag = field.getAttachmentHiddenField();
        assertThat(attachmentTag.toString(),
                   containsAll("<input", "name='_fm.g._0.f.attach'", "type='hidden'", "value=''", "/>"));

        // with attachment
        field.setAttachment("attachedObject");

        assertEquals("attachedObject", field.getAttachment());
        assertEquals("eNpb85aBtYSBL7GkJDE5IzXFPykrNbkEAFOhB7Y%3D", field.getAttachmentEncoded());
        assertEquals(true, field.hasAttachment());

        attachmentTag = field.getAttachmentHiddenField();
        assertThat(
                attachmentTag.toString(),
                containsAll("<input", "name='_fm.g._0.f.attach'", "type='hidden'",
                            "value='eNpb85aBtYSBL7GkJDE5IzXFPykrNbkEAFOhB7Y%3D'", "/>"));

        // clear attachment
        field.clearAttachment();
        assertEquals(null, field.getAttachment());
        assertEquals("", field.getAttachmentEncoded());
        assertEquals(false, field.hasAttachment());
    }
View Full Code Here

    @Test
    public void field_isValid() throws Exception {
        // new form
        GroupInstanceHelper group = tool.get("group1").getDefaultInstance();
        FieldHelper field = group.get("field1");

        assertTrue(field.isValid());

        // submit form
        submitForm();

        group = tool.get("group1").getDefaultInstance();
        field = group.get("field2");

        assertFalse(field.isValid());
    }
View Full Code Here

    @Test
    public void field_getMessage() throws Exception {
        // new form
        GroupInstanceHelper group = tool.get("group1").getDefaultInstance();
        FieldHelper field = group.get("field1");

        assertEquals(null, field.getMessage());

        // submit form
        submitForm();

        group = tool.get("group1").getDefaultInstance();
        field = group.get("field2");

        assertEquals("required field2", field.getMessage());
    }
View Full Code Here

        tool.setFormService(formService);

        invokePost(null);

        GroupInstanceHelper group = tool.get("group1").getDefaultInstance();
        FieldHelper field = group.get("field1");

        assertEquals("_fm.group1._0.field1", field.getKey());
        assertEquals("_fm.group1._0.field1.absent", field.getAbsentKey());
        assertEquals("_fm.group1._0.field1.attach", field.getAttachmentKey());
    }
View Full Code Here

TOP

Related Classes of com.alibaba.citrus.service.form.support.FormTool.FieldHelper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.