2011-04-20 108 views
1

我从primefaces使用名为dock的导航工具。当我点击其中一个项目时,我需要重定向到另一个页面。 问题是,我需要找到一个替代的url属性,这是因为如果我使用它,页面获取重定向和操作属性不会调用该方法应该调用。当我点击一个项目时,如何在我的导航栏中重定向到另一个页面

这是我的导航栏看起来像:

<h:form> 
     <p:dock position="top"> 
      <!--Some other menu items ...--> 
      <p:menuitem value="Logout" icon="unsecuredimages/logout.png" action="#{securityController.logOut}" rendered ="#{!securityController.checkLogged}"/>    
     </p:dock> 
</h:form> 

这是支持Bean被称为做注销。它运作良好唯一的问题是,我不会重定向。

@ManagedBean 
@RequestScoped 
public class SecurityController { 

@EJB 
private IAuthentificationEJB authentificationEJB; 

public String logOut() { 
     authentificationEJB.releaseUserState(); 
     return "main.xhtml"; 
    } 
... 

正如你看到我试图返回一个字符串形式的支持bean方法,但不起作用。

当我点击p:menuItem时,你能帮我找到重定向的方法吗?

你知道也许一些JavaScript技巧或类似的东西,我可以使用重定向时,我点击?

回答

4

使用

return "main.xhtml?faces-redirect=true"; 
+0

它的工作!谢谢:) – sfrj 2011-04-20 11:41:05

+0

欢迎:) – 2011-04-20 11:42:21

相关问题