Announcement

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

    Comprehension question: setDefaultProperties does not hand down, correct?

    Hi Isomorphic,

    just to be sure:

    If I call
    Code:
    FormItem fi = new FormItem() {
    	{
    		setHeight(30);
    	}
    };
    FormItem.setDefaultProperties(fi);
    at the very beginning of my application, this property is not set as well for inheriting subclasses, e.g. TextItem.
    Therefore it does not matter in which order I call setDefaultProperties() for classes and subclasses, if I want to set default properties for different form items.

    Is this correct?

    Thank you & Best regards,
    Blama

    #2
    Using setDefaultProperties() simply applies an instance property (a non-static property if you like) to the underlying SmartClient class. Class inheritance then works normally.

    In concrete terms:
    If you have class childClass which inherits from class parentClass and you set attribute someAttr on the parentClass (to "X", say), using setDefaultProperties, both parent and child class instances inherit the value for this attribute.

    However if you set childClass.someAttr (to "Y"), this overrides the value for instances of the child class only.

    childClassInstance.someAttr will be "Y", while parentClassInstance.someAttr will be "X".

    If you subsequently modify the value on the parent class (to "Z", let's say), this will not effect the child class which already has an overridden value of its own.

    So childClassInstance.someAttr will still be "Y", but now parentClassInstance.someAttr will be "Z".

    So - yes - the order in which you assign the attributes using setDefaultProperties doesn't matter - once you've overridden the value for a child class, it continues to be respected.

    Regards
    Isomorphic Software

    Comment


      #3
      Hi Isomorphic,

      thanks for the explanation.

      As the FormItem-code excerpt from my 1st post does not set the height for e.g. TextItem, this means that the (default) height for TextItem is defined elsewhere, correct?

      ...

      I just looked up load_skin.js - it has height-values for all the *Items. Of course FormItem.setDefaultProperties() can't overwrite these then.



      Thanks for the answer, I once more got a bit more insight.

      Best regards,
      Blama

      Comment

      Working...
      X