PDA

View Full Version : MetaForm and RemoteValidator



michael melsen
15 Apr 2010, 1:14 AM
Hi everyone,

I have a small question. I have this panel that holds a metaform component. In order to add remote validation by the server I've overridden the Ext.form.TextField and added the following line of code:



Ext.override(Ext.form.TextField, {

getValue : function(){
return this.value;
},

setValue : function(v){
this.setRawValue(this.formatValue(v));
this.value = v;
return this;
},

// add plugin remotevalidator on each textfield
plugins:[Ext.ux.plugins.RemoteValidator],

// add url to rest service for validator
rvOptions: {url:'services/student/validate/personal' },


The form gets loaded with initial values. Upon editing a textfield in my form the validation is triggered but the problem I'm facing is that the original value is submitted instead of the value that the user changed the textfield to. Any ideas what could be wrong?

here is the code of my panel that holds the validator and metaform:



Ext.ns('Student.Details');

/**
* This component will contain the
* personal details of the student
*/
Student.Details.Personal = Ext.extend(Ext.Panel, {

id: "student-details-personal",

initComponent:function() {

Ext.apply(this, {
title : "Personalia",
closeAction: 'close',
align: 'center'
,bodyStyle: {"background-color":'#DFE8F6'},
defaults : {xtype: 'fieldset', collapsible: true, autoHeight: true, defaultType: 'container'}
,layout: 'form'
,items: [{
title: 'Persoonsgegevens'
,items: [{
defaults: {labelStyle: 'background-color: #c5d2df;',width: 200,labelWidth: 190},
xtype:'metaform',
url:'services/student/single/slNumber?'+ Ext.urlEncode({slNumber: getSelectedSlnumber(), excludeType:'PERSON'}),
method: 'POST'
}] // eo items persoonsgegevens

}, {
title: 'Identificerende gegevens'
,defaults: {labelStyle: 'background-color: #c5d2df;'}
,items: [{
defaults: {labelStyle: 'background-color: #c5d2df;',width: 200,labelWidth: 190},
xtype:'metaform',
url:'services/student/single/slNumber?'+ Ext.urlEncode({slNumber: getSelectedSlnumber(), excludeType:'IDENTIFICATION'}),
method: 'POST'
}] // eo identification items
}, {
title: 'Adres en contactgegevens'
,defaults: {labelStyle: 'background-color: #c5d2df;'}
,items: [{
defaults: {labelStyle: 'background-color: #c5d2df;',width: 200,labelWidth: 190},
xtype:'metaform',
url:'services/student/single/slNumber?'+ Ext.urlEncode({slNumber: getSelectedSlnumber(), excludeType:'CONTACT'}),
method: 'POST'
}] // eo contact items
}] // eo items
}); // eo apply

// call parent
Student.Details.Personal.superclass.initComponent.apply(this, arguments);
} // eo function initComponent

,onRender:function() {

// call parent
Student.Details.Personal.superclass.onRender.apply(this, arguments);

// this function returns the selected slnumber from the gridpanel with students
function getSelectedSlnumber(){
var selectedStudent = Ext.getCmp('search-student').getSelectionModel().getSelected();
return selectedStudent.get('slnumber');
};

Ext.override(Ext.form.TextField, {

getValue : function(){
return this.value;
},

setValue : function(v){
this.setRawValue(this.formatValue(v));
this.value = v;
return this;
},

// add plugin remotevalidator on each textfield
plugins:[Ext.ux.plugins.RemoteValidator],

// add url to rest service for validator
rvOptions: {url:'services/student/validate/personal' }
}
});

} // eo onRender
}); // eo extend

// register component
Ext.reg('student-details-personal', Student.Details.Personal);