Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

How to override cq default xtype "textfiled"

Avatar

Level 3

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

1 Accepted Solution

Avatar

Correct answer by
Level 10
3 Replies

Avatar

Level 10

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. 

Avatar

Level 3

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

Avatar

Correct answer by
Level 10