6 Replies Latest reply on Mar 16, 2013 3:27 PM by rush_pawan

    How to custom the ok button in the edit dialog

    leon825 Level 1

      Hi Team:

      I want to log down the user's action when user after edit the attribute in the edit dialog,how to do that?

      any suggestions/pointers to solve this problem would be appreciable.

        • 1. Re: How to custom the ok button in the edit dialog
          rush_pawan Level 4

          Hello,

           

          Please provide more detail about your requirement. Do you want to log user actions like click "ok" or "cancel" button after authring the data in edit dialog or something else?

           

          Thanks,

          Pawan

          • 2. Re: How to custom the ok button in the edit dialog
            leon825 Level 1

            yes,for example: when i input the data of the "Publish Date" i click the "ok" button, before the screen refresh i want to log user's action info like which fields has been modified and the modified date and user account,including but not limited to the "Publish Date",thank you!p1.jpg

            • 3. Re: How to custom the ok button in the edit dialog
              MatheusOliveira Level 1

              Maybe you can try to do something progamatically, in the Widgets configuration?

               

              I'm pretty sure that there is some code lines in the JSP's of the component where you can work with the buttons of the dialog.

               

              leon825 wrote:

               

              yes,for example: when i input the data of the "Publish Date" i click the "ok" button, before the screen refresh i want to log user's action info like which fields has been modified and the modified date and user account,including but not limited to the "Publish Date",thank you!p1.jpg

              • 4. Re: How to custom the ok button in the edit dialog
                rush_pawan Level 4

                Hello,

                 

                In that case you have to add cq:editConfig node to your component and define the cq:listners node with what ever the event you want. Please refer below link

                http://dev.day.com/docs/en/cq/current/developing/components/edit_config.html#cq:listeners

                 

                Now here you have many events and based on your requirement either you can use client side event (means java script events to track the information for example before/after <action> event from http://dev.day.com/docs/en/cq/current/widgets-api/index.html?class=CQ.wcm.EditBar or http://dev.day.com/docs/en/cq/current/widgets-api/index.html?class=CQ.wcm.EditRollover

                 

                OR

                 

                you can write your own handler which will help you to do you task, the benefit here is that you will have all the CQ API available to do your job mainly fetching user information from current session.

                http://sling.apache.org/site/eventing-and-jobs.html

                 

                but its your choice which best suits to your requirement.

                 

                Also if you select client side even handler then ecma script will help you to fetch user information for example take a look at /etc/workflow/scripts/activitystreams/dummy-activity.ecma

                 

                I hope above information will help you to proceed. Let me know for more information.

                 

                Thanks,

                Pawan

                • 5. Re: How to custom the ok button in the edit dialog
                  leon825 Level 1

                  Thank you for your answer,I have a sample:

                   

                  <?xml version="1.0" encoding="UTF-8"?>
                  <jcr:root
                     
                  xmlns:cq="http://www.day.com/jcr/cq/1.0"
                     
                  xmlns:jcr="http://www.jcp.org/jcr/1.0"
                     
                  jcr:primaryType="cq:Dialog"
                     
                  xtype="dialog">
                     
                  <listeners jcr:primaryType="nt:unstructured"
                         
                  beforesubmit="function(dialog) {
                              var url = '/bin/member.json';

                   

                              var result = CQ.HTTP.eval(url);

                   

                          }"
                  />
                     
                  <items jcr:primaryType="cq:WidgetCollection">
                         
                  <tab1 jcr:primaryType="cq:Widget" title="Text" xtype="panel">
                             
                  <items jcr:primaryType="cq:WidgetCollection">
                                  ...
                             
                  </items>
                         
                  </tab1>
                         
                  <tab2 jcr:primaryType="cq:Widget" title="Image" xtype="panel">
                             
                  <items jcr:primaryType="cq:WidgetCollection">
                                  ...
                             
                  </items>
                         
                  </tab2>
                     
                  </items>
                  </jcr:root>

                   

                   

                  java servlet:

                   

                   

                  @Component(immediate = true)
                  @Service
                  @Properties({
                     
                  @Property(name = "service.description", value = "Group Member servlet checks if a user is a member of a group."),
                     
                  @Property(name = "sling.servlet.paths", value = "/bin/member")
                  })
                  public class myServlet extends SlingAllMethodsServlet {

                   

                  .......

                  }

                   

                  my questions as following:

                  1.dose this way accords with my requirement?

                  2.should i need to declare the myServlet to any configuration file?

                  3.where should i place the myServlet.java to?

                  4.how can i know which field has been changed?

                   

                   


                  • 6. Re: How to custom the ok button in the edit dialog
                    rush_pawan Level 4

                    Hi,

                     

                    I have never come to this type of requirement but based on experience i can suggest as below.

                     

                    Answer1: I think you can use your servlet to get user information back for your track pursponse.

                    Answer2,3 : You can deploy your servlet as part of OSGI bundle using normal build process. As a best practice we create the file inside project src folder.

                    Answer4: Now i want to some of the thing here

                         a. You already have got user information from your servlet.

                         b. Now use the client listner function "beforestatesave" (i hope this will help you more than to other or search similar type of method which suits your requirement.) where you will have the object of component through which you can get the path of this component on page. So now because the data has not been saved to component you can use the path of component to fetch already stored data in respository and compare the values of properties that you want to track with current passed "this" object.

                     

                    I also recommend you to look into an example /apps/geometrixx/components/productlist/cq:editConfig/cq:listeners and go thourgh some of the public property or public methods of panel/tabpanel/component xtypes at here http://dev.day.com/docs/en/cq/current/widgets-api/index.html?class=CQ.Ext.Panel

                     

                    Let me know if you need more information.

                     

                    Thanks,

                    Pawan