use of com.enonic.xp.form.Form in project xp by enonic.
the class XmlPageDescriptorParserTest method assertResult.
private void assertResult() throws Exception {
final PageDescriptor result = this.builder.build();
assertEquals("myapplication:mypage", result.getKey().toString());
assertEquals("mypage", result.getName());
assertEquals("Landing page", result.getDisplayName());
assertEquals("key.display-name", result.getDisplayNameI18nKey());
assertEquals("My Page Description", result.getDescription());
assertEquals("key.description", result.getDescriptionI18nKey());
final Form config = result.getConfig();
assertNotNull(config);
assertEquals(InputTypeName.DOUBLE, config.getFormItem("pause").toInput().getInputType());
assertEquals("Pause parameter", config.getFormItem("pause").toInput().getLabel());
assertEquals("key1.label", config.getFormItem("pause").toInput().getLabelI18nKey());
assertEquals("key1.help-text", config.getFormItem("pause").toInput().getHelpTextI18nKey());
assertNotNull(config.getFormItem("myFormItemSet").toFormItemSet());
assertEquals("My form item set", config.getFormItem("myFormItemSet").toFormItemSet().getLabel());
assertEquals(InputTypeName.TEXT_LINE, config.getFormItem("myFormItemSet.fieldSetItem").toInput().getInputType());
assertEquals("Field set Item", config.getFormItem("myFormItemSet.fieldSetItem").toInput().getLabel());
assertEquals("key2.label", config.getFormItem("myFormItemSet.fieldSetItem").toInput().getLabelI18nKey());
assertEquals("key2.help-text", config.getFormItem("myFormItemSet.fieldSetItem").toInput().getHelpTextI18nKey());
final RegionDescriptors regions = result.getRegions();
assertNotNull(regions);
assertEquals(3, regions.numberOfRegions());
assertNotNull(regions.getRegionDescriptor("header"));
}
use of com.enonic.xp.form.Form in project xp by enonic.
the class XmlLayoutDescriptorParserTest method assertResult.
private void assertResult() throws Exception {
final LayoutDescriptor result = this.builder.build();
assertEquals("myapplication:mylayout", result.getKey().toString());
assertEquals("mylayout", result.getName());
assertEquals("My Layout", result.getDisplayName());
assertEquals("key.display-name", result.getDisplayNameI18nKey());
assertEquals("My Layout Description", result.getDescription());
assertEquals("key.description", result.getDescriptionI18nKey());
final Form config = result.getConfig();
assertNotNull(config);
assertEquals(InputTypeName.DOUBLE, config.getFormItem("pause").toInput().getInputType());
assertEquals("Pause parameter", config.getFormItem("pause").toInput().getLabel());
assertEquals("key1.label", config.getFormItem("pause").toInput().getLabelI18nKey());
assertEquals("key1.help-text", config.getFormItem("pause").toInput().getHelpTextI18nKey());
assertNotNull(config.getFormItem("myFormItemSet").toFormItemSet());
assertEquals("My form item set", config.getFormItem("myFormItemSet").toFormItemSet().getLabel());
assertEquals(InputTypeName.TEXT_LINE, config.getFormItem("myFormItemSet.fieldSetItem").toInput().getInputType());
assertEquals("Field set Item", config.getFormItem("myFormItemSet.fieldSetItem").toInput().getLabel());
assertEquals("key2.label", config.getFormItem("myFormItemSet.fieldSetItem").toInput().getLabelI18nKey());
assertEquals("key2.help-text", config.getFormItem("myFormItemSet.fieldSetItem").toInput().getHelpTextI18nKey());
final RegionDescriptors regions = result.getRegions();
assertNotNull(regions);
assertEquals(3, regions.numberOfRegions());
assertNotNull(regions.getRegionDescriptor("header"));
}
use of com.enonic.xp.form.Form in project xp by enonic.
the class XmlPartDescriptorParserTest method assertResult.
private void assertResult() throws Exception {
final PartDescriptor result = this.builder.build();
assertEquals("myapplication:mypart", result.getKey().toString());
assertEquals("mypart", result.getName());
assertEquals("A Part", result.getDisplayName());
assertEquals("key.display-name", result.getDisplayNameI18nKey());
assertEquals("My Part Description", result.getDescription());
assertEquals("key.description", result.getDescriptionI18nKey());
final Form config = result.getConfig();
assertNotNull(config);
assertEquals(InputTypeName.DOUBLE, config.getFormItem("width").toInput().getInputType());
assertEquals("Column width", config.getFormItem("width").toInput().getLabel());
assertEquals("key.label", config.getFormItem("width").toInput().getLabelI18nKey());
assertEquals("key.help-text", config.getFormItem("width").toInput().getHelpTextI18nKey());
assertEquals("link-urls", config.getFormItem("link-urls").toInlineMixin().getName());
}
use of com.enonic.xp.form.Form in project xp by enonic.
the class PageDefaultValuesProcessor method applyComponentDefaultValues.
private void applyComponentDefaultValues(final DescriptorBasedComponent cmp) {
if (cmp.getDescriptor() == null) {
return;
}
final Form cmpForm;
if (cmp instanceof PartComponent) {
final PartDescriptor partDescriptor = partDescriptorService.getByKey(cmp.getDescriptor());
cmpForm = partDescriptor.getConfig();
} else {
final LayoutDescriptor layoutDescriptor = layoutDescriptorService.getByKey(cmp.getDescriptor());
cmpForm = layoutDescriptor.getConfig();
}
if (cmpForm != null) {
final PropertyTree cmpData = cmp.getConfig();
formDefaultValuesProcessor.setDefaultValues(cmpForm, cmpData);
}
}
use of com.enonic.xp.form.Form in project xp by enonic.
the class IndexConfigVisitorTest method top_htmlArea.
@Test
public void top_htmlArea() throws Exception {
Input myTextLine = Input.create().name("htmlArea").inputType(InputTypeName.HTML_AREA).label("htmlArea").required(true).build();
Form form = Form.create().addFormItem(myTextLine).build();
final PatternIndexConfigDocument.Builder builder = PatternIndexConfigDocument.create();
final IndexConfigVisitor validationVisitor = new IndexConfigVisitor("parent", builder);
validationVisitor.traverse(form);
final PatternIndexConfigDocument document = builder.build();
assertEquals(1, document.getPathIndexConfigs().size());
assertEquals("htmlStripper", document.getConfigForPath(PropertyPath.from("parent.htmlArea")).getIndexValueProcessors().get(0).getName());
}
Aggregations