I have a problem which should be easy but I have trouble with finding the solution. I have a database that I want to present in a datatable. However I need additional columns that get more information about the current row. For example - the database has a set of people with id numbers. What I need is to display the Name, Last Name, ID (all columns of database), but then I want to display the address which is in a different REST webservice and to get it I need to send the ID (from database). I hope I have described it clearly but just in case I will point out:
-my database has 3 columns: name, las name, id number
-I need to add a 4th column to my datatable with address
-to get the address I need to send the id number to a rest webservice
The only solution I was able to find so far i to add all database elements to a list or some container and then use it inside a bean. But that is unacceptable since the database is very big. There must be a simpler way but it seems that I can't form an adequate question for google to get the proper results :> Can any one give some advice?
I think you can solve you problem if you use a Component System event, exactly the preRenderComponent, you can use this event for every component in the address colum, you can pass to it the id number as <f:attribute> of the component, and in the listener of the preRenderComponent event you can get the id number attribute and call your RestWebService, The problem is it only fuction with JSF 2.0 because since this version there are the System Events.
Let me now if you're using JSF 2.0 to give you an example.
When a dream is ending because to come true - OCPJP 6,7. OCE JPA EE6. MCTS
Joined: Sep 01, 2009
Thank you Cesar,
Unfortunately I am using JSF 1.2 so far. But maybe I will swtich to 2.0
But any way it would be great to have an example you mentioned so if it is not a problem please post it. I would prefer to stick to 1.2 but if it is impossible or much harder than maybe I will have to use 2.0. Do you know how to solve this in 1.2?
Of course there is no problem, here is the code that I said to use with JSF 2.0.
And the System component listenerYou can improve this code implementing a cache it could be a Map that insert every address (put) when the data of table changes and get from the map with every request, but here you have an idea.
I'm not sure How Can I help you in JSF 1.2, May you post the code that you use to call the database data, maybe this could give an idea.
Joined: Sep 01, 2009
For now the DB is down and being modified. It turned out that I may need hibernate for connecting with it. But thank you for the advice with 2.0, maybe in the end I'll decide on that, but all other projects are 1.2 so thats undesirable for me :/