Danijel
Danijel

Reputation: 8600

Is panelGroup allowed inside selectOneMenu?

Is this kind of "nesting" of panelGroup inside selectOneMenu allowed in JSF?

<p:selectOneMenu>
    <f:selectItem itemValue="MOUNT" itemLabel="Local directory" />
    <f:selectItem itemValue="AS3" itemLabel="Amazon S3" />
    <f:selectItem itemValue="FTP" itemLabel="FTP site" />
  <h:panelGroup rendered="#{ConfigBean.rackspace}">
    <f:selectItem itemValue="RCF" itemLabel="RackspaceCloud"/>
  </h:panelGroup>     
</p:selectOneMenu>

The 4th selectItem is never rendered, no matter if ConfigBean.rackspace is true.

I also tried p:outputPanel instead of h:panelGroup.

Upvotes: 0

Views: 252

Answers (2)

Avinash Singh
Avinash Singh

Reputation: 3787

you can wrap it in c:if but it won't rerender the selectitem if you change rackspace in your bean.

<c:if test="#{ConfigBean.rackspace}">
    <f:selectItem itemValue="RCF" itemLabel="RackspaceCloud"/>
  </c:if>  

Remember that JSTL components execute only during create view so you would not be able to add <f:selectItem itemValue="RCF" itemLabel="RackspaceCloud"/> based on the condition in your bean for subsequent POSTS.

Upvotes: 1

Daniel
Daniel

Reputation: 37061

You can't use <h:panelGroup for that... and you better not use <c:if for that (INMO its an overkill)

Instead just use f:selectItems and load it conditionally in the server side...

Upvotes: 1

Related Questions