• Publicidad (ayudanos a mantener el Foro haciendo un click sobre la misma)
  • Cuixer, una forma de administrar páginas web que nunca viste!

No soy capaz de submitar un form con servlet asociado

Foros generales de ayuda Ext 1.0.

Ext.foro.Nuevo
Mensajes: 4
Registrado: 23 Nov 2007, 13:57
NotaPublicado: 23 Nov 2007, 14:07
Hola Amigos,

Soy nuevo en esta libreria y estoy utilizandola para mi Proyecto de Fin de Carrera, pero aunque me lo he estado empollando por mi cuenta me he atascado en los submit de los formularios... Quiero que se ejecute un servlet de java simple un "hola mundo" pero no soy capaz de conseguirlo.

En este link esta el formulario de donde quiero lanzar el servlet al pulsar en el botón Enviar

http://pantuflo.escet.urjc.es/~jgonzale ... iones.html

Y el código de mi js esta extraido de los ejemplos de la web de extjs (el principio es solo paja para diseñar la interfaz):

Código: Seleccionar todo
/*
* Ext JS Library 2.0 RC 1
* Copyright(c) 2006-2007, Ext JS, LLC.
* licensing@extjs.com
*
* http://extjs.com/license
*/

Ext.onReady(function(){

    Ext.QuickTips.init();
   
   function showResult(btn){
        Ext.example.msg('Button Click', 'You clicked the {0} button', btn);
    };

    function showResultText(btn, text){
        Ext.example.msg('Button Click', 'You clicked the {0} button and entered the text "{1}".', btn, text);
    };
   
   
   /* Datos para la creación del grid */
      var xg = Ext.grid;
   
       // shared reader
       var reader = new Ext.data.ArrayReader({}, [
             {name: 'sistema'},
             {name: 'anagrama'},
            {name: 'jp'},
             {name: 'email'},
            {name: 'telefono'}
       ]);
      
      ////////////////////////////////////////////////////////////////////////////////////////
       // Grid para contener los sistemas para permitir la selección al usuario de los que participaran
      // en la pruebai
       ////////////////////////////////////////////////////////////////////////////////////////
         // Array data for the grids
   Ext.grid.dummyData = [
            ['SCM','QY','C','c','666'],
             ['SCM','QY','C','c','666'],
             ['SCM','QY','C','c','666']
                  ];
       var sm = new xg.CheckboxSelectionModel();
      var store = new Ext.data.Store({
            reader: reader,
               data: xg.dummyData
       })
      
       var cm=new xg.ColumnModel([
            sm,
            {id:'sistema',header: "Sistema", width: 100, sortable: true, dataIndex: 'sistema'},
            {header: "Anagrama", width: 100, sortable: true, dataIndex: 'anagrama'},
         {header: "Jefe de Proyecto", width: 100, sortable: true, dataIndex: 'jp'},
         {header: "Email", width: 100, sortable: true, dataIndex: 'email'},
         {header: "Telefono", width: 100, sortable: true, dataIndex: 'telefono'}
        ])
      



    // turn on validation errors beside the field globally
    Ext.form.Field.prototype.msgTarget = 'side';

   


    /*
     * ================  Formulario de Petición de Prueba Integrada  =======================
     */
   

    var tab2 = new Ext.FormPanel({
        labelAlign: 'top',
        title: 'Petición de Prueba de Prestaciones',
        bodyStyle:'padding:5px',
      
        width: 600,
        items: [{
            layout:'column',
            border:false,
            items:[{
                columnWidth:.5,
                layout: 'form',
                border:false,
                items: [{
                    xtype:'textfield',
                    fieldLabel: 'Proyecto',
                    name: 'proyecto',
                    anchor:'95%',
               allowBlank:false,
               maxLengthText:"5"
               
                }]
            },{
                columnWidth:.5,
                layout: 'form',
                border:false,
                items: [{
                    xtype:'textfield',
                    fieldLabel: 'Solicitante',
                    name: 'codpromdes',
                    anchor:'95%',
               allowBlank:false
                }]
            }]
        },{
            xtype:'tabpanel',
            plain:true,
            activeTab: 0,
            height:235,
            defaults:{bodyStyle:'padding:10px'},
            items:[{
                title:'Planificación',
                layout:'form',
                defaults: {width: 230},
                defaultType: 'textfield',

                items: [{
                    xtype:"datefield",
                fieldLabel:"Fecha Inicio Integración",
               anchor:'25%',
               format: "d/m/y",
                name:"fec_inicio_integracion"
                },{
                   xtype:"datefield",
                fieldLabel:"Fecha Fin Integración",
               anchor:'25%',
               format: "d/m/y",
                name:"fec_fin_integracion"
                }
            ]
            },{
            title:'Acceso a la aplicación',
            layout:'form',
            defaults: {width: 230},
                defaultType: "textfield",

                items: [{
                    xtype:'textfield',
                    fieldLabel: 'Modo de acceso',
                    name: 'mod_acceso',
                    anchor:'50%',
               allowBlank:true
                },{
                    xtype:'textfield',
                    fieldLabel: 'Login',
                    name: 'login',
                    anchor:'30%',
               allowBlank:true
                },{
                      xtype:'textfield',
                    fieldLabel: 'Password',
                    name: 'password',
                    anchor:'30%',
               allowBlank:true
                }]
                                        
            

         },{
            cls:'x-plain',
                title:'Descripción de las Pruebas',
                layout:'fit',
                items: {
                    xtype:'htmleditor',
                    id:'desc_pru'
                }
         },{
            cls:'x-plain',
                title:'Datos necesarios',
                layout:'fit',
                items: {
                    xtype:'htmleditor',
                    id:'desc_datos'
                }
         }]
        }],
      
        buttons: [{
            text: 'Enviar',
         handler:function()
               {
                  Ext.MessageBox.show({
                       msg: 'Almacenando su solicitud, espere por favor...',
                       progressText: 'Guardando datos..',
                       width:300,
                       wait:true,
                       waitConfig: {interval:200},
                       icon:'ext-mb-download' //custom class in msg-box.html
                       
                      });
                  
                  setTimeout(function(){
                           //This simulates a long-running operation like a database save or XHR call.
                           //In real code, this would be in a callback function.
                             Ext.MessageBox.hide();
                        Ext.MessageBox.show({
                                         title: 'OK',
                                         msg: 'Solicitud de prueba de prestaciones almacenada',
                                         buttons: Ext.MessageBox.OK,
                                         fn: showResult,
                                         icon: Ext.MessageBox.INFO
                            });
                        
                           
                    }, 8000);
                  
               }
        },{
            text: 'Cancelar'
        }]
      
    });
//tab2.render(document.body);
    tab2.render("myDiv");
});

He probado a poner el atributo url:'miservlet' en la definición del formulario, en el botón... pero no lo he conseguido. Alguien me podria iluminar???

Gracias a todos por vuestra ayuda.

Un saludo!!!
Para no ver esta publicidad, debes ser usuario del Foro.
Publicidad (ayudanos a mantener el Foro haciendo un click sobre la misma)


Cuixer, una forma de administrar páginas web que nunca viste!


Ext.foro.Nuevo
Mensajes: 4
Registrado: 23 Nov 2007, 13:57
NotaPublicado: 24 Nov 2007, 08:21
Conseguido. Por si algun perdido y principiante como yo le pasará lo mismo, la solución es bastante sencilla....

Cuando creamos el FormPanel le tenemos que poner la propiedad 'url' el servlet a ejecutar, posterioremente cuando definimos los botones tenemos que hacer referencia al evento de submitar el formulario..Se ve mejor con un ejemplo

Código: Seleccionar todo
.....
var tab2 = new Ext.FormPanel({
        labelAlign: 'top',
        title: 'Mi titulo',
        bodyStyle:'padding:5px',
   url:'http://ip:port/ext2.0/servlet/miservlet',
        width: 600,
....

Y ya en la definición de los botones
Código: Seleccionar todo
....
         buttons: [{
         text: 'Enviar',
         handler: function() {
         if (tab2.form.isValid()) {
               //Si el formulario es válido, lo enviamos
               tab2.form.submit({
                     waitMsg:'Enviando petición, espere por favor',
                     reset: false,
               failure: function(tab2, action) {
                  Ext.MessageBox.alert('Error', 'Error....');
               },
               success: function(tab2, action) {
                  Ext.MessageBox.show({
                                         title: 'OK',
                                         msg: 'OK',
                                         buttons: Ext.MessageBox.OK,
                                         icon: Ext.MessageBox.INFO
                            });
               }
               });
         }
         else Ext.MessageBox.alert('Error', 'El formulario no es correcto, revise los campos');
         }
         }]

Ext.foro.Nuevo
Mensajes: 4
Registrado: 14 Ene 2008, 00:05
NotaPublicado: 14 Ene 2008, 00:07
Hola julimirin. Y en el servlet... ¿Cómo recuperas la información? Estoy muy interesado en esa parte, pero aun no he conseguido hacerlo funcionar, pues yo lo leo con request.getParameter y no me funciona.
A ver si me das una mano.
¡Gracias!
Richard

Ext.foro.Nuevo
Mensajes: 8
Registrado: 02 Sep 2008, 16:31
NotaPublicado: 02 Oct 2008, 16:47
Yo lo hago asi y funciona:

Código: Seleccionar todo
System.out.println(request.getParameter("nombreDelParametro"));

esto dentro de doPost o doGet
Maña>=Fuerza
Vivo en un lugar donde crecen los árboles rojos y bajan las lluvias.

¿Donde? aqui: 18°30′13″N 88°18′19″O

Volver a Ext 1.0: Ayuda





  • Publicidad (ayudanos a mantener el Foro haciendo un click sobre la misma)
  • Cuixer, una forma de administrar páginas web que nunca viste!