The moose likes JSF and the fly likes JSF 2.0 - Ajax not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF 2.0 - Ajax not working" Watch "JSF 2.0 - Ajax not working" New topic

JSF 2.0 - Ajax not working

David Lidz

Joined: Mar 30, 2011
Posts: 14
Im a complete beginner when it comes to ajax, but im trying to get something very simple going here.

Heres the JSF page code:

And this is the bean code:

If i've understood Ajax then only the text with the "test" id should render, the other text should stay the same, but it doesnt...
Have I misunderstood ajax?
Brendan Healey
Ranch Hand

Joined: May 12, 2009
Posts: 218

It should only change "test". What scope is your backing bean? you need to use ViewScoped with
Ajax. Also panelGrid has no layout attribute, use panelGroup with layout="block" to render a div.

If you put some logging in your getters you should find that they get called multiple times through
the phase lifecycle which makes it a good idea to almost always use IDE generated getters & setters.
There's always somewhere else to put additional logic. I realise that this is just a simple test but
this is something that can make your life easier in future.

Any particular reason for multiple forms? You may have to specify the naming container as well
as the component id, i.e. f:ajax render="formid:test".

David Lidz

Joined: Mar 30, 2011
Posts: 14
I put them in different forms as a last attempt to figure out why it wasnt working, I figured thta just maybe the form was updated

Also im using SessionScoped. Is only ViewScoped possible to use in conjuction with Ajax? And if so, why if I may ask?
I agree. Here's the link:
subject: JSF 2.0 - Ajax not working
It's not a secret anymore!