• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Switching Panels with Primefaces and p:ajax

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Saloon Keeper
Posts: 27792
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Saloon Keeper
Posts: 27792
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic