myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Spiegl (JIRA)" <...@myfaces.apache.org>
Subject [jira] Resolved: (MYFACES-697) Non-standard behaviour of t:navigationMenuItem (in t:jscookMenu) breaks facelets
Date Wed, 02 Nov 2005 16:24:56 GMT
     [ http://issues.apache.org/jira/browse/MYFACES-697?page=all ]
     
Thomas Spiegl resolved MYFACES-697:
-----------------------------------

    Fix Version: Nightly
     Resolution: Fixed

fixed: itemValue="0" no longer necessary
fixed: action of navigationMenuItem is now recognized as methodbinding

> Non-standard behaviour of t:navigationMenuItem (in t:jscookMenu) breaks facelets
> --------------------------------------------------------------------------------
>
>          Key: MYFACES-697
>          URL: http://issues.apache.org/jira/browse/MYFACES-697
>      Project: MyFaces
>         Type: Bug
>   Components: Tomahawk
>     Reporter: Erik-Berndt Scheper
>     Assignee: Thomas Spiegl
>      Fix For: Nightly

>
> Non-standard behaviour of t:navigationMenuItem (in t:jscookMenu) breaks facelets in two
ways:
> Consider the following menu:
>     	<t:jscookMenu layout="hbr" theme="ThemeOffice" >
>     	    <!-- Hoofdmenu ==> link naar startscherm (home) -->
>         	<t:navigationMenuItem id="nav_home" 
>         			itemLabel="#{msg['label.menu.home']}" 
>         			action="home" />
>     	    <t:navigationMenuItem id="nav_medewerker" itemLabel="#{msg['label.menu.medewerkers']}"
>
> 	            <t:navigationMenuItem id="nav_mw_toev" 
>             		itemLabel="#{msg['label.menu.medewerkers.toevoegen']}"
> 	            	action="#{medewerkerToevoegenHandler.initializeHandlerAction}" />
>             	<t:navigationMenuItem id="nav_mw_wijzig" 
>             		itemLabel="#{msg['label.menu.medewerkers.wijzigen']}"
> 	            	action="#{medewerkerWijzigenHandler.initializeHandlerAction}"/>
>         	</t:navigationMenuItem>
>     	</t:jscookMenu>
> This leads to the following exception in facelets
> An Error Occurred:
> value
> +- Stack Trace
> java.lang.NullPointerException: value
> 	at javax.faces.model.SelectItem.<init>(SelectItem.java:69)
> 	at org.apache.myfaces.custom.navmenu.NavigationMenuItem.<init>(NavigationMenuItem.java:50)
> 	at org.apache.myfaces.custom.navmenu.NavigationMenuItem.<init>(NavigationMenuItem.java:65)
> 	at org.apache.myfaces.custom.navmenu.NavigationMenuUtils.getNavigationMenuItemList(NavigationMenuUtils.java:63)
> 	at org.apache.myfaces.custom.navmenu.jscookmenu.HtmlJSCookMenuRenderer.encodeChildren(HtmlJSCookMenuRenderer.java:120)
> 	at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:319)
> 	at org.apache.myfaces.renderkit.RendererUtils.renderChild(RendererUtils.java:444)
> 	at org.apache.myfaces.renderkit.html.HtmlGridRendererBase.renderChildren(HtmlGridRendererBase.java:203)
> 	at org.apache.myfaces.renderkit.html.HtmlGridRendererBase.encodeEnd(HtmlGridRendererBase.java:85)
> The reason is non standard behaviour in class org.apache.myfaces.custom.navmenu.HtmlNavigationMenuItemTag.java.
> The setProperties() method in this class sets itemValue to "0". In method getNavigationMenuItemList()
of org.apache.myfaces.custom.navmenu.NavigationMenuUtils this property (itemValue) is used
as the value property of a newly created instance  of NavigationMenuItem (which extends SelectItem).
> However, in facelets the setProperties() method is never used, (all supported properties
of the tag are set indivually) and the itemValue is null when the new instance of NavigationMenuItem
is created. This leads to a nullpointer exception in the constructor of SelectItem (called
by the constructor of NavigationMenuItem)
> Others have been reporting the same problem. See http://www.mail-archive.com/users@myfaces.apache.org/msg09857.html
> The easy fix is to add a property itemValue="0" to all navigationmenuitem tags. I.e.
>     	<t:jscookMenu layout="hbr" theme="ThemeOffice" >
>     	    <!-- Hoofdmenu ==> link naar startscherm (home) -->
>         	<t:navigationMenuItem id="nav_home" 
>         			itemLabel="#{msg['label.menu.home']}" itemValue="0" 
>         			action="home" />
>     	    <!-- Hoofdmenu ==>  submenu: Medewerkers -->
>     	    <t:navigationMenuItem id="nav_medewerker" itemLabel="#{msg['label.menu.medewerkers']}"
itemValue="0">
> 	            <t:navigationMenuItem id="nav_mw_toev" 
>             		itemLabel="#{msg['label.menu.medewerkers.toevoegen']}" itemValue="0"
> 	            	action="#{medewerkerToevoegenHandler.initializeHandlerAction}" />
>             	<t:navigationMenuItem id="nav_mw_wijzig" 
>             		itemLabel="#{msg['label.menu.medewerkers.wijzigen']}" itemValue="0"
> 	            	action="#{medewerkerWijzigenHandler.initializeHandlerAction}"/>
>         	</t:navigationMenuItem>
>     	</t:jscookMenu>
> This fixes the nullpointer exception, but leads to a new stack trace in facelets:
> An Error Occurred:
> /pages/layout/menu.jsp @28,80 action="#{medewerkerToevoegenHandler.initializeHandlerAction}":
Bean: nl.ibgroep.demo.web.handler.medewerker.MedewerkerToevoegenHandler, property: initializeHandlerAction
> +- Stack Trace
> javax.faces.el.PropertyNotFoundException: /pages/layout/menu.jsp @28,80 action="#{medewerkerToevoegenHandler.initializeHandlerAction}":
Bean: nl.ibgroep.demo.web.handler.medewerker.MedewerkerToevoegenHandler, property: initializeHandlerAction
> 	at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:58)
> 	at org.apache.myfaces.custom.navmenu.UINavigationMenuItem.getAction(UINavigationMenuItem.java:89)
> 	at org.apache.myfaces.custom.navmenu.NavigationMenuUtils.getNavigationMenuItemList(NavigationMenuUtils.java:63)
> 	at org.apache.myfaces.custom.navmenu.NavigationMenuUtils.getNavigationMenuItemList(NavigationMenuUtils.java:75)
> 	at org.apache.myfaces.custom.navmenu.jscookmenu.HtmlJSCookMenuRenderer.encodeChildren(HtmlJSCookMenuRenderer.java:120)
> The reason is obvious: the action property of a navigationMenuItem is not recognized
as a methodbinding. Because NavigationMenuItem is not assignable from ActionSource, the action
property is assumed to be a JavaBean property. I.e. the renderer calls getInitializeHandlerAction()
to render the view! Whereas I would like the initializeHandlerAction() method to be called
when the menuitem is selected...
> I have no workaround for this. The only solution seems to be the use of hardcoded actions
such as specified below.
>     	<t:jscookMenu layout="hbr" theme="ThemeOffice" >
>     	    <!-- Hoofdmenu ==> link naar startscherm (home) -->
>         	<t:navigationMenuItem id="nav_home" 
>         			itemLabel="#{msg['label.menu.home']}" itemValue="0" 
>         			action="home" />
>     	    <!-- Hoofdmenu ==>  submenu: Medewerkers -->
>     	    <t:navigationMenuItem id="nav_medewerker" itemLabel="#{msg['label.menu.medewerkers']}"
itemValue="0">
> 	            <t:navigationMenuItem id="nav_mw_toev" 
>             		itemLabel="#{msg['label.menu.medewerkers.toevoegen']}" itemValue="0"
> 	            	action="medewerkerToevoegen" />
>             	<t:navigationMenuItem id="nav_mw_wijzig" 
>             		itemLabel="#{msg['label.menu.medewerkers.wijzigen']}" itemValue="0"
> 	            	action="medewerkerWijzigen"/>
>         	</t:navigationMenuItem>
>     	</t:jscookMenu>

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message