p:commandLink不会重定向到新页面吗? [英] p:commandLink won't redirect to new page?

查看:161
本文介绍了p:commandLink不会重定向到新页面吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JSF2和GlassFish,PrimeFaces 2.1.

I'm using JSF2 and GlassFish, PrimeFaces 2.1.

此方法有效,showCreateProfile()方法被命中,该方法返回"profileForm",浏览器重定向到该页面:

This works, showCreateProfile() method gets hit, and the method returns "profileForm" and the browser redirects to that page:

<h:commandLink action="#{profileHandler.showCreateProfile}" value="#{msg.menu_createNewProfile}" />

但是,这不起作用,showCreateProfile()方法被命中,并且该方法返回"profileForm",但浏览器未重定向到页面.我没有运气就尝试了三种不同的方法:

However, this doesn't work, showCreateProfile() method get hits, and the method returns "profileForm" but the browser does not redirect to the page. I tried three different things with no luck:

<p:commandLink action="#{profileHandler.showCreateProfile}" value="#{msg.menu_createNewProfile}" />

<p:commandLink action="#{profileHandler.showCreateProfile}" value="#{msg.menu_createNewProfile}" ajax="false" />

<p:commandLink action="#{profileHandler.showCreateProfile}" value="#{msg.menu_createNewProfile}" ajax="false" immediate="true"/>

有什么想法我在做什么错吗?

Any ideas what I'm doing wrong?

推荐答案

Primefaces的p:commandLink默认情况下会触发ajax请求.它不会返回完整的HTTP响应,而仅返回必须由JS在HTML DOM树中更新的部分HTTP响应.

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.

您基本上有两种选择:

  1. 通过ajax="false"属性禁用Ajax.然后它将触发正常的HTTP请求.

  1. 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的操作方法也已执行,因此这仅意味着您在尝试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.

这篇关于p:commandLink不会重定向到新页面吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆