Chuyển đến nội dung chính

Bài đăng

Đang hiển thị bài đăng từ Tháng 6, 2015

[CQ Embedded Form] Add an approach for server side validation in Cq5 to use for CQ embedded form

Issue While working with cq5 forms you would need to do some validations at server side end. These validations can be very generic like character only validation or may be complex business scenarios. Solution The approach we would discuss would incorporate all these scenarios: The first and foremost thing to do is to override the default server validation file in /libs directory (/libs/foundation/components/form/defaults/field/servervalidation.jsp) into your project like /apps/foundation/components/form/defaults/field/servervalidation.jsp The file above is called for each form field separately when the form is submitted. Within this default server validation field I suggest you to validate only required constraint. This can be achieved with the help of form api’s available OOTB. Required validation (available OOTB in the constraint tab on the form field) can be done with this code below. FieldDescription[] descs = FieldHelper.getFieldDescriptions(slingRequest, resour

[CQ Embedded Form] Route to different pages after submit on CQ embedded form

Issue In CQ you have the form functionality available that allows you to create a form on a page, for each form you can specify a “thank you” page that will be displayed when the form is submitted. In this blogpost I will explain how you conditionally can route to different thank you pages depending on the values entered by the user. Solution Use request.setAttribute(“cq.form.redirect”,”/content/myproject/en/thank-you-no.html”); in forward.jsp. Detail Create a simple form The first step here is to create a (simple) form to test the basic functionality. You start with the “form” component, after this you can drag/drop other form-components like textfields etc in your form. Configure the thank-you page When you click “Edit” on the “Start of Form”, you can configure the “Thank You Page”, where the user will be redirected to after submitting the form. So until now this is all out of the box functionality, the implementation of this you can see via CRXDE Lite vi