更新时间:2023-11-23 11:22:40
The Primefaces 的 p:commandLink
默认会触发 ajax 请求.它不会返回整个 HTTP 响应,而只会返回部分 HTTP 响应,该响应必须由 JS 在 HTML DOM 树中进行更新.
The Primefaces' p:commandLink
fires by default an ajax request. It does not return a whole HTTP response, but only a partial HTTP response which has got to be updated in HTML DOM tree by JS.
您基本上有两个选择:
通过 ajax="false"
属性禁用 ajax.然后它会触发一个普通的 HTTP 请求.
Disable ajax by ajax="false"
attribute. It'll then fire a normal HTTP request.
通过 update="clientid"
属性更新(重新渲染)部分内容(在同一页面上!).您可以使用 rendered
属性来控制内容的呈现.
Update (re-render) the partial content (on the same page!) by update="clientid"
attribute. You can use rendered
attribute to control the rendering of content.
如果两者都不起作用,那么问题出在其他地方.由于 h:commandLink
起作用并且 p:commandLink
的 action 方法也被执行了,所以它只能意味着你没有运行你认为的代码在尝试 ajax="false"
时运行.验证、保存、重建、重新部署、重新启动.
If neither works, then the problem lies somewhere else. Since the h:commandLink
works and the action method of p:commandLink
also get executed, then it can only mean that you're not running the code you think you're running while trying the ajax="false"
. Verify, save, rebuild, redeploy, restart.