Friday, April 23, 2010

Richfaces: Creation of rich:panelMenuGroup and rich:panelMenuItem

You can create your rich:panelMenuGroup and rich:panelMenuItem components in richfaces from a collection of parent components which internally contains another child collection.
In this scenario i have to show a rich navigation bar that contains the list of different products and each product has a list of particular brands i.e
                                                 Laptops--|
                                                                |--> IBM
                                                                |--> HP
                                                                |--> Sony
                                               Cameras--|
                                                                |--> Canon
                                                                |--> Sony

You can achieve this by using the following code:


<rich:panelMenu selectedChild="#{leftService.focusValue}" style="width:250px" mode="server"
                iconExpandedGroup="disc" iconCollapsedGroup="disc" iconExpandedTopGroup="chevronUp"
iconGroupTopPosition="right" iconCollapsedTopGroup="chevronDown" iconCollapsedTopPosition="right" expandSingle="true">
  <c:forEach var="pComp" items="#{leftService.plist}">
    <rich:panelMenuGroup id="#{pComp.id}" label="#{pComp.groupLabel}" value="#{leftService.menu[pComp.groupLabel]}" >
    <rich:effect for="#{pComp.id}" type="BlindDown" params="duration:1.5" disableDefault="true" event="onclick"/>
 <c:forEach var="cComp" items="#{pComp.childCompList}">
<rich:panelMenuItem label="#{cComp.label}" value="#{cComp.label}" disabled="#{cComp.disable}"
                   actionListener="#{testService.select}" disabledClass="#{cComp.disableStyle}" styleClass="#{cComp.fontStyle}">
<f:param value="#{cComp.label}" name="selectedValue"/>  
</rich:panelMenuItem>
</c:forEach>
 </rich:panelMenuGroup>
</c:forEach>
</rich:panelMenu>


Feel free to discuss....

No comments:

Post a Comment