Search in sources :

Example 1 with FormStructureHelper

use of com.day.cq.wcm.foundation.forms.FormStructureHelper in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class ContainerImpl method initModel.

@PostConstruct
private void initModel() {
    FormStructureHelper formStructureHelper = formStructureHelperFactory.getFormStructureHelper(resource);
    request.setAttribute(FormsHelper.REQ_ATTR_FORM_STRUCTURE_HELPER, formStructureHelper);
    this.action = currentPage.getPath() + ".html";
    if (StringUtils.isBlank(id)) {
        id = FormsHelper.getFormId(request);
    }
    this.name = id;
    this.dropAreaResourceType += "/new";
    if (redirect != null) {
        String contextPath = request.getContextPath();
        if (StringUtils.isNotBlank(contextPath) && redirect.startsWith("/")) {
            redirect = contextPath + redirect;
        }
    }
    if (!StringUtils.equals(request.getRequestPathInfo().getExtension(), Constants.EXPORTER_EXTENSION)) {
        runActionTypeInit(formStructureHelper);
    }
}
Also used : FormStructureHelper(com.day.cq.wcm.foundation.forms.FormStructureHelper) PostConstruct(javax.annotation.PostConstruct)

Example 2 with FormStructureHelper

use of com.day.cq.wcm.foundation.forms.FormStructureHelper in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class ContainerImpl method initModel.

@PostConstruct
private void initModel() {
    FormStructureHelper formStructureHelper = formStructureHelperFactory.getFormStructureHelper(resource);
    request.setAttribute(FormsHelper.REQ_ATTR_FORM_STRUCTURE_HELPER, formStructureHelper);
    this.action = linkHandler.getLink(currentPage).map(Link::getURL).orElse(null);
    String formId = FormsHelper.getFormId(request);
    if (StringUtils.isBlank(id)) {
        id = formId;
    }
    request.setAttribute(FormsHelper.REQ_ATTR_FORMID, getId());
    this.name = id;
    this.dropAreaResourceType = "wcm/foundation/components/responsivegrid/new";
    if (redirect != null) {
        String contextPath = request.getContextPath();
        if (StringUtils.isNotBlank(contextPath) && redirect.startsWith("/")) {
            redirect = contextPath + redirect;
        }
    }
    if (!StringUtils.equals(request.getRequestPathInfo().getExtension(), ExporterConstants.SLING_MODEL_EXTENSION)) {
        runActionTypeInit(formStructureHelper);
    }
    final ValidationInfo info = ValidationInfo.getValidationInfo(request);
    if (info != null) {
        this.errorMessages = info.getErrorMessages(null);
    }
}
Also used : FormStructureHelper(com.day.cq.wcm.foundation.forms.FormStructureHelper) ValidationInfo(com.day.cq.wcm.foundation.forms.ValidationInfo) Link(com.adobe.cq.wcm.core.components.commons.link.Link) PostConstruct(javax.annotation.PostConstruct)

Example 3 with FormStructureHelper

use of com.day.cq.wcm.foundation.forms.FormStructureHelper in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class TextImplTest method setUp.

@Before
public void setUp() {
    Page page = context.currentPage(CONTAINING_PAGE);
    slingBindings = (SlingBindings) context.request().getAttribute(SlingBindings.class.getName());
    slingBindings.put(WCMBindings.CURRENT_PAGE, page);
    context.registerService(FormStructureHelperFactory.class, new FormStructureHelperFactory() {

        @Override
        public FormStructureHelper getFormStructureHelper(Resource formElement) {
            return null;
        }
    });
    FormsHelperStubber.createStub();
}
Also used : FormStructureHelper(com.day.cq.wcm.foundation.forms.FormStructureHelper) SlingBindings(org.apache.sling.api.scripting.SlingBindings) Resource(org.apache.sling.api.resource.Resource) Page(com.day.cq.wcm.api.Page) FormStructureHelperFactory(com.day.cq.wcm.foundation.forms.FormStructureHelperFactory) Before(org.junit.Before)

Aggregations

FormStructureHelper (com.day.cq.wcm.foundation.forms.FormStructureHelper)3 PostConstruct (javax.annotation.PostConstruct)2 Link (com.adobe.cq.wcm.core.components.commons.link.Link)1 Page (com.day.cq.wcm.api.Page)1 FormStructureHelperFactory (com.day.cq.wcm.foundation.forms.FormStructureHelperFactory)1 ValidationInfo (com.day.cq.wcm.foundation.forms.ValidationInfo)1 Resource (org.apache.sling.api.resource.Resource)1 SlingBindings (org.apache.sling.api.scripting.SlingBindings)1 Before (org.junit.Before)1