wood burning stoves 2.0*
The moose likes JSF and the fly likes creating a table component dynamically Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "creating a table component dynamically" Watch "creating a table component dynamically" New topic
Author

creating a table component dynamically

Miro Ricco
Ranch Hand

Joined: Apr 16, 2002
Posts: 40
Hello

First of all, thanks for reading this.
I'm JSF newby and I have a problem with the design...

I'd like to open a page with table displaying the data relevant to a selected item in a previous page. But I want to have a separate bean for accessing the data for every table. The bean should be initialised everytime the new table is opened. It may be one bean holding more sets of data for every table, but I don't know how should i manage the identification of the table ? The other problem is destroying the data for closed table in such a case.

Do you have a suggestion how to design it ?

MR
Miro Ricco
Ranch Hand

Joined: Apr 16, 2002
Posts: 40
No one can help me ?
ansar basha
Ranch Hand

Joined: Aug 02, 2005
Posts: 34
Hi Miro Ricco,

Please go through this first and let me try to answer your question.
http://faq.javaranch.com/view?PatienceIsAVirtue

Create the table data bean and add this to session for every table, for distroying the bean just invalidate the session.
Hopefully this provides some sort of solution to your problem.

Thanks
Ansar
Miro Ricco
Ranch Hand

Joined: Apr 16, 2002
Posts: 40
Hi ansar basha

Thank you for your reply.
I'm sorry I panic, but i have no idea for more than a week...

I understand I can configure a managed data bean in faces-config.xml and then use it to show a data in the jsf page. But how can i create more beans dynamically and use them in more jsf pages to show different data ?

I'm learning everything myself, maybe I've missed something basic.

Kind regards
MR
ansar basha
Ranch Hand

Joined: Aug 02, 2005
Posts: 34
Hi,
Great you are learning the JSF by your self thats good one .
You can give different atribute name for different table while setting
attributes in session. I hope you know how to get session from faces
context and set session.
Thanks
Ansar
Miro Ricco
Ranch Hand

Joined: Apr 16, 2002
Posts: 40
I think i have to describe my problem in more detail.

I have an index page, which is normal JSP and calls other JSF page containing the table, which contains dynamic data. In the sample i have fixed number of 3 tables, but i need to have possibility to open a table, which will then show new data based on a parameter.

Here is my sample.
It handles more tables, but when i have more tables opened at the same time and I add a row to a table, it shows data for the last opened table.
I'm sure it's missing some basic concepts.

At first faces-config.xml:


Index JSP page looks like this:


tableId attribute in the request identifies the table.

first.jsp:


MyTable.java:
Miro Ricco
Ranch Hand

Joined: Apr 16, 2002
Posts: 40
I see other problems now.
I've traced the program and I see that the add() method is not called after the button is pressed. It is called only when new window is opened from the index JSP page.
Also dTable.getRows() is called two times when rendering the page.

I have also changed the inputHidden as follows:

Now it remembers the table name also after pressing the Add button.
Miro Ricco
Ranch Hand

Joined: Apr 16, 2002
Posts: 40
Now I have my example working, but I'm not sure if it is the way it should be solved.

I use managed bean to hold the table id:






The problem regarding the add method which was not called was caused by param.tableId in inputHidden tag. It caused to throw this exception and thus the add method was not called:

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: creating a table component dynamically
 
Similar Threads
showing values in table on basis of column header
Java beans + JDBC
Listener Class and Regular Java
How do I Call a Bean Function Using JSP?
Getting HTML code from a java bean