[
https://issues.jboss.org/browse/RF-12845?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12765421#comment-12765421
]
Michael B commented on RF-12845:
--------------------------------
Brian,
thanks for your suggestion. I made several attempts, but couldn't get it to
work.
Using "org.richfaces.component.UIMenuItem" as "componentType" is not accepted,
since that's not the actual component type (produces "Named Object:
org.richfaces.component.UIMenuItem not found.") - the right one should be
"org.richfaces.MenuItem" - I suppose...
So I've tried with this setting:
{code:xml}
<composite:interface componentType="org.richfaces.MenuItem">
<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>
{code}
And using it like that:
{code:xml}
<xxx:menuItem menuKey="aaa" menuItem="bbb" label="TestLabel" value="TestValue"
/>
{code}
However that produces an error when calling the page: "The following
attribute(s) are required, but no values have been supplied for them: value,
label.". If I add another composite-attribute like "xyz" and assign a value to
it, that works - also for the other custom attributes that are defined. So I
don't know what's the special handling for "label" and "value".
Just to test it I also set the attributes to optional and hard-coded "label"
and "value". That renders the page without error, but also without the menu
item...
> rich:menuItem does not work as composite component
> --------------------------------------------------
>
> Key: RF-12845
> URL: https://issues.jboss.org/browse/RF-12845
> Project: RichFaces
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: component-menu
> Affects Versions: 4.3.1
> Environment: Win7 x64, Java 6 x64, Tomcat 7.0.30 x64, RF 4.3.1, IE8 +
> FF19.0.2
> Reporter: Michael B
> Priority: Minor
> Labels: richfaces, waiting_on_user
>
> 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.
> {code:xml|title:menuItem.xhtml}
> <?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>
> {code}
> Including the resulting composite component in a rich:dropDownMenu like
> {code:xml}
> <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>
> {code}
> ... 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:
> {code:xml}
> <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>
> {code}
> 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.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
_______________________________________________
richfaces-issues mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/richfaces-issues