Uploaded image for project: 'RichFaces'
  1. RichFaces
  2. RF-12845

rich:menuItem does not work as composite component

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Done
    • Affects Version/s: 4.3.1
    • Fix Version/s: 4.5.16
    • Component/s: component-menu
    • Labels:
    • Environment:

      Win7 x64, Java 6 x64, Tomcat 7.0.30 x64, RF 4.3.1, IE8 + FF19.0.2

    • Steps to Reproduce:
      Hide

      see description

      Show
      see description
    • Workaround Description:
      Hide

      Don't use rich:menuItem in a composite component...

      Show
      Don't use rich:menuItem in a composite component...

      Description

      When creating a composite component that contains a rich:menuItem, the menu item is not showing. => Client side error while identifying the menu items parent via css-selector.

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html 	xmlns="http://www.w3.org/1999/xhtml"  
      		xmlns:h="http://java.sun.com/jsf/html"
      		xmlns:f="http://java.sun.com/jsf/core"
      		xmlns:rich="http://richfaces.org/rich"
      		xmlns:composite="http://java.sun.com/jsf/composite">
      		
      	<composite:interface>
      		<composite:attribute name="icon" type="java.lang.String" required="false" />
      		<composite:attribute name="label" type="java.lang.String" required="true" />
      		<composite:attribute name="menuItem" type="java.lang.String" required="true" />
      		<composite:attribute name="menuKey" type="java.lang.String" required="true" />
      		<composite:attribute name="value" type="java.lang.String" required="true" />
      	</composite:interface>
       
      	<composite:implementation>
      		<rich:menuItem label="#{cc.attrs.label}" icon="#{cc.attrs.icon}" action="#{menuController.menuItemClicked}" rendered="#{menuController.isMenuItemAccessible( cc.attrs.menuKey, cc.attrs.menuItem )}">
      			<f:param name="selectedItem" value="#{cc.attrs.value}" />
      		</rich:menuItem>
      	</composite:implementation>
      		
      </html>
      

      Including the resulting composite component in a rich:dropDownMenu like

      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
      			    xmlns:ui="http://java.sun.com/jsf/facelets"
      			    xmlns:h="http://java.sun.com/jsf/html"
      			    xmlns:f="http://java.sun.com/jsf/core"
      			    xmlns:a4j="http://richfaces.org/a4j"
      			    xmlns:rich="http://richfaces.org/rich"
      			    xmlns:xxx="http://java.sun.com/jsf/composite/xxx">
      			    
              <rich:toolbar>
                  <rich:dropDownMenu>
                      <f:facet name="label">
                          <h:outputText value="Test" />
                      </f:facet>
                      <xxx:menuItem label="Item 1" value="item1" menuKey="aaa" menuItem="bbb" />
                  </rich:dropDownMenu>
              </rich:toolbar>
      		
      </ui:composition>
      

      ... reproduces the problem. Writing the rich:menuItem directly inside the rich:dropDownMenu works. Also wrapping the composite component with rich:menuGroup works. Only the direct child option fails.

      See example for comparison - item 2 and 3 are working, while item 1 is not:

      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
      			    xmlns:ui="http://java.sun.com/jsf/facelets"
      			    xmlns:h="http://java.sun.com/jsf/html"
      			    xmlns:f="http://java.sun.com/jsf/core"
      			    xmlns:a4j="http://richfaces.org/a4j"
      			    xmlns:rich="http://richfaces.org/rich"
      			    xmlns:xxx="http://java.sun.com/jsf/composite/xxx">
      			    
              <rich:toolbar>
                  <rich:dropDownMenu>
                      <f:facet name="label">
                          <h:outputText value="Test" />
                      </f:facet>
                      <xxx:menuItem label="Item 1" value="item1" menuKey="aaa" menuItem="bbb" />
      		<rich:menuItem label="Item 2" action="#{menuController.menuItemClicked}" rendered="#{menuController.isMenuItemAccessible( 'aaa', 'bbb' )}">
      			<f:param name="selectedItem" value="item2" />
      		</rich:menuItem>
      		<rich:menuGroup label="Group">
      			<xxx:menuItem label="Item 3" value="item3" menuKey="aaa" menuItem="bbb" />
      		</rich:menuGroup>
                  </rich:dropDownMenu>
              </rich:toolbar>
      		
      </ui:composition>
      

      On a side not: just found out, that the problem might come from the rich:dropDownMenu only allowing for direct children of type rich:menuGroup or rich:menuItem, while a composite component always adds another UIPanel to wrap itself. So if I understand the concept correctly, one would have to write a custom component class that is a menu item and also implements NamingContainer and add it as 'componentType' to the interface. Kinda beats the purpose of being able to easily create an extended markup for components that are expected as direct children though.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  michpetrov Michal Petrov
                  Reporter:
                  michaelb80 Michael B
                • Votes:
                  2 Vote for this issue
                  Watchers:
                  5 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: