Announcement

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

    8.3p - DateItem.showPicker() method spoofing

    Hi,

    In 8.2p, we had the following code which worked fine. When we updated to 8.3p, it broke. The date picker
    does show up, but whenever the user selects a date using his mouse, the click mask stays up and the
    user can't click anywhere following the date picker popup closing.

    Code:
    /**
     * Class containing a spoofed version for the isc.DateItem class.
     */
    
    // grab copy of the original showPicker() method so we can call it
    isc.DateItem.addMethods({ showPickerOriginal : isc.DateItem.getPrototype().showPicker });
    
    isc.DateItem.addProperties
    ({
    	//----------------------------------------------------------------------------------------------------------------------------
        showPicker : function ()
    	{
    		if (this.isReadOnly())
    			return false;
    
    		if (this.showPickerOriginal)
    			return this.showPickerOriginal(arguments);
    
    		return true;
    	}
    });
    Any ideas why this isn't working anymore? Is there a better way to inject logic into SmartClient code,
    (aka spoofing methods) such as being done here without going thru the regular inheritance mechanism since
    we sometimes don't have control over the name of the objects that get created (factory?) ...

    Thanks,

    #2
    What you're doing here is not really supported. This pattern (storing a function under a new name, and having a new function that calls back to the original) can lead to some very obscure bugs in some cases. It seems like this is what you're hitting.

    Subclassing is usually the right way to handle this. As you say, FormItems are generated by a factory based on data type, so you don't necessarily explicitly specify the item type within your component. You can often handle this by specifying the editorType at a higher level -- either via a new SimpleType which inherits from Date but has a different explicit "editorType" specified, or by settings directly on your DataSource field.

    However before continuing down this path - what are you actually trying to achieve here? By default if you have a DateItem with "canEdit" set to false, the date-picker icon should be disabled, so you shouldn't need to be explicitly tweaking the code to suppress the "showPicker" call.
    Last edited by Isomorphic; 6 Jun 2013, 20:49.

    Comment


      #3
      I understand what you're saying about the necessity to have this code in the first place ...

      I'll carry out some testing of our app, and indeed, this could be some legacy code
      that is no longer required. If such is the case, we'll simply remove it, if not,
      we'll go down the sub-classing path instead of spoofing the Isomorphic class.

      Thanks,

      Comment

      Working...
      X