You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Only1 <va...@gmail.com> on 2006/06/12 23:55:54 UTC

Strange JSCookMenu Error

Hi,
I am getting the following exception while trying to implement dynamic menu
using myfaces. The error seemed to be strange because in the backing
component ( I am using a seam component), the getter method is called
properly  and  I also confirmed that the object type of returning array is
of type 'org.apache.myfaces.custom.navmenu.NavigationMenuItem'

My backing DynamicMenu component is seam component


java.lang.IllegalArgumentException: Value binding of UINavigationMenuItems
with id dynamicMenus does not reference an Object of type
NavigationMenuItem, Navigat
ionMenuItem[], Collection or Map
        at
org.apache.myfaces.custom.navmenu.NavigationMenuUtils.addNavigationMenuItems(NavigationMenuUtils.java:143)
        at
org.apache.myfaces.custom.navmenu.NavigationMenuUtils.getNavigationMenuItemList(NavigationMenuUtils.java:100)
        at
org.apache.myfaces.custom.navmenu.jscookmenu.HtmlJSCookMenuRenderer.encodeChildren(HtmlJSCookMenuRenderer.java:161)
        at
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:319)
        at
javax.faces.webapp.UIComponentTag.encodeChildren(UIComponentTag.java:343)
--
View this message in context: http://www.nabble.com/Strange-JSCookMenu-Error-t1776830.html#a4837245
Sent from the MyFaces - Users forum at Nabble.com.


Re: Strange JSCookMenu Error

Posted by Only1 <va...@gmail.com>.
Also keeping <h:outputText value="#{dynMenu.navItems}"/>  gave the following
o/p on the screen. So it is not null.

[Lorg.apache.myfaces.custom.navmenu.NavigationMenuItem;@1c95b4c
--
View this message in context: http://www.nabble.com/Strange-JSCookMenu-Error-t1776830.html#a4853782
Sent from the MyFaces - Users forum at Nabble.com.


Re: Strange JSCookMenu Error

Posted by Only1 <va...@gmail.com>.
Probably not. I could see the output of the getter. It is printing "Inside
Getter" in the server console. Means navItems is really the instance of 
org.apache.myfaces.custom.navmenu.NavigationMenuItem

public NavigationMenuItem[] getNavItems() {
    	if(navItems[0] instanceof
org.apache.myfaces.custom.navmenu.NavigationMenuItem){
    		System.out.println("Inside getter "); 			
    	}else{
    		System.out.println("No Match ");
    	}
        return navItems;
    }
--
View this message in context: http://www.nabble.com/Strange-JSCookMenu-Error-t1776830.html#a4852269
Sent from the MyFaces - Users forum at Nabble.com.


Re: Strange JSCookMenu Error

Posted by Bruno Aranda <br...@gmail.com>.
I don't see why it is failing, can you verify that dynMenu.navItems is
not true when the expression is being called? Replace the jsCookMenu
by a outputText like this...

<h:outputText value="#{dynMenu.navItems == true}"/>

as a dirty way to check that... A null value could be provoking that
behaviour maybe...

Bruno

On 6/13/06, Only1 <va...@gmail.com> wrote:
>
> The following is my menu generation code
>
> package org.jboss.seam.example.todo;
>
> import java.util.ArrayList;
> import java.util.List;
>
> import org.apache.myfaces.custom.navmenu.NavigationMenuItem;
> import org.jboss.seam.annotations.Name;
> import org.jboss.seam.annotations.Scope;
> import org.jboss.seam.ScopeType;
>
> @Name ("dynMenu")
> @Scope (ScopeType.APPLICATION)
> public class DynamicMenu {
>         private NavigationMenuItem[] navItems;
>
>         private NavigationMenuItem viewsMenu;
>         private NavigationMenuItem formsMenu;
>
>     public DynamicMenu() {
>         // root items
>         navItems = new NavigationMenuItem[2];
>         viewsMenu= new NavigationMenuItem("Item 1 Label","action1", "iconUrl",
> false);
>         formsMenu= new NavigationMenuItem("Item 3 Label","action3", "iconUrl",
> false);
>         navItems[0] = viewsMenu;
>         navItems[1] = formsMenu;
>
>     }
>
>     public NavigationMenuItem[] getNavItems() {
>         if(navItems[0] instanceof
> org.apache.myfaces.custom.navmenu.NavigationMenuItem){
>                 System.out.println("Inside getter ");
>         }else{
>                 System.out.println("No Match ");
>         }
>         return navItems;
>     }
>
>     public void setNavItems(NavigationMenuItem[] navItems) {
>         this.navItems = navItems;
>     }
>
>         public NavigationMenuItem getFormsMenu() {
>                 System.out.println("Inside getFormsMenu ");
>                 return formsMenu;
>         }
>
>         public void setFormsMenu(NavigationMenuItem formsMenu) {
>                 this.formsMenu = formsMenu;
>         }
>
>         public NavigationMenuItem getViewsMenu() {
>                 System.out.println("Inside getViewsMenu ");
>                 return viewsMenu;
>         }
>
>         public void setViewsMenu(NavigationMenuItem viewsMenu) {
>                 this.viewsMenu = viewsMenu;
>         }
> }
>
> This is my JSP Code. This is included in another page as <f:subview>
>
> <%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
> <%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
>   <font color="#38c940"><strong>P R O C E S S&nbsp;&nbsp;T R A C K I N
> G</strong>
> </font>
> <t:jscookMenu layout="hbr" theme="ThemeOffice">
>                 <t:navigationMenuItems id= "dynamicMenus"
> value="#{dynMenu.navItems}" />
> </t:jscookMenu>
>
>
>
>
> --
> View this message in context: http://www.nabble.com/Strange-JSCookMenu-Error-t1776830.html#a4852003
> Sent from the MyFaces - Users forum at Nabble.com.
>
>

Re: Strange JSCookMenu Error

Posted by Only1 <va...@gmail.com>.
The following is my menu generation code

package org.jboss.seam.example.todo;

import java.util.ArrayList;
import java.util.List;

import org.apache.myfaces.custom.navmenu.NavigationMenuItem;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.ScopeType;

@Name ("dynMenu")
@Scope (ScopeType.APPLICATION)
public class DynamicMenu {
	private NavigationMenuItem[] navItems;
	
	private NavigationMenuItem viewsMenu;
	private NavigationMenuItem formsMenu;

    public DynamicMenu() {
        // root items
    	navItems = new NavigationMenuItem[2];
    	viewsMenu= new NavigationMenuItem("Item 1 Label","action1", "iconUrl",
false);
    	formsMenu= new NavigationMenuItem("Item 3 Label","action3", "iconUrl",
false);
    	navItems[0] = viewsMenu;
    	navItems[1] = formsMenu;
    	
    }
    
    public NavigationMenuItem[] getNavItems() {
    	if(navItems[0] instanceof
org.apache.myfaces.custom.navmenu.NavigationMenuItem){
    		System.out.println("Inside getter "); 			
    	}else{
    		System.out.println("No Match ");
    	}
        return navItems;
    }

    public void setNavItems(NavigationMenuItem[] navItems) {
        this.navItems = navItems;
    }

	public NavigationMenuItem getFormsMenu() {
		System.out.println("Inside getFormsMenu ");
		return formsMenu;
	}

	public void setFormsMenu(NavigationMenuItem formsMenu) {
		this.formsMenu = formsMenu;
	}

	public NavigationMenuItem getViewsMenu() {
		System.out.println("Inside getViewsMenu ");
		return viewsMenu;
	}

	public void setViewsMenu(NavigationMenuItem viewsMenu) {
		this.viewsMenu = viewsMenu;
	}
}

This is my JSP Code. This is included in another page as <f:subview>

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
  <font color="#38c940"><strong>P R O C E S S&nbsp;&nbsp;T R A C K I N
G</strong>
</font>
<t:jscookMenu layout="hbr" theme="ThemeOffice">		
         	<t:navigationMenuItems id= "dynamicMenus"
value="#{dynMenu.navItems}" />         	       	
</t:jscookMenu>




--
View this message in context: http://www.nabble.com/Strange-JSCookMenu-Error-t1776830.html#a4852003
Sent from the MyFaces - Users forum at Nabble.com.


Re: Strange JSCookMenu Error

Posted by Bruno Aranda <br...@gmail.com>.
Are you sure that you are generating the component with
NavigationMenuItem instances? Could you show a snippet of your code?
That would help,

Bruno

On 6/13/06, Only1 <va...@gmail.com> wrote:
>
> Did anybody else got this error? It is very strange. Nobody else in the forum
> seemed to have encountered this error.
>
> Thanks
> Vamsi
> --
> View this message in context: http://www.nabble.com/Strange-JSCookMenu-Error-t1776830.html#a4846629
> Sent from the MyFaces - Users forum at Nabble.com.
>
>

Re: Strange JSCookMenu Error

Posted by Only1 <va...@gmail.com>.
Did anybody else got this error? It is very strange. Nobody else in the forum
seemed to have encountered this error.

Thanks
Vamsi
--
View this message in context: http://www.nabble.com/Strange-JSCookMenu-Error-t1776830.html#a4846629
Sent from the MyFaces - Users forum at Nabble.com.