1

我正在尝试从表中删除对象,但是当我单击“删除”按钮时,什么也没有发生,它应该调用将删除这个特定对象的方法。MethodNotFoundException 出现,我不知道为什么。这是一个代码:

.xhtml:

                <p:column headerText="Imię">
                    <h:outputText value="#{client.firstName}" />
                </p:column>
                <p:column headerText="Nazwisko">
                    <h:outputText value="#{client.lastName}" />
                </p:column>

                <p:column>                  
                    <p:commandLink type="submit" value="Usuń"
                    style="font-size: 11px"
                        update="searcher:table:clientsTable" 
                        ajax="true"
                        actionListener="#{clientBean.deleteClient(client)}"
                        styleClass="btn btn-danger resized-font delete-btn"
                        icon="glyphicon glyphicon-trash">
                        <span class="glyphicon glyphicon-trash"></span>                                     
                    </p:commandLink>


                    <a href="klienci/#{client.ID}"
                    style="font-size: 11px"
                        class="btn btn-primary resized-font"><span
                        class="glyphicon glyphicon-book"></span> Informacje</a>

                </p:column>
            </p:dataTable>
        </h:form>

来自 ClientBean 的方法:

public void deleteClient(Client client){
    clientDao.delete(client);
}

例外:

SEVERE: javax.el.MethodNotFoundException: Method not found: com.firanycrm.controller.ClientBean@14b77a2a.deleteClient(com.firanycrm.model.Client)
4

1 回答 1

0

您不需要将p:commandLink类型添加到submit,并尝试添加 process="@this"到您的p:commandLink

<p:commandLink value="Delete" 
               update="table" 
               actionListener="#{clientBean.deleteClient(client)}" 
               process="@this" />
于 2016-09-11T08:06:47.973 回答