• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to use database row values to generate additional columns in datatable

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Adam,

I think If you are able to generate XML out of all the data you need, you may apply an XSLT transformer to display it on JSP.

Thanks,
Sandeep.
 
Ranch Hand
Posts: 90
Eclipse IDE Chrome Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Adam

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.

Regards
Cesar
 
Adam Kronicki
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Cesar Loachamin
Ranch Hand
Posts: 90
Eclipse IDE Chrome Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Adam.

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.

Regards
Cesar

 
Adam Kronicki
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 :/
 
reply
    Bookmark Topic Watch Topic
  • New Topic