How to override cq default xtype "textfiled" | Community
Skip to main content
Level 3
October 16, 2015
Solved

How to override cq default xtype "textfiled"

  • October 16, 2015
  • 3 replies
  • 955 views

Hi All,

Our requirement is to "Encode" the Authored content in "textfiled" ,"pathfiled","textarea" before it got submitted to CQ-Server.  For this we have overlayed  "TextFiled.js" and Overidden method "syncValue()" in the Overlayed file. It is working fine in almost all places (Authored content is getting encoded and saved properly in CRX ). But in not working in some places.  In "syncValue()" method we have written below code. We are not sure whether it is correct or not. We have copied and pasted this code from "RichText.js" file and made some minor modifications as per our requirement.

******************************************

    syncValue: function() {
        
            //var html = this.editorKernel.getProcessedHtml();
        if(this.isFormField){
            var html = this.getValue();
            if(this.contentEncoding){
            html=encodeURIComponent(html);
            }
            this.value=html;
            if (this.fireEvent("beforesync", this, html) !== false) {
                    if(this.el.dom){this.el.dom.value = html;}
                this.fireEvent("sync", this, html);
            }
        }
        
    },

**************************************************************

Please let me know

1) Is it fine if we override "syncValue()" Method in overlayed "textfield.js" file? if so source code is correct or not? if not which method we need to override?

2) In some places for Path filed's it is giving below Java script error. What is the reason? But in  Almost all places it is working fine (Encoding happening Properly).

TypeError: this.el is undefined
     
 
if(this.el.dom){this.el.dom.value = html;}

Note that:

We want do this using overlay concept only. Since we around 500+ text field's in our applications we  do not want do this using Dialog listenrs. Also we do not want to do this using OSGI-java listenrs for other reasons.

Any Help or Pointers on this  issue really appreciated.

Thanks

K Chaitanya

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

smacdonald2008
Level 10
October 16, 2015

You are on the right track as per the AEM documentation. That is, overlaying the component is the right process. Refer to the AEM Widget documentation at:

http://dev.day.com/docs/en/cq/5-6/widgets-api/index.html

for more information about the widgets you are working with, 

For: In some places for Path filed's it is giving below Java script error. 

Can you please paste the exact error. 

Level 3
October 16, 2015

HI Smacdonad,

1) Here is the error we are getting in brwser console.

TypeError: this.el is undefined
     
 
if(this.el.dom){this.el.dom.value = html;}

2) Most important thing we want to know is,  is it correct to override the method "syncValue()" ?  No documentation about this method is available. We have copied  this method code from "RichText.js" file  and made some minor modifications as per our requirement.

Thanks

K Chaitanya

Sham_HC
Sham_HCAccepted solution
Level 10
October 16, 2015