PDA

View Full Version : Help with 1 of the demos



linker85
1 May 2009, 4:57 PM
I´m using EXTJS-Demo-Src for a school proyect. I adapt this demo to make it work with sql instead of the hardcoded data. The problem comes when I try to load 2 datagrids, one of the datagrids doesn´t load and if I try to update the one not working I get:


Action: listAreaLaboral
Se ha realizado con exito la conexión a MySQL
Conexion Cerrada con Exito...
The serialized data from the server is:
{"AreaLaboral":{"class":"mypackage.util.JsonObjectResponse","data":[{"class":"mypackage.catalogos.AreaLaboral","id_area_padre":"1","id_org_ubicacion":"1","nombre":"1"},{"class":"mypackage.catalogos.AreaLaboral","id_area_padre":"2","id_org_ubicacion":"2","nombre":"dummyNombre2"},{"class":"mypackage.catalogos.AreaLaboral","id_area_padre":"3","id_org_ubicacion":"2","nombre":"4"},{"class":"mypackage.catalogos.AreaLaboral","id_area_padre":"4","id_org_ubicacion":"2","nombre":"nombre2"},{"class":"mypackage.catalogos.AreaLaboral","id_area_padre":"5","id_org_ubicacion":"1","nombre":"uno"},{"class":"mypackage.catalogos.AreaLaboral","id_area_padre":"7","id_org_ubicacion":"1","nombre":"a"}],"message":"Las Areas Laborales fueron obtenidas exitosamente","success":true,"totalRows":6}}
(vengo de ServletLog), Organizacion a la que pertenece el usuario:null
(vengo de ServletLog), SubArea a la que pertenece el usuario:null
(vengo de ServletLog), Grupos a los que pertenece el usuario:null
Action: list
The serialized data from the server is:
{"catalogo":{"class":"mypackage.util.JsonObjectResponse","data":[{"class":"mypackage.catalogos.AreaLaboral","id_area_padre":"1","id_org_ubicacion":"1","nombre":"1"},{"class":"mypackage.catalogos.AreaLaboral","id_area_padre":"2","id_org_ubicacion":"2","nombre":"dummyNombre2"},{"class":"mypackage.catalogos.AreaLaboral","id_area_padre":"3","id_org_ubicacion":"2","nombre":"4"},{"class":"mypackage.catalogos.AreaLaboral","id_area_padre":"4","id_org_ubicacion":"2","nombre":"nombre2"},{"class":"mypackage.catalogos.AreaLaboral","id_area_padre":"5","id_org_ubicacion":"1","nombre":"uno"},{"class":"mypackage.catalogos.AreaLaboral","id_area_padre":"7","id_org_ubicacion":"1","nombre":"a"}],"message":"Los Catalogos fueron obtenidos exitosamente","success":true,"totalRows":6}}
(vengo de ServletLog), Organizacion a la que pertenece el usuario:null
(vengo de ServletLog), SubArea a la que pertenece el usuario:null
(vengo de ServletLog), Grupos a los que pertenece el usuario:null
Action: loadCatalogo
StandardWrapperValve[CatalogoServlet]: PWC1406: Servlet.service() para el servlet CatalogoServlet desencadenó una excepción
java.lang.ClassCastException: mypackage.catalogos.AreaLaboral cannot be cast to mypackage.catalogos.Catalogo
at mypackage.servlets.CatalogoCRUDServlet.loadCatalogo(CatalogoCRUDServlet.java:456)
at mypackage.servlets.CatalogoCRUDServlet.doPost(CatalogoCRUDServlet.java:111)


Image aF shows one grid after being opened, imger cN shows a 2nd grid opened.

This are my methods inside the servlet that seems to be giving problems:


private String loadCatalogo(HttpServletRequest request) {

// Retrieve a list of person objects from the session and find
// the person to return by their id.
List<Catalogo> catalogos =
(List<Catalogo>) request.getSession().getAttribute("persons");

Catalogo requestedCatalogo = null;

if (request.getParameter("id") != null) {

int requestedCatalogoId = Integer.parseInt(
(String) request.getParameter("id").trim());

for (Catalogo c : catalogos) {
if (c.getId() == requestedCatalogoId) {
requestedCatalogo = c;
}
}
}

// Return successfully the JSON serialized Person object.
return serializeCatalogo(requestedCatalogo, true, "El Catalogo fue encontrado.");

// If the retrieval of a person failed in some way...exception, etc. then we pass
// a null in as the parameter for the person.
//return serializePerson(
// null, false, "Exception occurred during the retrieval of the person.");
}

private String loadAreaLaboral(HttpServletRequest request) {
List<AreaLaboral> areaLaborales =
(List<AreaLaboral>) request.getSession().getAttribute("persons");
AreaLaboral requestedAreaLaboral = null;
if (request.getParameter("id") != null) {
int requestedAreaLaboralId = Integer.parseInt(
(String) request.getParameter("id").trim());
for (AreaLaboral c : areaLaborales) {
Integer idD = new Integer(c.getId_area_padre());
if (idD == requestedAreaLaboralId) {
requestedAreaLaboral = c;
}
}
}
return serializeAreaLaboral(requestedAreaLaboral, true, "La AreaLaboral fue encontrada.");
}

The thing is that it doesn´t matter which html is opened 1st; the 1st opened html works and the 2nd...n fails.
I include the original demo that I´m using.