1

I'm wondering why updating a form won't update a conditionally rendered selectItem. The commandButton (for testing purposes) is updated correctly as expected.

<h:form id="form">
    <h:selectOneMenu id="selectedGroupId" label="#{msgs.group_group}" value="#{groupBean.selectedGroupId}">
        <p:ajax event="change" listener="#{groupBean.selectGroupEvent}" update=":form"/>
        <f:selectItem rendered="#{empty groupBean.selectedGroupId}" itemLabel="#{msgs.global_select_select}" />
        <f:selectItems value="#{groupBean.availableGruppen}" />
   </h:selectOneMenu>
   <p:commandButton value="Test" actionListener="#{groupBean.test}" rendered="#{empty groupBean.selectedGroupId}"/> 
</h:form>

Any hints what I'm doing wrong here?

Thanks
Jonny

user871611
  • 3,307
  • 7
  • 51
  • 73

1 Answers1

1

There is no rendered attribute for f:selectItem.

According to this answer, you can use a <c:if> as a wrapper instead or modify your list of f:selecItems in your action method.

Community
  • 1
  • 1
Matt Handy
  • 29,855
  • 2
  • 89
  • 112
  • Hi Matt, thanks for your answer. I'm using MyFaces 2.1.7 and there is a rendered attribute for UISelectItem. `public class UISelectItem extends javax.faces.component.UIComponentBase { ... //BEGIN CODE COPIED FROM javax.faces.component._UISelectItem public void setRendered(boolean state) { super.setRendered(state); ... }` Or am I wrong again? Jonny – user871611 Apr 27 '12 at 08:58
  • 1
    And by the way: The worked like a charm (but I still want to use the rendered attribute, if there is one). Thanks a lot Matt – user871611 Apr 27 '12 at 09:06
  • Ok, I looked into Mojarra api doc. So this is different somehow. – Matt Handy Apr 27 '12 at 09:06
  • 1
    I also desperately need a property like itemRendered for f:selectItem. But it seems most experts want to achieve it in the backing controller, but I still think it is a very useful attribute. I have posted a link hear. http://stackoverflow.com/questions/17611620/filter-values-in-fselectitems-in-jsf-primefaces?noredirect=1#comment25670995_17611620 – Buddhika Ariyaratne Jul 13 '13 at 15:46