JSF menuitem actionListener工作不正常
这是我菜单项的代码:JSF menuitem actionListener工作不正常,jsf,primefaces,Jsf,Primefaces,这是我菜单项的代码: <p:menuitem value="Listar ocorrências" url="/ocorrencia/listaOcorrencia.xhtml" actionListener="#{ocorrenciaBean.buscarTodas()}" ajax="false"/> 它应该从我的数据库返回所有ocorrecias(DAO工作正常),但它没有调用该方法。actionListener需要javax.faces.event中的ActionEven
<p:menuitem value="Listar ocorrências" url="/ocorrencia/listaOcorrencia.xhtml" actionListener="#{ocorrenciaBean.buscarTodas()}" ajax="false"/>
它应该从我的数据库返回所有
ocorrecias
(DAO工作正常),但它没有调用该方法。actionListener
需要javax.faces.event
中的ActionEvent
作为方法参数(除非您使用参数化方法覆盖它)。由于您似乎要导航到不同的URL,action
比actionListener
更合适,您可能需要相应地替换它。@Tiny这是必须的吗?它是not@Tiny它起作用了。谢谢如果你想要a+1,请填写答案。
public String buscarTodas(){
try {
ocorrencias = ocorrenciaService.buscarOcorrencias(null);
} catch (Exception e) {
e.printStackTrace();
}
return "ocorrencia/listaOcorrencia.xhtml";
}