• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using Ajax with MyFaces

 
Shasi Mitra
Ranch Hand
Posts: 101
Flex Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I've a page which has three data tables. I want the data in the two tables to be populated after the page loads.Can i do it using AJAX. I am new to AJAX. Or is there any component in Sandbox for this requirement. Any help is appreciated
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you want to use Ajax for this? Why not just the bean constructor or so?
 
Tim Holloway
Saloon Keeper
Posts: 18359
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bauke Scholtz wrote:Why do you want to use Ajax for this? Why not just the bean constructor or so?


Because Shasi wants to populate them after the page loads.

Yes, that's what AJAX is all about. But the easiest was to use AJAX to do that is to employ one of the AJAX-supporting JSF tag libraries such as RichFaces.

In fact, I'm using RichFaces + MyFaces myself on a major project.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This sounds more like as "immediately after the page loads". But if he only want to rerender page parts asynchronously on client interaction, then Ajax is indeed suitable. In that case I would recommend RichFaces/Ajax4jsf as well.
 
Tim Holloway
Saloon Keeper
Posts: 18359
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bauke Scholtz wrote:This sounds more like as "immediately after the page loads".


Hard to say. Even native English-speaking computer people can be a little hard to interpret sometime. But RichFaces works for me!
 
Shasi Mitra
Ranch Hand
Posts: 101
Flex Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using myfaces 1.1.6, tomahawk-1.1.8, tiles with jdk 1.4. Already i'm facing lot of problems cos i'm trying to use trinidad for breadcrumb which i could not resolve yet. If i include rich faces now, I'm scared I'll have incompatibility issues. My aim is to populate one table(which is a web service call) automatically after the page loads. That too without any client interaction. Please help as we have very less time for development.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shasi Mitra wrote:That too without any client interaction.
Then my first reply/question still stands.
 
Shasi Mitra
Ranch Hand
Posts: 101
Flex Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you tell me how to use it then..Please
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the bean constructor (or in initialization block or as lazy loading in getter) just obtain the desired list of row objects from your DAO class and assign it to a list property. In your JSF page just use a h:dataTable component whose value points to that list property.
 
Shasi Mitra
Ranch Hand
Posts: 101
Flex Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bauke Scholtz,
thanks for the reply. I tried that approach. But in that case too the whole page loads after all the database hits. The only solution for my requirement is using AJAX i think. Anyway thanks a lot. My actual requirement is to load the page partially with one table then load the other part slowly.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should have explained it before.

Well, go ahead with RichFaces then.
 
Shasi Mitra
Ranch Hand
Posts: 101
Flex Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Ajax4Jsf but not getting desired output. once the javascript method gets called whole page is getting refreshed and the style and font is changing. Anybody has any idea on how to use ajax4jsf and which tag satisfies my requirment(loading a particular portion of page after the pageloads)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic