• Post Reply Bookmark Topic Watch Topic
  • New Topic

Switching Panels with Primefaces and p:ajax

 
Michael Oberleitner
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I'm new to JSF and Primefaces and I want to switch between panels dependening on the selection the user makes using an p:selectOneRadio.

This is the xhtml:


and this is the relevant part of the UserBean



The two p:outputLabels out and out2 get updated while switching the radio buttons and changePayment() gets also called, but the panels are always both visible no matter which radio button is chosen.
So how is it possible to do this?
 
Tim Holloway
Bartender
Posts: 18417
60
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you're going to want to kick yourself.

The attribute you want isn't "render=", it's "rendered="

Undefined attributes are ignored in JSF, the default value is always "rendered="true"". So...
 
Michael Oberleitner
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim, this was really stupid of me.
So I changed every 'render' to 'rendered' and now the p:outputPanel id="output" is not visible anymore.
Unfortunately the form elements still don't change, although the str property in the backing bean changes through the radio buttons.
Is it possible to do this that way?
 
Michael Oberleitner
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok the solution for this is:

because otherwise the form elements won't get rendered to html and java script is not able to switch them.
 
Tim Holloway
Bartender
Posts: 18417
60
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I'd put the forms inside the panelgroups, instead, then attach ID's to the panelgroups for AJAX reference purposes, rather than refreshing the forms.

What you're doing should work, but it's not quite as tidy to me.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!