PDA

View Full Version : Weird...



danielbertini
12 Oct 2010, 11:51 AM
When i try post this form i get the error:

uncaught exception: [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIXMLHttpRequest.open]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: http://localhost/ekompro/resources/extjs/adapter/ext/ext-base.js :: i :: line 7" data: no]

Line 0



var topContainer = new Ext.Container({
layout:'form',
defaults:{
labelStyle: 'font-size:11px; color:#333; font-weight:bold;',
xtype: 'textfield',
},
items: [{
fieldLabel: 'Nome',
name: 'name',
anchor: '90%',
allowBlank: false
},{
xtype: 'combo',
fieldLabel: 'Status',
name: 'status',
anchor: '90%',
triggerAction: 'all',
editable: false,
allowBlank: false,
store: ['Ativa','Inativa']
}]
});

var categoryStore = new Ext.data.JsonStore({
url: base_url+'catalog/category/gridCheckBox',
baseParams: {limit:9999},
root: 'results',
remoteSort: true,
autoDestroy: true,
autoLoad: true,
fields:[
{name:'id'},
{name:'name'}
]
});

var smCategoryGrid = new Ext.grid.CheckboxSelectionModel();
var categoryGrid = new Ext.grid.GridPanel({
title: 'Categorias',
layout: 'fit',
border: false,
columnLines: true,
loadMask: true,
store: categoryStore,
sm: smCategoryGrid,
columns:[
smCategoryGrid,
{header:'Categoria', dataIndex:'name', width:100, sortable:false}
],
plugins:[
new Ext.ux.plugins.CheckBoxMemory({idProperty:'id'}),
],
viewConfig:{
forceFit:true
}
});

var tabPanel = new Ext.TabPanel({
xtype: 'tabpanel',
activeTab: 0,
autoScroll: true,
plain: true,
deferredRender: false,
flex: 1,
items:[{
title: 'Configurações',
layout: 'form',
frame: false,
autoHeight: true,
bodyStyle: 'padding:12px 0px 0px 0px;',
defaults:{
labelStyle: 'font-size:11px; color:#333; font-weight:normal;',
anchor: '90%',
xtype: 'textfield',
},
items:[{
labelStyle: 'font-size:11px; color:#333; font-weight:bold;',
xtype: 'combo',
fieldLabel: 'Tipo de desconto',
name: 'discount_type',
value: 'Porcentagem',
triggerAction: 'all',
editable: false,
anchor: '90%',
allowBlank: false,
store: ['Porcentagem','Valor fixo'],
listeners :{
'select':function(combo, record, idx){
if(idx === 0){
Ext.getCmp('percentage_value').enable();
Ext.getCmp('fixed_value').disable();
Ext.getCmp('fixed_value').setValue('');
}
if(idx === 1){
Ext.getCmp('percentage_value').disable();
Ext.getCmp('fixed_value').enable();
Ext.getCmp('percentage_value').setValue('');
}
}
}
},{
fieldLabel: 'Porcentagem',
name: 'percentage_value',
id: 'percentage_value',
xtype: 'numberfield',
allowNegative: false
},{
disabled: true,
xtype: 'moneyfield',
fieldLabel: 'Valor fixo',
name: 'fixed_value',
id: 'fixed_value'
},{
xtype: 'datefield',
editable: false,
fieldLabel: 'Data de início',
name: 'date_to_start'
},{
xtype: 'datefield',
editable: false,
fieldLabel: 'Data de término',
name: 'date_to_end'
}]
},
categoryGrid
]
});

var promotionAddForm = new Ext.FormPanel({
xtype: 'form',
frame: false,
border: false,
baseCls: 'x-plain',
labelAlign: 'right',
autoHeight: false,
labelWidth: 130,
defaults:{
labelStyle: 'font-size:11px; color:#333; font-weight:bold;',
xtype: 'textfield',
},
layout:{
type: 'vbox',
align: 'stretch'
},
items:[topContainer, tabPanel]
});

var promotionAddWin = new Ext.Window({
id: 'promotion-add-win',
title: 'Adicionar Promoção',
width: 640,
height: 480,
closable: true,
resizable: true,
maximizable: true,
modal: true,
bodyStyle: 'padding:5px; padding-top:10px;',
layout: 'fit',
items: [promotionAddForm],
buttons: [{
text: 'Cancelar',
handler: function(){ promotionAddWin.close(); }
},{
text:'Adicionar',
handler: function(){
if(promotionAddForm.form.isValid()){
var mask = new Ext.LoadMask(Ext.get('promotion-add-win'), {msg:'Adicionando. Por favor, aguarde.'});
mask.show();
promotionAddForm.form.submit({
method:'post',
params:{
categories:''+getSelectedCategories()+''
},
success:function(form,action){
promotionAddWin.close(this);
promotionStore.reload();
},
failure: function(form,action){
mask.hide();
switch (action.failureType) {
case Ext.form.Action.CLIENT_INVALID:
Ext.Msg.alert('Erro:', 'Verifique o preenchimento do formulário.');
break;
case Ext.form.Action.CONNECT_FAILURE:
Ext.Msg.alert('Erro:', 'Ocorreu uma falha de conexão. Tente novamente, caso o erro persista entre em contato com o atendimento.');
break;
case Ext.form.Action.SERVER_INVALID:
//Ext.Msg.alert('Erro:', 'Ocorreu uma falha no sistema. Reporte este problema ao atendimento.');
break;
default:
Ext.Msg.alert('Erro:', 'Ocorreu uma falha no sistema. Reporte este problema ao atendimento.');
}
}
});

}
}
}]
});

promotionAddWin.show(this);

function getSelectedCategories(){
var ids = null;
var arr=dat1;
var sorted_arr = arr.sort();
var results = [];
for(var i = 0; i < arr.length; i += 1) {
if(sorted_arr[i + 1] != sorted_arr[i]) {
results.push(sorted_arr[i]);
}
}
var new_result=[];
for(i=0;i<results.length;i++){
if(categoryGrid.plugins[0].items[results[i]]==true){
new_result.push(results[i]);
//applicationGrid.plugins[0].items[results[i]]=false;
ids = new_result;
}
}
if(ids){ return ids; }
}