5 Replies Latest reply on Mar 22, 2013 4:29 AM by Andras Fejer

    How constraint type is populated in foundation form text component??

    Veena_07 Level 3

      HI Guys

       

                  When i was analysing foundation/components/form/text component i could see that the constraintType is populated from /bin/wcm/foundation/forms/constraints.json . When i am creating a custom text component in apps/<proj>/components/ with same structure it is not getting populated. Where does this /bin/wcm/foundation/forms/constraints.json refer to? I couldnt find any bin folder in my CRXDE. Any help would be appreciable

       

       

      Thanks

       

      Veena

        • 1. Re: How constraint type is populated in foundation form text component??
          rush_pawan Level 4

          So its registered servlet with path '/bin/wcm/foundation/forms/constraints.json' (OOTB) and it pulls data from "/libs/foundation/components/form/constraints". You can access it http://<host>:<port>/bin/wcm/foundation/forms/constraints.json to see json response.

           

          Let me know if it doesn't help you.

          • 2. Re: How constraint type is populated in foundation form text component??
            Veena_07 Level 3

            Hi pawan

             

                           Your reply is not clear to me. Actually where can i find the path 'bin/wcm/foundation/forms/constrains.json.?? Even if i give a constraints folder and some constraints inside that in my local proj it will be taken as a constraint type,,... So How is it actualy working??

            • 3. Re: How constraint type is populated in foundation form text component??
              rush_pawan Level 4

              So if you go to "/libs/foundation/components/form/text/dialog/items/fourth/items/constraintType" and check "options" property it is pointing to "/bin/wcm/foundation/forms/constraints.json" and if you access this path you will be able to see the JSON response.

              http://<host>:<port>/bin/wcm/foundation/forms/constraints.json or

              http://<host>:<port>/bin/wcm/foundation/forms/constraints

               

              Now from where the drop down generates - "/libs/foundation/components/form/constraints" you will see those listed here but it used by servlet which i mentioned above has been registered using "/bin/wcm/foundation/forms/constraints" path and you can find it if you go to felix console component tab (follow below)

               

              1. http://<host>:<port>/system/console

              2. go to "component tab"

              3. now search for "FormsListServlet"

              4. open the configuration by clicking at row node

              under "property" column you will see this configuration

              sling.servlet.paths = [/bin/wcm/foundation/forms/actions, /bin/wcm/foundation/forms/constraints, /bin/wcm/foundation/forms/actiondialog, /bin/wcm/foundation/forms/report]

               

              Now if you want to add more drop down then you have to extend this servlet and add your won drop down.

               

              I hope above information has provided you better clarification drop down implementation. Let me know if you need more info.

               


              • 4. Re: How constraint type is populated in foundation form text component??
                Veena_07 Level 3

                Hi Pawan

                 

                     Thanks a lot. That was very useful information

                • 5. Re: How constraint type is populated in foundation form text component??
                  Andras Fejer Level 1

                  I thought that it wouldn't hurt if I elaborate the answer from above more clearly.

                   

                  As already mention, here we have a servlet to deal with, because it seems like servlets in CQ are usually registered under the /bin path.

                  In the system console, under the Configurations tab, there is a configuration called "Apache Sling Servlet/Script Resolver and Error Hanlder".

                  There you can find a configuration called "Execution Paths" where you can set the exec paths for servlet calls.

                   

                  The "FormsListServlet" (/libs/foundation/src/impl/src/main/java/com/day/cq/wcm/foundation/forms/impl/FormsListSe rvlet.java)

                  returns a JSON result which consists of the paths (value), names (text) and descriptions (qtip) of the options which can be chosen in the dialog of the form textfield.

                  The list of options is retrieved from the "FormsManager" (/libs/foundation/src/impl/src/main/java/com/day/cq/wcm/foundation/forms/FormsManager.jav a)

                  by using the method "getConstraints".

                  The "FormsManager" class is an interface, so we need the implementation called "FormsManagerImpl"

                  (/libs/foundation/src/impl/src/main/java/com/day/cq/wcm/foundation/forms/impl/FormsManage rImpl.java) to work with it.

                  The "FormsManagerImpl" class is defined as a service interface, that's why there is a service call for the FormsManager in the servlet.

                   

                  /** @scr.reference */

                  private FormsManager formsManager;

                   

                  In the "FormsManagerImpl" there is a method called "searchFormElements" which searches for either the form actions or form costraints.

                  In this method "search" call has "FormsConstants.RT_FORM_CONSTRAINT" as the parameter.

                  For the static value of "RT_FORM_CONSTRAINT" the constants class "FormsConstants" (/libs/foundation/src/impl/src/main/java/com/day/cq/wcm/foundation/forms/FormsConstants.j ava)

                  has the following value:

                   

                  public final static String RT_FORM_PREFIX = "foundation/components/form/";

                  public final static String RST_FORM_CONSTRAINT = RT_FORM_PREFIX + "defaults/constraint";

                   

                  Hope this saves time for others who want to find out how the constraints options are loaded into the form textfield dialog.