MethodNotFoundException for dynamically created component

UI Components for JSF
Post Reply
suneetha
Posts: 8
Joined: 13 Jan 2011, 05:22

21 Jan 2011, 07:29

Hi
I have created menuItem component and tried to create Action Listener object and setting it to the component in the backing bean.
but it is throwing methodnot found exception.

javax.el.MethodNotFoundException: Method not found: com.mkyong.common.BreadCrumbBean@4786a2.test()
javax.faces.el.MethodNotFoundException: javax.el.MethodNotFoundException: Method not found: com.mkyong.common.BreadCrumbBean@4786a2.test()
at com.sun.faces.application.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:92)

Below is my code..
MenuItem item1 = new MenuItem();
item1.setValue(key);
Application app = FacesContext.getCurrentInstance().getApplication();
javax.faces.el.MethodBinding actionListener = app.createMethodBinding("#{breadCrumbBean.test}", null);
item1.setActionListener(actionListener);

Let me know whether i created actionListener object or not.

Thanks

kylt
Posts: 9
Joined: 04 Feb 2011, 16:13

10 Feb 2011, 12:34

Hi suneetha,
well, I don't like this sentence. But I was facing exactly same problem.
You have to specify the ActionEvent in your second parameter

Code: Select all

menuItem.setActionListener(context.getApplication().createMethodBinding("#{testBean.actionListenerMethod}",
				    		new Class[] {ActionEvent.class}));
----------------------------------------------------------------------------------------------------------
Furthermore I ve got a question:
Due to the fact that setActionListener is deprecated, could anyone tell me how to declare an actionListener via Expression or is this not possible?

Code: Select all

 menuItem.setActionExpression(expressionFactory.createMethodExpression(
				    		el, "#{testBean.changePartner(javax.faces.event.ActionEvent)}",
				    		null, new Class[] {ActionEvent.class}));
In this case my ActionEvent Parameter is null during runtime.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Majestic-12 [Bot] and 45 guests