ExtJS / Javascript本地运行(localhost)但不远程

时间:2018-01-24 03:11:01

标签: javascript java extjs extjs4

我有以下Javascript / ExtJS代码

Ext.define('KLIFT.view.vPavimento', {
extend: 'Ext.window.Window',

title: 'Pavimentos',
closeAction: 'destroy',
autoShow: true,
height: 400,
width: 400,
layout: 'fit',
modal: true,

idObra: null,

afterRender: function() {
    var me = this;

    me.gridPavimento = me.down('grid[name=gridPavimento]');
    me.botaoSalvar = me.down('button[name=botaoSalvar]');
    me.botaoCancelar = me.down('button[name=botaoCancelar]');

    if(me.idObra != null){
        me.carregaGrid();
    }

    me.callParent(arguments);
},

carregaGrid: function(){
    var me = this;

    me.setLoading(true);
    alert('cai aqui');
    me.gridPavimento.store.load({
        params: {
            idObra: me.idObra

        },
        callback: function(){
            me.setLoading(false);
        }
    });
},

desabilitarControles: function(o){
    var me = this;

    var opcao = false;

    if(o == true){
        opcao = true;
    }

    me.botaoSalvar.setDisabled(opcao);
    me.botaoCancelar.setDisabled(opcao);
},

salvarAlteracoes: function(){
    var me = this;

    me.gridPavimento.store.sync();
},

cancelarAlteracoes: function(){
    var me = this;

    me.gridPavimento.store.rejectChanges();
    me.gridPavimento.store.sort();
},

adicionarVarios: function(){
    var me = this;

    Ext.MessageBox.show({
        title: 'Criar varios pavimentos',
        msg: 
            '<table><tr><td>Quantidade de pavimentos:</td><td><input id="qtde" type="text" /></td></tr><tr><td>Medida pe direito:</td><td><input id="pdPadrao" pattern="[0-9.]+" type="number"   /></td></tr></table>',
        buttons: Ext.MessageBox.OKCANCEL,
        fn: function(btn) {
            if(btn == 'ok') {

                me.setLoading(true);

                //var qtde = Ext.get('qtde').getValue();
                //var pdPadrao = Ext.get('pdPadrao').getValue();

                quant = document.getElementById('qtde').value;
                pd = document.getElementById('pdPadrao').value;


                //pdPadrao = parseFloat(pdPadrao.replace(',', '.'));

                if(quant != "" && pd != ""){
                    Ext.Ajax.request({
                        async: false, 
                        url: '../pavimento/criarVarios',
                        method: 'GET',
                        params: {
                            idObra: me.idObra,
                            qtde: quant,
                            pdPadrao: pd
                        },
                        success: function(){
                            me.carregaGrid();
                        },
                        callback: function(){
                            me.setLoading(false);
                        }
                    });
                } else{
                    me.adicionarVarios();
                }
            }
        }
    });
},

initComponent: function(){
    var me = this;

    Ext.apply(me, {
        tbar: [{
            icon: '../img/add.png',
            text: 'Adicionar',
            handler: function(){
                me.gridPavimento.adicionaPavimento();
            }
        },{
            icon: '../img/delete.png',
            text: 'Remover',
            handler: function(){
                me.gridPavimento.removePavimento();
            }
        },{
            icon: '../img/add.png',
            text: 'Adicionar Varios',
            handler: function(){
                me.adicionarVarios();
            }
        }],
        bbar: [{
         icon: '../img/up.png',
            text: 'Sobe',
            handler: function(){
                me.gridPavimento.sobePavimento();
            }
        },{
            icon: '../img/down.png',
            text: 'Desce',
            handler: function(){
                me.gridPavimento.descePavimento();
            }
        },{
            icon: '../img/accept.png',
            name: 'botaoSalvar',
            text: 'Salvar Alteracoes',
            handler: function(){
                me.salvarAlteracoes();
            }
        },{
            icon: '../img/cross.gif',
            name: 'botaoCancelar',
            text: 'Cancelar Alteracoes',
            handler: function(){
                me.cancelarAlteracoes();
            }
        }],
        items: Ext.create('KLIFT.grid.gPavimento')
    });

    me.callParent(arguments);
}

});

此调用

Ext.Ajax.request({                             async:false,                             url:'../ pavimento / dentarVarios',                             方法:'GET',                             参数:{                                 idObra:me.idObra,                                 qtde:quant,                                 pdPadrao:encodeURIComponent(pd)                             },

将在服务器端调用java代码,如下所示:

@Get
public void criarVarios(Long idObra, int qtde, Double pdPadrao) throws Exception{

    try{
        session.beginTransaction();

        dao.excluirPorObra(idObra);

        for (int i = 1; i <= qtde; i++) {
            Pavimento p = new Pavimento();
            p.setIdObra(idObra);
            p.setPosicao(i);
            p.setMarcacaoVisual(String.valueOf(i));
            p.setMedidaPeDireito(pdPadrao);

            if(i == 1){
                p.setTerreo(true);
            }

            dao.create(p);
        }

        session.getTransaction().commit();

        String success = "true";
        result.use(Results.json()).from(success, "success").serialize();
    } catch (Exception e) {
        if(session.getTransaction().isActive())
            session.getTransaction().rollback();

        throw e;
    }
}

在Chrome本地运行时,我在此HTML输入文本中键入十进制值:

相应的java方法接受它为double(如2.5或3.23或1.457)

当我将这样的战争部署到远程服务器并从Chrome浏览器访问网页时,十进制模式不适用于输入类型和值类型,因为3.4来自java服务器端调用34.0。

我在服务器端使用Vraptor框架。 Wildfly 10.2作为服务器。 Ext-js版本4用于前端。请帮助,我不知道该怎么做,我不知道Ext.js并且不得不承担遗留项目。

0 个答案:

没有答案