0

It's basically this Question: JSF 2.0 How to display a different h:panelGroup each time an item is selected from a selectOneMenu

But i'm using selectOneRadio and I don't have the f:ajax that the answers says it fixes. Any idea of what I could do to reRender my panelGroups?

I've tried with a4j:support but no success. It looks like it's going to reRender but nothing changes. Maybe i'm doing something wrong. So, I've put an onclick="submit()" on the selectOneRadio and it worked but it loads the whole page again.

<h:selectOneRadio value="#{myBean.selectedItem}" >
 <a4j:support event="onclick" reRender="regionSomeItem,regionAnotherItem" />
 <div class="cssClass">
  <f:selectItem itemValue="someItem" itemLabel="Some Item"/>
 </div>
 <div class="cssClass">
  <f:selectItem itemValue="anotherItem" itemLabel="Another Item"/>
 </div>
 <div class="clear"></div>
</h:selectOneRadio>

<a4j:region id="regionSomeItem" rendered="#{condition for some item}"/>

<a4j:region id="regionAnotherItem" rendered="#{condition for another item}"/>
Community
  • 1
  • 1
Gondim
  • 3,038
  • 8
  • 44
  • 62

1 Answers1

2

You need make a group outside the a4j:region with no tag rendered. It seems to conflict with the tag reRender of what is trying to reRender it.

<h:selectOneRadio value="#{myBean.selectedItem}" >
 <a4j:support event="onclick" reRender="allItemsInOneGroup" />
</h:selectOneRadio>

<h:panelGroup id="allItemsInOneGroup">

<a4j:region rendered="#{condition for some item}">
</a4j:region>

<a4j:region rendered="#{condition for another item}">
</a4j:region>

</h:panelGroup>
Gondim
  • 3,038
  • 8
  • 44
  • 62
niksvp
  • 5,545
  • 2
  • 24
  • 41
  • i'm already doing it. it doesn't work, unless i put on reRender a "submit()" that refreshes the whole page :( – Gondim May 30 '11 at 17:51
  • @pringlesinn - can you edit your question and add the regions you are reRendering? – niksvp May 31 '11 at 06:37
  • I edited your answer cause i found the answer and didn't want to answer in another place. – Gondim May 31 '11 at 13:26