aspose file tools*
The moose likes JSF and the fly likes Using Ajax with MyFaces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Using Ajax with MyFaces" Watch "Using Ajax with MyFaces" New topic
Author

Using Ajax with MyFaces

Shasi Mitra
Ranch Hand

Joined: Nov 27, 2008
Posts: 101

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

Joined: Oct 08, 2006
Posts: 2458
Why do you want to use Ajax for this? Why not just the bean constructor or so?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16142
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
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

Joined: Jun 25, 2001
Posts: 16142
    
  21

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

Joined: Nov 27, 2008
Posts: 101

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

Joined: Oct 08, 2006
Posts: 2458
Shasi Mitra wrote:That too without any client interaction.
Then my first reply/question still stands.
Shasi Mitra
Ranch Hand

Joined: Nov 27, 2008
Posts: 101

Can you tell me how to use it then..Please
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
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

Joined: Nov 27, 2008
Posts: 101

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

Joined: Oct 08, 2006
Posts: 2458
You should have explained it before.

Well, go ahead with RichFaces then.
Shasi Mitra
Ranch Hand

Joined: Nov 27, 2008
Posts: 101

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)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using Ajax with MyFaces