DZone Forums
Go Back   DZone Forums > Community > Tools & IDEs > NetBeans
Reload this Page Visual Web JSF. Problem in the prerender() method.
Notices
Reply
 
LinkBack Thread Tools Display Modes
  (#1 (permalink)) Old
Member
 
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Join Date: Feb 2009
Default Visual Web JSF. Problem in the prerender() method. - 06-29-2009, 02:33 AM

Hi,

Firstable I am going to introduce my code,

Code:
if (productoDataProviderPieza.getRowCount() > 0) {
try {
if (!getRequestBean1().getAction().equalsIgnoreCase("productosDD")) {
List<Option> productosDDDefaultOptions = (List<Option>) productosDD.getItems();
Iterator<Option> i = productosDDDefaultOptions.iterator();
Option o = null;
Object idPieza = null;
if (i.hasNext()) {
o = i.next();
firstProductoId = o.getValue();
String miLabel = o.getLabel();
getApplicationBean1().getGetPiezaRowSetPK().setObject(1, miLabel);
getPiezaDataProviderPK.refresh();
RowKey rk = getPiezaDataProviderPK.findFirst("PIEZA.ID_PRODUCTO", firstProductoId);
idPieza = getPiezaDataProviderPK.getValue("PIEZA.ID_PIEZA", rk);
}
if (idPieza == null) {
getApplicationBean1().getPiezaRowSet().setObject(1, new Integer(-1));
getApplicationBean1().getPiezaRowSet().setObject(2, new Integer(-1));
piezaDataProvider.refresh();
getRequestBean1().setMensaje("No hay Productos");
} else {
getApplicationBean1().getPiezaRowSet().setObject(1, idPieza);
getApplicationBean1().getPiezaRowSet().setObject(2, firstProductoId);

if (piezaDataProvider instanceof RefreshableDataProvider) {
piezaDataProvider.refresh();

tableRowGroup1.setRowKey(piezaDataProvider.findFirst(
new String[]{"PIEZA.ID_PIEZA", "PIEZA.ID_PRODUCTO"},
new Object[]{idPieza, firstProductoId}));
}
}
}
} catch (Exception e) {
error("Cannot switch to producto " +
firstProductoId);
log("Cannot switch to producto " +
firstProductoId, e);
}
} else {
try {
getApplicationBean1().getPiezaRowSet().setObject(1, new Integer(-1));
getApplicationBean1().getPiezaRowSet().setObject(2, new Integer(-1));
piezaDataProvider.refresh();
getRequestBean1().setMensaje("No hay Productos");
} catch (Exception e) {
error("Cannot switch to producto " +
firstProductoId);
log("Cannot switch to producto " +
firstProductoId, e);
}
}
}
This is the code in the prerender() method.

My problem is the first time I select a Subcategoria from its
DDL. productosDD is a nested Producto DDL son when I select a Categoria and a Subcategoria the DDL Producto is loaded with a subset
of data of the table Producto. Well, when I select a Categoria and a Subcategoria it loads Producto and I get the first Item of the Producto DDL. Later I calculate the firstProductoId and idPieza and I hope that piezaDataProvider refresh with the new calculated values and my table show the new rows. But it does not work. And it does not only for the first time. The rest of the time the web app works ok.

And I do not Know what I am making wrong. I think the problem is in the prerender() method. I mean,

Code:
if (piezaDataProvider instanceof RefreshableDataProvider) {
piezaDataProvider.refresh();

tableRowGroup1.setRowKey(piezaDataProvider.findFirst(
new String[]{"PIEZA.ID_PIEZA", "PIEZA.ID_PRODUCTO"},
new Object[]{idPieza, firstProductoId}));
}
I do not think these are the correct sentences.
Any idea?

Here is the rest of the, needed to understand it, code,

Code:
piezaRowSet.setDataSourceName("java:comp/env/jdbc/ALMACEN_ApacheDerby");
piezaRowSet.setCommand("SELECT ALL ALMACEN.PIEZA.ID_PIEZA, ALMACEN.PIEZA.ID_PRODUCTO, ALMACEN.PIEZA.NOMBRE, ALMACEN.PIEZA.DESCRIPCION, ALMACEN.PIEZA.DISPONIBILIDAD, ALMACEN.PIEZA.ENTREGA, ALMACEN.PIEZA.PRECIO, ALMACEN.PIEZA.IMAGEN FROM ALMACEN.PIEZA INNER JOIN ALMACEN.PRODUCTO ON ALMACEN.PIEZA.ID_PRODUCTO = ALMACEN.PRODUCTO.ID_PRODUCTO WHERE ALMACEN.PIEZA.ID_PIEZA = ? AND ALMACEN.PIEZA.ID_PRODUCTO = ?");
piezaRowSet.setTableName("PIEZA");

piezaRowSetPK.setDataSourceName("java:comp/env/jdbc/ALMACEN_ApacheDerby");
piezaRowSetPK.setCommand("SELECT ALL ALMACEN.PIEZA.ID_PIEZA, ALMACEN.PIEZA.ID_PRODUCTO FROM ALMACEN.PIEZA");
piezaRowSetPK.setTableName("PIEZA");

getPiezaRowSetPK.setDataSourceName("java:comp/env/jdbc/ALMACEN_ApacheDerby");
getPiezaRowSetPK.setCommand("SELECT ALL ALMACEN.PIEZA.ID_PIEZA, ALMACEN.PIEZA.ID_PRODUCTO FROM ALMACEN.PIEZA INNER JOIN ALMACEN.PRODUCTO ON ALMACEN.PIEZA.ID_PRODUCTO = ALMACEN.PRODUCTO.ID_PRODUCTO WHERE ALMACEN.PRODUCTO.PRODUCTO LIKE ?");
getPiezaRowSetPK.setTableName("PIEZA");
Where the PK is formed by both, ID_PIEZA and ID_PRODUCTO being ID_PRODUCTO a foreign key.

Thanks in advance,
Jose Alvarez de Lara
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Eclipse or Visual Studio Shell? dduster Eclipse 2 01-29-2009 04:41 AM
Eclipse visual editor sakthikumaran Eclipse 0 10-06-2008 02:09 AM
Using JPA and visual java server face roberto1073 Java 0 08-29-2008 03:18 PM
JPA y Visual Java Server Faces roberto1073 Java 0 08-29-2008 03:09 PM
Eclipse Visual Editor. amitvyavahare Eclipse 0 02-29-2008 06:07 AM


Copyright 1997-2009, DZone, Inc.
vBulletin Skin developed by: vBStyles.com