8 Replies Latest reply: Jul 7, 2013 10:58 PM by snayakar RSS

    How the values are stored in CRX after form submission?

    Veena_07 Community Member

      Hi

       

           I have analysed the flow of form submission. I could find out how the node is created under /content/usergenerated/...... . But the thing which i am not able to understand is , after creating all nodes, how they are storing different form fields as the property of created node. I tried a lot but couldnt find from where the call to store the form values in CRX is coming. Any help would be highly appreciable...

       

       

      Thanks and regards

       

      Veena

        • 1. Re: How the values are stored in CRX after form submission?
          Scott Brodersen Adobe Employee

          Hi Veena,

           

          as described here: http://dev.day.com/docs/en/cq/current/wcm/default_components.html#Settings Common to (Many) Form Components

           

          the Element Name property of the form component determines where the data is stored

           

          scott

          • 2. Re: How the values are stored in CRX after form submission?
            Veena_07 Community Member

            Hi scott,

             

                      Thanks for the quick reply. Can u please tell me exactly in which java class or servlet the call is being done to write the value to the CRX

             

             

             

            Veena

            • 3. Re: How the values are stored in CRX after form submission?
              rush_pawan Community Member

              Hello Veena,

               

              I think i already provided this information to you in my early POST but giving it again (This is what i think)

              FormHandlingServlet is main which get called for all form submit and it does the processing of storing data at node. Where to store the data - we define while configuring the form at field "content path" under "action configuration"

               

              To know more about form server and its filter

               

              refer - http://sling.apache.org/site/filters.html

              http://dev.day.com/content/docs/v5_1/cq-wcm-javadoc/com/day/cq/wcm/foundation/forms/impl/F ormsHandlingServlet.html

               

              and my earlier post - http://forums.adobe.com/message/4838063#4838063

               

              Let me know if it doesn't help you.

               

              Thanks,

              Pawan

              • 4. Re: How the values are stored in CRX after form submission?
                Veena_07 Community Member

                Hi rush_pawan

                 

                            I am almost 80 percent clear about the flow of form and storing. The only thing i could'nt find while analysing is from which servlet or class, the value we are entering in the form field in publish side is getting stored in the CRX under /content/usergenerated/ .. I could find how the nodes are created under this path but couldnt understnd how the values are getting stored.

                 

                In actions/store/forward.jsp I could find one line

                  FormsHelper.setForwardPath(slingRequest, path); where path is /content/usergenerated/<pagename>/<sysgeneratedNode>/<sysgeneratedUniqueNode(for each submit)>/

                 

                which sets REQ_ATTR_FORWARD_PATH as above path

                and in FormsHandlingServlet---> doPost

                 

                final Resource forwardResource = request.getResourceResolver().resolve(forwardPath);

                 

                            request.getRequestDispatcher(forwardResource).forward(request, response);

                 

                ******here forwardPath is d path which was set as REQ_ATTR_FORWARD_PATH

                ****** I want to know how the request dispatcher act so dat the values enterd in the fields get stored in CRX while submitting the form

                 

                 

                I hope my Doubt is now bit more clear... Please help me with a solution

                 

                Thanks

                Veena

                • 5. Re: How the values are stored in CRX after form submission?
                  rush_pawan Community Member

                  Hi Veena,

                   

                  If you trace DEBUG statement in your error.log file then you can see how request is processing. But for your information i think below is the class which saves node property

                   

                   

                  org.apache.jackrabbit.core.session.SessionState Performed session.save()

                  org.apache.jackrabbit.core.session.SessionState Performed item.save()

                  org.apache.jackrabbit.core.ItemImpl.perform()

                  org.apache.jackrabbit.core.ItemImpl.getPath()

                  ...

                  ....

                  ....

                  start from requestdispatcher.

                   

                   

                  I hope this will help you. Let me know if you need more information.

                   

                  To change log config plz go to http://localhost:4502/system/console/slinglog

                   

                  Thanks,

                  Pawan

                  • 6. Re: How the values are stored in CRX after form submission?
                    Veena_07 Community Member

                    HI pawan,

                     

                         I figured out how values are getting stored. My latest doubt is , from where the request is getting passed to :redirect page if we have set a ThankYou page in start.jsp.??

                     

                     

                    Thanks

                    Veena

                    • 7. Re: How the values are stored in CRX after form submission?
                      karansheel Community Member

                      Hi i want to know when i submit the form the data is stored is stored in the CRX under /content/usergenerated/ .... but if i want to reterive this data in another jsp?? how can i render it there ??

                       

                      do u hv any idea about it ??

                      • 8. Re: How the values are stored in CRX after form submission?
                        snayakar Community Member

                        KaranSheel,

                         

                        Hope the below code be usefull for you to retrieve , what you have stored at path /content/usergenerated/<Ipsum>/<Ipsum>

                         

                        listingPath="/content/usergenerated/<comments>/<your node>"

                        <%

                        String listingPath = properties.get("listingPath", String.class);

                        log.info("listingPath="+listingPath);

                         

                            Resource commentsFolder = slingRequest.getResourceResolver().getResource(listingPath);

                            log.info("commentsFolder?"+commentsFolder);

                            if (commentsFolder != null) {

                                Iterator<Resource> children = slingRequest.getResourceResolver().listChildren(commentsFolder);

                                //log.info("children="+children.hasNext());

                         

                                // disable WCM for included components

                                //WCMMode mode = WCMMode.DISABLED.toRequest(request);

                                try {

                                    while (children.hasNext()) {

                                        Resource comment = children.next();

                                        //if (!comment.getResourceType().equals("cq:ntunstructured")) continue;

                                       

                                        String pathtoinclude = comment.getPath() != null ?  comment.getPath() : "" ;

                                        Node node = comment.adaptTo(Node.class);

                                        String userComments=(node.getProperty("jcr:description").getValue().getString()) != null ?  node.getProperty("jcr:description").getValue().getString() : "" ;

                                        String createdDate=(node.getProperty("jcr:created").getValue().getString()) != null ?  node.getProperty("jcr:created").getValue().getString() : "" ;

                                        //String userID=(node.getProperty("cq:userid").getValue().getString()) != null ?  node.getProperty("cq:userid").getValue().getString() : "" ;

                                       

                                        %><p><div class="item">Date:   <%=createdDate%> <br/>

                                             <div class="item">Comment:  <%=userComments%></div> </p><%

                                    }

                                } catch(Exception e) {

                                   

                                }

                           

                        }%>