Search code examples
javajsfservletsjsf-2

JSF javax.servlet.ServletException: Method not found: class entity


I would like to know how to call this function anystock from my entity consumable.java and use it on xhtml.

 public String anystock(int value) {
    String result = null;


    if (value==0)
    {
        result="Please fill the stock of this device";
    }
    else  if (value<5)
    {
        result="The stock will be empty ";
    }

    return result;
}

Xhtml:

            </p:column>
                <p:column headerText="message" >
                    <h:outputText value="#{consumable.anystock(consumable.stock)}"/>
            </p:column>

This here works fine and I also receive some information:

            <p:column headerText="stock" sortBy="#{consumable.stock}"   filterBy="#{consumable.stock}">
                <h:outputText value="#{consumable.stock}"/>
            </p:column>

The error code:

javax.servlet.ServletException: Method not found: class entity.Consumable.anystock(java.lang.Integer)

Thank you for you answer

EDIT::

Thanks for the solution prashant


Solution

  • instead of taking int as an argument try taking Integer as an argument...Class of primitive int resolves to int.class and not Integer.class.