• Post Reply Bookmark Topic Watch Topic
  • New Topic

MethodNotFoundException  RSS feed

 
ammalu pillai
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have been trying on a small sample on JSF. I used datatable with the binding attribute.Eventhough the submit button ie.Delete which is inside the datatable is working fine when i click on a button outside the datatable ie AddItem ..it throws an exception saying "javax.faces.el.MethodNotFoundException"

Attaching the sample here.Please HELP

<f:view>
<h:dataTable value="#{login.item}"
var="items" border="3" binding="#{item}" >
<h:column>
<f:facet name="header">
<f:verbatim>Id</f:verbatim>
</f:facet>
<h:commandButton value="Delete"
action="#{items.deleteItem}" />
</h:column>

<h:column>
<f:facet name="header">
<f:verbatim>Name</f:verbatim>
</f:facet>
<hutputText value="#{items.name} " />
</h:column>
</h:dataTable>

<h:commandButton action="#{item.addNewItem}" value="Additem!"/>

</h:form>
</f:view>

Following is the exception:

com.sun.faces.lifecycle.InvokeApplicationPhase execute
SEVERE: #{item.addNewItem}: javax.faces.el.MethodNotFoundException: addNewItem: javax.faces.component.html.HtmlDataTable.addNewItem()
javax.faces.FacesException: #{item.addNewItem}: javax.faces.el.MethodNotFoundException: addNewItem: javax.faces.component.html.HtmlDataTable.addNewItem()
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:74)
at javax.faces.component.UICommand.broadcast(UICommand.java:312)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
at java.lang.Thread.run(Thread.java:619)
Caused by: javax.faces.el.MethodNotFoundException: addNewItem: javax.faces.component.html.HtmlDataTable.addNewItem()
at com.sun.faces.el.MethodBindingImpl.method(MethodBindingImpl.java:206)
at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:124)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)


Please help me out !
 
Amir Iqbal
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ammalu.

i found following line in your code snipet.



just replace action="#{item.addNewItem}" with action="#{items.addNewItem}"
probably it will work.

if this solutions works please reply back
Regards
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by ammalu pillai:
Caused by: javax.faces.el.MethodNotFoundException: addNewItem: javax.faces.component.html.HtmlDataTable.addNewItem()


Isn't that self-explaining enough? That method simply doesn't exist. How did you come up to it? It isn't stated anywhere in its API document.
http://java.sun.com/javaee/5/docs/api/javax/faces/component/html/HtmlDataTable.html
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Amir Iqbal:
Hi Ammalu.

i found following line in your code snipet.



just replace action="#{item.addNewItem}" with action="#{items.addNewItem}"
probably it will work.

if this solutions works please reply back
Regards

It won't work. That method doesn't even exist in javax.faces.model.DataModel or java.util.List or java.util.Map or whatever datamodel he is using as datatable's value.
 
ammalu pillai
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the reply.. yes..it doesnt work that way. but what confuses me is the following line of code <h:commandButton action="#{item.addNewItem}" value="Additem!"/> is after my datatable..ie. after the datatable tag closes, and also addNewItem is a method in my item bean.and since my commandbutton is outside the datatable why is it still lookin in "javax.faces.component.html.HtmlDataTable" ?
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to the value of the binding attribute of your h:dataTable, the #{item} is just a HtmlDataTable, not a managed bean or so.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!