use of com.enonic.xp.form.FormItem in project xp by enonic.
the class ContentTypeMapper method serializeFormItemSet.
private void serializeFormItemSet(final MapGenerator gen, final FormItemSet itemSet) {
gen.map();
gen.value("formItemType", "ItemSet");
gen.value("name", itemSet.getName());
gen.value("label", itemSet.getLabel());
gen.value("customText", itemSet.getCustomText());
gen.value("helpText", itemSet.getHelpText());
serializeOccurrences(gen, itemSet.getOccurrences());
gen.array("items");
for (FormItem formItem : itemSet) {
serializeItem(gen, formItem);
}
gen.end();
gen.end();
}
use of com.enonic.xp.form.FormItem in project xp by enonic.
the class ContentTypeMapper method serializeLayout.
private void serializeLayout(final MapGenerator gen, final FieldSet fieldSet) {
gen.map();
gen.value("formItemType", "Layout");
gen.value("name", fieldSet.getName());
gen.value("label", fieldSet.getLabel());
gen.array("items");
for (FormItem formItem : fieldSet) {
serializeItem(gen, formItem);
}
gen.end();
gen.end();
}
use of com.enonic.xp.form.FormItem in project xp by enonic.
the class MacroInstruction method createContext.
private MacroContext createContext(final Instruction macroInstruction, final MacroDescriptor macroDescriptor, final PortalRequest request) {
final Form macroForm = macroDescriptor.getForm();
final Map<String, String> paramCaseTranslator = new HashMap<>(macroForm.size());
for (FormItem formItem : macroForm) {
final String name = formItem.getName();
paramCaseTranslator.put(name.toLowerCase(), name);
}
final MacroContext.Builder context = MacroContext.create().name(macroDescriptor.getName());
for (String name : macroInstruction.attributeNames()) {
if (name.equalsIgnoreCase(MACRO_BODY) || name.equalsIgnoreCase(MACRO_NAME) || name.equalsIgnoreCase(MACRO_DOCUMENT)) {
continue;
}
String contextParamName = name;
if (macroForm.getFormItems().getItemByName(name) == null) {
final String normalizedName = paramCaseTranslator.get(name.toLowerCase());
if (normalizedName != null) {
contextParamName = normalizedName;
}
}
for (String attribute : macroInstruction.attributes(name)) {
context.param(contextParamName, attribute);
}
}
context.body(macroInstruction.attribute(MACRO_BODY));
context.request(request);
final String documentRef = macroInstruction.attribute(MACRO_DOCUMENT);
final String document = (String) ContextAccessor.current().getLocalScope().getAttribute(documentRef);
context.document(document);
return context.build();
}
Aggregations