0

I'm trying to find out how to make this work with the tag "ui:fragment". I'm using JSF 2.2 and Richfaces 4.

I have a combo, and when I select a value I want to show or hide the code inside my ui:fragment in function of the value selected.

Combo:

<rich:select id="mycombo" valueChangeListener="#{controller.comboChangeListener}" 
            selectFirstOnUpdate="false" value="#{controller.myComboValue}">
    <f:selectItems value="#{controller.getValues}" var="object" itemLabel="#{object.label}" itemValue="#{object.id}"/>
    <a4j:ajax event="selectitem" render="myHiddenFragment" />
</rich:select>

Fragment:

<ui:fragment rendered="#{controller.isMyValueSelected}" id="myHiddenFragment">
    <!-- Lots of things going on here -->
</ui:fragment>

Controller:

private boolean isMyValueSelected = false;

public void comboChangeListener(final ValueChangeEvent event) {
    if (event.getNewValue().equals(IConstantes.ID_THIS_VALUE)) {
         this.isMyValueSelected = false;
    } else {
         this.isMyValueSelected = true;
    }
}

I guess I'm missing something very silly, but I don't see it.

Thanks!

maqjav
  • 2,310
  • 3
  • 23
  • 35
  • 1
    I don't have the canonical question handy, but this a classical example of "you need to `render` a id that is already present in the HTML or JSF won't find a target to update". Try re-rendering the parent component of the `ui:fragment` (or introduce one). – mabi May 06 '14 at 06:20
  • 1
    possible duplicate of [Why do I need to nest a component with rendered="#{some}" in another component when I want to ajax-update it?](http://stackoverflow.com/questions/9010734/why-do-i-need-to-nest-a-component-with-rendered-some-in-another-component-w) – mabi May 06 '14 at 06:29
  • @mabi you are right. I added a parent component to this fragment and renderer this one instead, and then it worked! Thank you! – maqjav May 06 '14 at 07:01

0 Answers0