Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Maximum call stack size exceeded when overriding TextAreaItem.setValue and using AutoFitTextAreaItem

    Hello isomorphic,

    I am facing this problem and I'm not sure whether it a bug or I am doing something wrong.

    I have an override of TextAreaItem.setValue (I need to manipulate the value in some cases)

    Code:
    isc.TextAreaItem.addMethods({
      ___originalTextAreaItemSetValue: isc.TextAreaItem.getPrototype().setValue,
      setValue: function(value) {
        // some override code
        this.___originalTextAreaItemSetValue(value);
      }
    });
    This work fine as long as I'm using TextAreaItem, but when I'm using AutoFitTextAreaItem I'm getting a "Maximum call stack size exceeded" exception.
    I have noticed that when my override of setValue is called for the AutoFitTextAreaItem, it is calling itself in an endless loop until it fails with that exception.

    Here is a snippet to demonstrate the problem - if you paste this code and run it, you will immediately get the error, but if you replace AutoFitTextAreaItem with just TextAreaItem, in the last line, it works!

    Code:
    isc.TextAreaItem.addMethods({
      ___originalTextAreaItemSetValue: isc.TextAreaItem.getPrototype().setValue,
      setValue: function(value) {
        // some override code
        this.___originalTextAreaItemSetValue(value);
      }
    });
    
    isc.DynamicForm.create({
      width:500, height:150,
      fields:[
        {
          title:"TextArea", titleOrientation:"top",
          editorType: "AutoFitTextAreaItem"
        }
      ]
    });
    Click image for larger version

Name:	2021-07-11_174955.png
Views:	155
Size:	14.1 KB
ID:	265912

    Please let me know if there a different way I should override setValue to avoid this problem or is this a bug on your side ?

    I am using SmartClient build v12.1p_2021-06-30

    Thanks in advance.
    Gil

    #2
    setValue is not a valid override point - notice how there is no documentation telling you when it would be called and what it would be valid to do. So this is one of many errors that might occur when attempting such an override. If you can let us know what kind of value transform it is that you need, we can show you the right override point.

    Also note, if setValue() were a valid override point, that would not be a valid override. You're just copying functions around, you need to instead call Super.

    Comment


      #3
      I need to transform 'value' into null when it is set to an empty string.
      Note that I don't want to create a subclass of TexAreaItem because then I would need to use that subclass everywhere and I would also need a corresponding subclass for AutoFitTextAreaItem.

      Having said that, I'm happy to learn what is the correct way to achieve such override.

      Thanks
      Gil

      Comment


        #4
        transformInput is the API you'd want for that.

        We understand about subclassing requiring more work than the apparent effort to hack the framework, but hacking the framework is definitely invalid and will lead to lots of problems. One area is: the framework reuses its own classes for many things (like dialogs opened by the grid being based on Window & DynamicForm, for example), so if you try to change core framework components for app-specific purposes, you'll break the framework.

        Because of this, please don't submit any issues before removing all such hacks and retesting.

        Comment

        Working...
        X