Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Touch Premium Member
    Join Date
    May 2007
    Posts
    47
    Vote Rating
    0
    jimmy.honeycutt is on a distinguished road

      0  

    Default [CLOSED][3.??] Infinite Loop Firefox 2

    [CLOSED][3.??] Infinite Loop Firefox 2


    I am still getting this error in FireFox 2... are you guys still supporting FireFox 2? Running the code below gives me an infinite loop and memory hog. This error only happens in my FireFox. When I remove the "buttons" config object below, it works fine.

    Code:
    this.win = new Ext.Window({
                    applyTo:  'process-rx-window',
                    border: false,
                    closable: false,
                    height: 300,
                    width: 600,
                    layout: 'fit',
                    modal: true,
                    plain: true,
                    shadow: true,
                    y: 5, 
                    title: 'Process Prescriptions',
                    items: new Ext.form.FormPanel({
                        id: 'process-form',
                        labelAlign: 'right',
                        labelWidth: 75,
                        bodyStyle: this.bodyStyle,
                        //defaults: this.defaults,
                        items: [new Ext.form.FieldSet({
                            id: 'rx-fieldset',
                            fieldLabel: 'Pending Prescriptions',
                            autoHeight: false,
                            height: 200,
                            border: false,
                            autoScroll: true
                        }), new Ext.form.ComboBox({
                            id: 'process-type-combo',
                            displayField: 'type',
                            fieldLabel: 'Process',
                            hideTrigger: false,
                            minChars: 3,
                            mode: 'local',
                            readOnly: true,
                            forceSelection: true,
                            store: new Ext.data.ArrayStore({
                                // process types
                                data: [ ['Print'], ['Handwritten'], ['Phoned In'] ],
                                // data fields
                                fields: [{
                                    name: 'type'
                                }]
                            }),
                            typeAhead: false,
                            value: 'Print',
                            width: 200
                        })]
                    }),
                    buttons: [{
                        handler: this.process,
                        scope: this,
                        text: 'Process'
                    }, {
                        handler: this.cancel,
                        scope: this,
                        text: 'Close'
                    }]
                });

  2. #2
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    6
    mjlecomte will become famous soon enough mjlecomte will become famous soon enough

      0  

    Default


    The original thread is here:
    http://extjs.com/forum/showthread.ph...265#post345265

    That thread is labelled FIXED, so I have moved your post to this thread for better exposure.

    It would help if you posted in accordance with this thread:
    http://extjs.com/forum/showthread.php?t=71015

    For example, detail which version of Ext, which adapter, which FF version and if Firebug is being used and which version if so.

    Thank you.

  3. #3
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,170
    Vote Rating
    674
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    I just dropped the following into the latest 3.x SVN build:

    Code:
    Ext.onReady(function(){
        var x = new Ext.Window({
            border: false,
            closable: false,
            height: 300,
            width: 600,
            layout: 'fit',
            modal: true,
            plain: true,
            shadow: true,
            y: 5,
            title: 'Process Prescriptions',
            items: new Ext.form.FormPanel({
                id: 'process-form',
                labelAlign: 'right',
                labelWidth: 75,
                bodyStyle: this.bodyStyle,
                //defaults: this.defaults,
                items: [new Ext.form.FieldSet({
                    id: 'rx-fieldset',
                    fieldLabel: 'Pending Prescriptions',
                    autoHeight: false,
                    height: 200,
                    border: false,
                    autoScroll: true
                }), new Ext.form.ComboBox({
                    id: 'process-type-combo',
                    displayField: 'type',
                    fieldLabel: 'Process',
                    hideTrigger: false,
                    minChars: 3,
                    mode: 'local',
                    readOnly: true,
                    forceSelection: true,
                    store: new Ext.data.ArrayStore({
                        // process types
                        data: [['Print'], ['Handwritten'], ['Phoned In']],
                        // data fields
                        fields: [{
                            name: 'type'
                        }]
                    }),
                    typeAhead: false,
                    value: 'Print',
                    width: 200
                })]
            }),
            buttons: [{
                handler: this.process,
                scope: this,
                text: 'Process'
            }, {
                handler: this.cancel,
                scope: this,
                text: 'Close'
            }]
        });
        x.show();
    });
    Using FF 2.0.0.20 with no issue. Can you provide more information?
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  4. #4
    Touch Premium Member
    Join Date
    May 2007
    Posts
    47
    Vote Rating
    0
    jimmy.honeycutt is on a distinguished road

      0  

    Default


    sorry, evan. that code does run fine... tried to isolate the problem (without success).

    i'm not exactly sure what is going on. i'm trying to migrate our code from ext 2.0.2 to the new ext 3.0 our company recently purchased. when i remove the 'buttons' config from the window instantiation, everything runs fine. however, if the buttons are there, i get an infinite loop on FireFox 2.0.0.20.

    the following is our own component:

    Code:
    //Creates Uabhs.widget namespace in Ext
    Ext.ns('Uabhs.widget');
    
    /**
     * @class Uabhs.widget.ProcessRxWindow
     * @extends Ext.Component
     *
     * This is an interface that allows the user to process prescriptions
     * that are in 'Pending' status from the medication reconciliation grid.
     *
     */
    Uabhs.widget.ProcessRxWindow = Ext.extend(Ext.Component, {
    
        /**
         * {String/HTMLElement/Ext.Element} The div element this window is
         * applied to
         */
        applyTo: null,
        
        /**
         * {Ext.form.FormPanel} The prescription form
         */
        form: null,
        
        /**
         * {Ext.Window} The pop-up window containing this form
         */
        win: null,
        
        /**
         * {Ext.data.Record []} The array of pending prescriptions
         * to be processed
         */
        rxRecords: [],
        
        /**
         * {String []} The array of rxIds that were processed.
         * MedsEditorGrid.js uses this in the 'processcomplete'
         * event to reconcile the medications in its grid
         * that have been processed.
         */
        processedRxIds: [],
        
        /**
         * {String []} The type of process the prescriptions were
         * processed by.  MedsEditorGrid.js uses this in the 'processcomplete'
         * event to reconcile the medications in its grid that have been processed.
         */
        processedType: null,
        
        /**
         * {Object} A config object containing the body style applied
         * to all panels in this window
         */
        bodyStyle: '{background-color: #C6D7EF; padding: 3px;}',
        
        /**
         * {Object} A config object containing default values applied
         * to all panels in this window
         */
        defaults: {
            bodyStyle: '{background-color: #C6D7EF; padding: 3px;}',
            bodyBorder: false,
            border: false
        },
        
        /**
         * Initializes this form.  Called in every superclass all the way
         * up the chain to Ext.Component.  Not much done here because
         * this class practices lazy loading.
         */
        initComponent: function () {
            Uabhs.widget.ProcessRxWindow.superclass.initComponent.call(this);
            
            // add some events			
            this.addEvents({
                /**
                 * Fires when this window is shown
                 */
                show: true,
                /**
                 * Fires when the rx is cancelled
                 */
                cancel: true,
                /**
                 * Fires when the processing completes
                 */
                processcomplete: true,
                /**
                 * Fires when the processing fails
                 */
                processfailed: true
            });
        },
        
        /**
         * Initializes the window object.  This practices lazy loading
         * in that this method is not called until it is needed.
         */
        initWindow: function () {
            // lazy initialize the dialog and only create it once					
            if (!this.win) {
            
                // sets all error message images for form fields to appear on right side of element
                Ext.form.Field.prototype.msgTarget = 'side';
                
                // creates the form panel containing all the data fields to be populated
                // by the user.  this form appears directly beneath the above search form
                var formPanel = new Ext.form.FormPanel({
                    labelAlign: 'right',
                    labelWidth: 125,
                    bodyStyle: this.defaults.bodyStyle,
                    defaults: this.defaults
                });
                
                // creates the pop-up window containing the above forms
                this.win = new Ext.Window({
                    applyTo: this.applyTo || 'process-rx-window',
                    border: this.border || false,
                    closable: false,
                    defaults: this.defaults,
                    draggable: this.draggable || true,
                    height: this.height || 300,
                    width: this.width || 600,
                    layout: 'fit',
                    minimizable: this.minimizable || false,
                    minHeight: this.minHeight || 200,
                    minWidth: this.minWidth || 300,
                    modal: this.modal || true,
                    plain: this.plain || true,
                    shadow: this.shadow || true,
                    y: 5, //puts this window 5 pixels down from top of screen
                    title: 'Process Prescriptions',
                    items: new Ext.form.FormPanel({
                        id: 'process-form',
                        labelAlign: 'right',
                        labelWidth: 50,
    					bodyCssClass: 'form-body',
                        items: [ new Ext.form.FieldSet({
                            id: 'rx-fieldset',
                            autoHeight: false,
                            height: 200,
                            border: false,
                            autoScroll: true
                        }), new Ext.form.ComboBox({
                            id: 'process-type-combo',
                            displayField: 'type',
                            fieldLabel: 'Process',
                            hideTrigger: false,
                            minChars: 3,
                            mode: 'local',
                            readOnly: true,
                            forceSelection: true,
                            store: new Ext.data.ArrayStore({
                                // process types
                                data: [ ['Print'], ['Handwritten'], ['Phoned In'] ],
                                // data fields
                                fields: [{
                                    name: 'type'
                                }]
                            }),
                            typeAhead: false,
                            value: 'Print',
                            width: 200
                        })]
                    }),
                    buttons: [{
                        handler: this.process,
                        scope: this,
                        text: 'Process'
                    }, {
                        handler: this.cancel,
                        scope: this,
                        text: 'Close'
                    }] 
                });
                
                // set base params for the getBrandStrengths query before it executes
                this.win.findById('process-type-combo').on('beforequery', function (object) {
                    object.forceAll = true;
                });
                
                // on hide of this dialog, the prescription form is reset
                this.win.on('hide', this.reset, this);
                
                Ext.QuickTips.init();
            }
            
            return this.win;
        },
        
        /**
         * Use this method to get the window object, it practices
         * lazy loading
         * @returns {Ext.Window}
         */
        getWindow: function () {
            if (!this.win) {
                this.initWindow();
            }
            return this.win;
        },
        
        /**
         * Use this method to get the form object.  
         * @returns {Ext.form.BasicForm}
         */
        getForm: function () {
            if (!this.form) { 
                this.form = this.getWindow().findById('process-form').getForm();            
            }
            return this.form;
        },
        
        /**
         * Use this method to get the fieldset object
         * which contains the prescription checkboxes.
         * @returns {Ext.form.Fieldset}
         */
        getFieldset: function () {
            if (!this.fieldset) {
    			this.fieldset = this.getWindow().findById('rx-fieldset')			
            }
            return this.fieldset;
        },
        
        /**
         * Shows this window.  If this window is null, it
         * initializes the window (lazy loading).
         *
         * @param rxRecords {Ext.data.Record} the pending prescription records
         */
        show: function (rxRecords) {
    		var record, med, checkbox;
    		
    		this.rxRecords = rxRecords;
    		
            for (var i = 0; i < this.rxRecords.length; i++) {
                record = this.rxRecords[i];
                
                med = record.get('brandName');
                if (record.get('dose')) {
                    med += ' ' + record.get('dose');
                }
                if (record.get('route')) {
                    med += ' ' + record.get('route');
                }
                if (record.get('form')) {
                    med += ' ' + record.get('form');
                }
                if (record.get('frequency')) {
                    med += ', ' + record.get('frequency');
                }
                
                checkbox = new Ext.form.Checkbox({
                    id: record.get('rxId'),
                    name: record.get('rxId'),
                    checked: true,
                    inputValue: true,
                    hideLabel: true,
                    boxLabel: med
                });
                
                this.getFieldset().add(checkbox);
            }
            
            this.getWindow().show();
            
            this.fireEvent("show");
        },
        
        /**
         * Hides this prescription window.
         */
        hide: function () {
            // doesn't use getWindow() because if window hasn't been created,
            // there's no need to create one just to hide it.
            // however, it still cleans data that may exist in the form
            if (this.win) {
                this.win.hide();
            }
        },
        
        /**
         * Cancels and hides this prescription window.
         */
        cancel: function () {
            this.hide();
            this.fireEvent('cancel');
        },
        
        /*
         * Process the selected prescriptions
         */
        process: function () {
    		var rxIds = [], count = 0, i = 0, processType = null, hasCsa = false;
    		
            processType = this.getWindow().findById('process-type-combo').getValue();
            
            // disable buttons after click
            for (i = 0; i < this.getWindow().buttons.length; i++) {
                this.getWindow().buttons[i].disable();
            }
            
    		// loop through prescriptions to see which are selected for processing
            for (i = 0; i < this.rxRecords.length; i++) {			
                if (this.getWindow().findById(this.rxRecords[i].get('rxId')).getValue()) {
                    rxIds[count] = this.rxRecords[i].get('rxId');
    				
    				// checks if this prescription is a controlled substance
    				if(this.rxRecords[i].get('csaSchedule') && this.rxRecords[i].get('csaSchedule') > 0 && this.rxRecords[i].get('csaSchedule') < 6) {
    					hasCsa = true;
    				}
    				
                    count++;
                }			
            }
            
            if (count > 0) {
                // if process is print, print prescriptions
                if (processType === 'Print') {
                    this.processPrint(rxIds, hasCsa);
    				processType = 'Printed';
                }
                                       
                // ajax request to process the prescriptions 
                // which updates the status to each of the prescriptions
                // based upon the process type	
                Ext.Ajax.request({
                    url: Uabhs.xmlServletPath + 'MRProcessRxXmlServlet',
                    params: {
                        rxId: rxIds,
                        processType: processType
                    },
                    method: 'POST',
                    scope: this,
                    success: function (response, options) {
                        // get xml from the response
                        var dq = Ext.DomQuery, xml = response.responseXML;
                        
                        if (dq.selectValue('UABHS/Response/Success', xml) === 'true') {
    						this.processedRxIds = rxIds;
    						this.processedType = processType;
                            this.fireEvent('processcomplete');
                        } else {
                            this.processFailed();
                        }
                    },
                    failure: function (response, options) {
                        this.processFailed();
                    }
                });
            } else {
                Ext.MessageBox.alert('Error', 'There are no prescriptions selected to be processed.');
                // re-enable buttons
                for (i = 0; i < this.getWindow().buttons.length; i++) {
                    this.getWindow().buttons[i].enable();
                }
                
            }
        },
        
        /**
         * Prints the selected prescriptions
         * @param rxIds {String []} array of prescription id's
         * @param hasCsa true if one or more of the prescriptions is a controlled substance
         */
        processPrint: function (rxIds, hasCsa) {
            var autoPrint = Uabhs.isWindowsOs(), url = Uabhs.servletPath + 'MRPrintRxServlet?';
            
            for (var i = 0; i < rxIds.length; i++) {
                url += 'rxId=' + rxIds[i] + '&';
            }
            
            url += 'autoprint=' + autoPrint + '&samePage=true';
    		
    		if(hasCsa) {
    			url += '&hasCsa=true';
    		}
            
            Uabhs.printWindow(url, 'mr_print_page', 500, 500);
        },
        
        /*
         * Resets this form's fields.
         */
        reset: function () {
            for (var i = 0; i < this.rxRecords.length; i++) {
    			this.getFieldset().remove(this.rxRecords[i].get('rxId'));
    		}
            
            // enable buttons 
            for (i = 0; i < this.getWindow().buttons.length; i++) {
                this.getWindow().buttons[i].enable();
            }
            
            this.rxRecords = [];
    		
    		this.processedRxIds = [];
    		
    		this.processedType = null;
        },
        
        /**
         * Invoked when a failure occured when trying to save prescription.
         *
         * @param rx {Uabhs.widget.ProcessRxWindow} the prescription form.
         */
        processFailed: function () {
            Uabhs.alertFatalError('Process prescriptions failed.');
            this.fireEvent('processfailed');
            // enable buttons that were disabled after click
            for (var i = 0; i < this.getWindow().buttons.length; i++) {
                this.getWindow().buttons[i].enable();
            }
            
        },
        
        /**
         * Destroys combobox and removes listeners from this form.
         */
        destroy: function () {
            if (this.win) {
                this.win.destroy();
            }
        }
        
    });
    you can reference this component with the following code:

    Code:
    var RxRecord = Ext.data.Record.create([{
                    name: 'brandName',
                    type: 'string'
                }, {
                    name: 'dose',
                    type: 'string'
                }, {
                    name: 'route',
                    type: 'string'
                }, {
                    name: 'form',
                    type: 'string'
                }, {
                    name: 'frequency',
                    type: 'string'
                }, {
                    name: 'rxId',
                    type: 'string'
                }]);
                
    	var rx = new RxRecord({
    		brandName: 'Januvia',
    		dose: '25 mg',
    		route: 'oral',
    		form: 'tablet',
    		frequency: 'once a day',
    		rxId: '99999'
    	});
    			
    	var pendingRxs = [];
    	pendingRxs[0] = rx;
    			
            new Uabhs.widget.ProcessRxWindow().show(pendingRxs);

  5. #5
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    6
    mjlecomte will become famous soon enough mjlecomte will become famous soon enough

      0  

    Default


    I modified your code into something runnable and had no issues when running on FF2:

    Code:
    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    
        <title>Empty test page</title>
    
        <link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
    
        <script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
        <script type="text/javascript" src="../../ext-all.js"></script>
    
        <script type="text/javascript">
    Ext.BLANK_IMAGE_URL = '../../resources/images/default/s.gif';
    
    Ext.onReady(function(){
    
    var RxRecord = Ext.data.Record.create([{
                    name: 'brandName',
                    type: 'string'
                }, {
                    name: 'dose',
                    type: 'string'
                }, {
                    name: 'route',
                    type: 'string'
                }, {
                    name: 'form',
                    type: 'string'
                }, {
                    name: 'frequency',
                    type: 'string'
                }, {
                    name: 'rxId',
                    type: 'string'
                }]);
                
    	var rx = new RxRecord({
    		brandName: 'Januvia',
    		dose: '25 mg',
    		route: 'oral',
    		form: 'tablet',
    		frequency: 'once a day',
    		rxId: '99999'
    	});
    			
    	var pendingRxs = [];
    	pendingRxs[0] = rx;
    
            new Uabhs.widget.ProcessRxWindow({
            }).show(pendingRxs);
    
    });
    
    //Creates Uabhs.widget namespace in Ext
    Ext.ns('Uabhs.widget');
    
    /**
     * @class Uabhs.widget.ProcessRxWindow
     * @extends Ext.Component
     *
     * This is an interface that allows the user to process prescriptions
     * that are in 'Pending' status from the medication reconciliation grid.
     *
     */
    Uabhs.widget.ProcessRxWindow = Ext.extend(Ext.Component, {
    
        /**
         * {String/HTMLElement/Ext.Element} The div element this window is
         * applied to
         */
        applyTo: null,
        
        /**
         * {Ext.form.FormPanel} The prescription form
         */
        form: null,
        
        /**
         * {Ext.Window} The pop-up window containing this form
         */
        win: null,
        
        /**
         * {Ext.data.Record []} The array of pending prescriptions
         * to be processed
         */
        rxRecords: [],
        
        /**
         * {String []} The array of rxIds that were processed.
         * MedsEditorGrid.js uses this in the 'processcomplete'
         * event to reconcile the medications in its grid
         * that have been processed.
         */
        processedRxIds: [],
        
        /**
         * {String []} The type of process the prescriptions were
         * processed by.  MedsEditorGrid.js uses this in the 'processcomplete'
         * event to reconcile the medications in its grid that have been processed.
         */
        processedType: null,
        
        /**
         * {Object} A config object containing the body style applied
         * to all panels in this window
         */
        bodyStyle: '{background-color: #C6D7EF; padding: 3px;}',
        
        /**
         * {Object} A config object containing default values applied
         * to all panels in this window
         */
        defaults: {
            bodyStyle: '{background-color: #C6D7EF; padding: 3px;}',
            bodyBorder: false,
            border: false
        },
        
        /**
         * Initializes this form.  Called in every superclass all the way
         * up the chain to Ext.Component.  Not much done here because
         * this class practices lazy loading.
         */
        initComponent: function () {
            Uabhs.widget.ProcessRxWindow.superclass.initComponent.call(this);
            
            // add some events			
            this.addEvents({
                /**
                 * Fires when this window is shown
                 */
                show: true,
                /**
                 * Fires when the rx is cancelled
                 */
                cancel: true,
                /**
                 * Fires when the processing completes
                 */
                processcomplete: true,
                /**
                 * Fires when the processing fails
                 */
                processfailed: true
            });
        },
        
        /**
         * Initializes the window object.  This practices lazy loading
         * in that this method is not called until it is needed.
         */
        initWindow: function () {
            // lazy initialize the dialog and only create it once					
            if (!this.win) {
            
                // sets all error message images for form fields to appear on right side of element
                Ext.form.Field.prototype.msgTarget = 'side';
                
                // creates the form panel containing all the data fields to be populated
                // by the user.  this form appears directly beneath the above search form
                var formPanel = new Ext.form.FormPanel({
                    labelAlign: 'right',
                    labelWidth: 125,
                    bodyStyle: this.defaults.bodyStyle,
                    defaults: this.defaults
                });
                
                // creates the pop-up window containing the above forms
                this.win = new Ext.Window({
    //                applyTo: this.applyTo || 'process-rx-window',
                    border: this.border || false,
                    closable: false,
                    defaults: this.defaults,
                    draggable: this.draggable || true,
                    height: this.height || 300,
                    width: this.width || 600,
                    layout: 'fit',
                    minimizable: this.minimizable || false,
                    minHeight: this.minHeight || 200,
                    minWidth: this.minWidth || 300,
                    modal: this.modal || true,
                    plain: this.plain || true,
                    shadow: this.shadow || true,
                    y: 5, //puts this window 5 pixels down from top of screen
                    title: 'Process Prescriptions',
                    items: new Ext.form.FormPanel({
                        id: 'process-form',
                        labelAlign: 'right',
                        labelWidth: 50,
    					bodyCssClass: 'form-body',
                        items: [ new Ext.form.FieldSet({
                            id: 'rx-fieldset',
                            autoHeight: false,
                            height: 200,
                            border: false,
                            autoScroll: true
                        }), new Ext.form.ComboBox({
                            id: 'process-type-combo',
                            displayField: 'type',
                            fieldLabel: 'Process',
                            hideTrigger: false,
                            minChars: 3,
                            mode: 'local',
                            readOnly: true,
                            forceSelection: true,
                            store: new Ext.data.ArrayStore({
                                // process types
                                data: [ ['Print'], ['Handwritten'], ['Phoned In'] ],
                                // data fields
                                fields: [{
                                    name: 'type'
                                }]
                            }),
                            typeAhead: false,
                            value: 'Print',
                            width: 200
                        })]
                    }),
                    buttons: [{
                        handler: this.process,
                        scope: this,
                        text: 'Process'
                    }, {
                        handler: this.cancel,
                        scope: this,
                        text: 'Close'
                    }] 
                });
                
                // set base params for the getBrandStrengths query before it executes
                this.win.findById('process-type-combo').on('beforequery', function (object) {
                    object.forceAll = true;
                });
                
                // on hide of this dialog, the prescription form is reset
                this.win.on('hide', this.reset, this);
                
                Ext.QuickTips.init();
            }
            
            return this.win;
        },
        
        /**
         * Use this method to get the window object, it practices
         * lazy loading
         * @returns {Ext.Window}
         */
        getWindow: function () {
            if (!this.win) {
                this.initWindow();
            }
            return this.win;
        },
        
        /**
         * Use this method to get the form object.  
         * @returns {Ext.form.BasicForm}
         */
        getForm: function () {
            if (!this.form) { 
                this.form = this.getWindow().findById('process-form').getForm();            
            }
            return this.form;
        },
        
        /**
         * Use this method to get the fieldset object
         * which contains the prescription checkboxes.
         * @returns {Ext.form.Fieldset}
         */
        getFieldset: function () {
            if (!this.fieldset) {
    			this.fieldset = this.getWindow().findById('rx-fieldset')			
            }
            return this.fieldset;
        },
        
        /**
         * Shows this window.  If this window is null, it
         * initializes the window (lazy loading).
         *
         * @param rxRecords {Ext.data.Record} the pending prescription records
         */
        show: function (rxRecords) {
    
    		var record, med, checkbox;
    		
    		this.rxRecords = rxRecords;
    
            for (var i = 0; i < this.rxRecords.length; i++) {
    		
                record = this.rxRecords[i];
                
                med = record.get('brandName');
    
                if (record.get('dose')) {
                    med += ' ' + record.get('dose');
                }
                if (record.get('route')) {
                    med += ' ' + record.get('route');
                }
                if (record.get('form')) {
                    med += ' ' + record.get('form');
                }
                if (record.get('frequency')) {
                    med += ', ' + record.get('frequency');
                }
                
                checkbox = new Ext.form.Checkbox({
                    id: record.get('rxId'),
                    name: record.get('rxId'),
                    checked: true,
                    inputValue: true,
                    hideLabel: true,
                    boxLabel: med
                });
                
                this.getFieldset().add(checkbox);
            }
            
            this.getWindow().show();
            
            this.fireEvent("show");
        },
        
        /**
         * Hides this prescription window.
         */
        hide: function () {
            // doesn't use getWindow() because if window hasn't been created,
            // there's no need to create one just to hide it.
            // however, it still cleans data that may exist in the form
            if (this.win) {
                this.win.hide();
            }
        },
        
        /**
         * Cancels and hides this prescription window.
         */
        cancel: function () {
            this.hide();
            this.fireEvent('cancel');
        },
        
        /*
         * Process the selected prescriptions
         */
        process: function () {
    		var rxIds = [], count = 0, i = 0, processType = null, hasCsa = false;
    		
            processType = this.getWindow().findById('process-type-combo').getValue();
            
            // disable buttons after click
            for (i = 0; i < this.getWindow().buttons.length; i++) {
                this.getWindow().buttons[i].disable();
            }
            
    		// loop through prescriptions to see which are selected for processing
            for (i = 0; i < this.rxRecords.length; i++) {			
                if (this.getWindow().findById(this.rxRecords[i].get('rxId')).getValue()) {
                    rxIds[count] = this.rxRecords[i].get('rxId');
    				
    				// checks if this prescription is a controlled substance
    				if(this.rxRecords[i].get('csaSchedule') && this.rxRecords[i].get('csaSchedule') > 0 && this.rxRecords[i].get('csaSchedule') < 6) {
    					hasCsa = true;
    				}
    				
                    count++;
                }			
            }
            
            if (count > 0) {
                // if process is print, print prescriptions
                if (processType === 'Print') {
                    this.processPrint(rxIds, hasCsa);
    				processType = 'Printed';
                }
                                       
                // ajax request to process the prescriptions 
                // which updates the status to each of the prescriptions
                // based upon the process type	
                Ext.Ajax.request({
                    url: Uabhs.xmlServletPath + 'MRProcessRxXmlServlet',
                    params: {
                        rxId: rxIds,
                        processType: processType
                    },
                    method: 'POST',
                    scope: this,
                    success: function (response, options) {
                        // get xml from the response
                        var dq = Ext.DomQuery, xml = response.responseXML;
                        
                        if (dq.selectValue('UABHS/Response/Success', xml) === 'true') {
    						this.processedRxIds = rxIds;
    						this.processedType = processType;
                            this.fireEvent('processcomplete');
                        } else {
                            this.processFailed();
                        }
                    },
                    failure: function (response, options) {
                        this.processFailed();
                    }
                });
            } else {
                Ext.MessageBox.alert('Error', 'There are no prescriptions selected to be processed.');
                // re-enable buttons
                for (i = 0; i < this.getWindow().buttons.length; i++) {
                    this.getWindow().buttons[i].enable();
                }
                
            }
        },
        
        /**
         * Prints the selected prescriptions
         * @param rxIds {String []} array of prescription id's
         * @param hasCsa true if one or more of the prescriptions is a controlled substance
         */
        processPrint: function (rxIds, hasCsa) {
            var autoPrint = Uabhs.isWindowsOs(), url = Uabhs.servletPath + 'MRPrintRxServlet?';
            
            for (var i = 0; i < rxIds.length; i++) {
                url += 'rxId=' + rxIds[i] + '&';
            }
            
            url += 'autoprint=' + autoPrint + '&samePage=true';
    		
    		if(hasCsa) {
    			url += '&hasCsa=true';
    		}
            
            Uabhs.printWindow(url, 'mr_print_page', 500, 500);
        },
        
        /*
         * Resets this form's fields.
         */
        reset: function () {
            for (var i = 0; i < this.rxRecords.length; i++) {
    			this.getFieldset().remove(this.rxRecords[i].get('rxId'));
    		}
            
            // enable buttons 
            for (i = 0; i < this.getWindow().buttons.length; i++) {
                this.getWindow().buttons[i].enable();
            }
            
            this.rxRecords = [];
    		
    		this.processedRxIds = [];
    		
    		this.processedType = null;
        },
        
        /**
         * Invoked when a failure occured when trying to save prescription.
         *
         * @param rx {Uabhs.widget.ProcessRxWindow} the prescription form.
         */
        processFailed: function () {
            Uabhs.alertFatalError('Process prescriptions failed.');
            this.fireEvent('processfailed');
            // enable buttons that were disabled after click
            for (var i = 0; i < this.getWindow().buttons.length; i++) {
                this.getWindow().buttons[i].enable();
            }
            
        },
        
        /**
         * Destroys combobox and removes listeners from this form.
         */
        destroy: function () {
            if (this.win) {
                this.win.destroy();
            }
        }
        
    });
        </script>
    
    </head>
    <body></body>
    </html>

  6. #6
    Touch Premium Member
    Join Date
    May 2007
    Posts
    47
    Vote Rating
    0
    jimmy.honeycutt is on a distinguished road

      0  

    Default


    ok... when i commented out the "applyTo" as you did, it works. any idea why that is? in previous version, i applied the window to a div element.

  7. #7
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    6
    mjlecomte will become famous soon enough mjlecomte will become famous soon enough

      0  

    Default


    I'm going to update the status to CLOSED in absence of new information. Please post again to have the issue reopened.

Thread Participants: 2