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

Bài đăng

[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...

[COMPILE] CQ doen't compile JSP after we modify in CRX / compiled jsp files

Problem: CQ doen't compile JSP after we modify in CRX. Solution: We have experienced similiar issues when deploying code with packages. We solved the caching issue by doing the following: 1. Deleted /var/classes and /var/clientlibs 2. Restart scripting bundles in felix      - Open up <server>/system/console - on a publish instance you'll need to log in as admin      - Filter bundles by "scripting". There should be 7 bundles that match the filter: Apache Sling JSP Tag Library (org.apache.sling.scripting.jsp.taglib) Apache Sling Scripting Core implementation (org.apache.sling.scripting.core) Apache Sling Scripting Implementation API (org.apache.sling.scripting.api) Apache Sling Scripting Java Support (org.apache.sling.scripting.java) Apache Sling Scripting JavaScript Support (org.apache.sling.scripting.javascript) Apache Sling Scripting JSP Support (org.apache.sling.scripting.jsp) Apache Sling Scriptin...

[MAVEN] Using Maven to Create and Install CQ5 Package

Creating components using CRXDE and CRXDE Lite can be frustrating. Both are buggy and are different environments than what you are use to working with. You can use Maven to create a package that it can then install the package in CQ5. If you have ever extracted a package then you’ll see that there are two folders within it, jcr_root and META-INF. Both of these files are important and they determine how the Maven project should be setup. META-INF holds the filters (paths) that the package contains. jcr_root has all of your files for components, templates, etc. I typically put these files in src/main/content in the Maven project so my code will have that path. First thing you need to do is in pom.xml under <build> add the following code so that it knows to include your files in the bundle. This also excludes any file vault (VLT) files. <resources>    <!-- filter meta information to get some properties into the files -->    <re...