PDA

View Full Version : [DUPE/FIXED] XDS produces incorrect code for FormPanel and BorderLayout regions.



Condor
20 Aug 2010, 7:06 AM
(I'm not using XDS myself and I am only reporting this for another user (http://www.sencha.com/forum/showthread.php?107626-FORM-POST-dont-work-if-panel-form-isnt-inside-window), so correct me if I've missed something)

The Designer doesn't take into account that BasicForm and BorderLayout.Region are constructed from the initialConfig of the component.

Example: The following two panels won't use the marked config options, because they are not part the the object's initialConfig.

MyPanelUi = Ext.extend(Ext.Panel, {
title: 'My Panel',
region: 'west',
width: 200,
split: true,
initComponent: function() {
MyPanelUi.superclass.initComponent.call(this);
}
});
MyFormUi = Ext.extend(Ext.form.FormPanel, {
title: 'My Form',
layout: 'form',
standardSubmit: true,
url: 'myurl.html',
initComponent: function() {
MyFormUi.superclass.initComponent.call(this);
}
});

Condor
20 Aug 2010, 7:16 AM
I read (http://www.sencha.com/forum/showthread.php?107642-FORM-POST-dont-work-if-panel-form-isnt-inside-window&p=503619#post503619) that the next maintenaince release already fixes the BasicForm problem. Does it also fix the BorderLayout.Region problem?

Condor
20 Aug 2010, 7:33 AM
I did a quick scan of the Ext code and initialConfig is used by a lot more components than I thought.

AnchorLayout
BorderLayout
ToolbarLayout
ComboBox
SliderField
GridView
FormPanel
and some other components that you can't define in XDS.

jarrednicholls
20 Aug 2010, 12:34 PM
Hey Condor,

Yes all of the configurations for components that are read from initialConfig are going to be applied to a config object and passed into a constructor, rather than set directly on the prototype or set within initComponent.

The change to, for example the FormPanels, will look like this:



MyFormUi = Ext.extend(Ext.form.FormPanel, {
title: 'My Form',
layout: 'form',
constructor: function(config){
MyFormUi.superclass.constructor.call(this, Ext.apply(config || {}, {
standardSubmit: true,
url: 'myurl.html'
}));
},
initComponent: function() {
MyFormUi.superclass.initComponent.call(this);
}
});


Since they will be passed into the constructor as a part of the config object, they will be set to the initialConfig object in Ext.Component.constructor.

Condor
20 Aug 2010, 11:17 PM
No, that's wrong. It should be:

MyFormUi.superclass.constructor.call(this, Ext.apply({
standardSubmit: true,
url: 'myurl.html'
}, config));
1. You should not modify the config object (it could be reused to create more objects).
2. You should be able to override the default options with the config object.

ps. Which properties do you currently have marked as being required in the constructor?

jarrednicholls
21 Aug 2010, 5:03 AM
Yes I know, I just typed it up wrong but that's what I'm doing. It will be the same as the Store generated code:



MyStore = Ext.extend(Ext.data.JsonStore, {
constructor: function(cfg) {
cfg = cfg || {};
MyStore.superclass.constructor.call(this, Ext.apply({
storeId: 'MyStore'
}, cfg));
}
});


Which properties? All that are read from initialConfig of course. In the case of FormPanel, all that belong to BasicForm.

Condor
23 Aug 2010, 12:45 AM
Which properties? All that are read from initialConfig of course. In the case of FormPanel, all that belong to BasicForm.

Did you scan the entire Ext codebase? (e.g. do you set 'width' in the constructor when a component is in an AnchorLayout?).