Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSF 2.0 - Ajax not working

 
David Lidz
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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".

Regards,
Brendan.
 
David Lidz
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic