I have a code, which when I try to access(through a JSF datatable, with a commandButton) it gives me the following error:
The error I am getting is:
javax.el.MethodNotFoundException: /page.xhtml @66,93 action="#{example.addToCart(p)}": Method not found: class managedbean.example.addToCart(javax.faces.model.ResultSetDataModel$ResultSetMap)
Here is the xhtml code for the datatable.
<h:dataTable value="#{example.info}" var="p" summary="Product list" border="0" cellpadding="2" cellspacing="0" rowClasses="" rules="all" style="border:solid 1px" class="tablef table container">
<h:column>
<f:facet name="header">
<h:outputText value="Product name"/>
</f:facet>
<h:outputText value="#{p.itemName}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Product Description"/>
</f:facet>
<h:outputText value="#{p.itemDesc}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Product Price"/>
</f:facet>
<h:outputText value="#{p.price}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Add To Cart"/>
</f:facet>
<h:commandButton action="#{example.addToCart(p)}" value="Add Item"/>
</h:column>
</h:dataTable>
Here is the java code that is meant to be accessed and print to console.
public void addToCart(HashMap product) {
System.out.println("This is a test: " + product.entrySet());
}
The original data being passed into the datatable is a ResultSet(this is what variable p is). I get a very similar error message when using ResultSet as the param type instead of HashMap.
I have tried different paramater types, the only one that has worked is an object, which im not sure how to then use in order to access the key:values.
I expected it to take the information and then print it to console.
The result is an error that is displayed above.