Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Visual Web JSF, nested drop down list  RSS feed

 
Jose Alvarez de Lara
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am making a web app using NetBeans 6.5 VWJSF framwork. My database has three tables
CATEGORIA, SUBCATEGORIA and PRODUCTO with a ManyToMany relationship. So I have made
two more tables CATEGORIA_SUBCATEGORIA and SUBCATEGORIA_PRODUCTO. Now the relationship
is ManyToOne - OneToMany.

The application has three JSP Categoria.jsp, Subcategoria.jsp and Producto.jsp.

Everything is ok, but in Producto.jsp I am using two nested Drop Down List. I select the categoria, and this
load the subcategoria DDL with the related data from the SUBCATEGORIA database table. This work fine. But
when I select the subcategoria I am using a Table component to load the related producto. And at this point
my app fails. And I do not know what I am doing wrong.

It is simple. In Subcategoria. jsp I am using a DDL categoria to load a Table component with the data of
SUBCATEGORIA database table related with the selected categoria.

This is my code for the nested DDLs,






Now what I am doing is first append rows in the Table component to add data
and at the end save de provided data, The code,



This is the method that does not work

Please help,

Thanks in advance,
Jose Alvarez de Lara
 
Jose Alvarez de Lara
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again,

I have got wrong.

This post must to be in Java Server Faces thread

Excuse me. Will you move it to its thread?

Regards,
Jose Alvarez de Lara
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Done.
 
Jose Alvarez de Lara
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have solved my issue. Just passing a flag on the request to the prerender method:

- if the flag says "nothing" I can change the DDLs selection
- if the flag says "addrows" or "saverows" I make it by keeping the current DDLs selection

Thanks a lot,
Jose Alvarez de Lara
 
Jose Alvarez de Lara
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Going on with my web over NetBeans 6.5 Visual Web JSF, I had to make some changes to my data model because an initial wrong design. But I want to talk about Piezas.java.

In Piezas.java I have three DDLs (Categorias, Subcategorias and Productos), three buttons (“New Pieza”, “Save Pieza”, and “Return to Index”) and a UIComponent Table that represents the selected Piezas.

The relationships between database tables is as follow,


Categoria
PK: ID_CATEGORIA

Subcategoria
PK: ID_SUBCATEGORIA
FK: ID_CATEGORIA

Producto
PK: ID_PRODUCTO
FK: ID_CATEGORIA
FK: ID_SUBCATEGORIA

Pieza
PK: ID_PIEZA
FK: ID_PRODUCTO


So my Piezas.java try CRUD based on this relationship. The DDLs Categorias and Subcategorias are set in a Virtual Form to set the DDL Productos. This works fine.
And when I select some categoria or subcategoria that take me to a producto´s non value, the UIComponent Table Pieza looks empty: ok.

I have three Virtual Forms, “categoria_subcategoria” to nest with the DDL Productos, “saveproducto” that save the new nested values on the DDL Productos on Participate and Submit the new pieza, and “save” to load the corresponding values on the UIComponent Table Pieza once selected a new producto.

What is my problem? When I try to add a new pieza, in the UIComponent Table Pieza appears the first row in the database table Pieza. I mean, there are two cases, there is no Producto and I cannot append any row, or there is a producto so when I append a new row it has to be from the entity of the selected Producto. Well, it is not. It is always from the entity of the first row of the database table Pieza.

This is my code,






It was taking me two weeks and I have any idea about the solution.
Please help.

Best regards,
Jose Alvarez de Lara
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!