当我点击导航栏中的某个项目时如何重定向到另一个页面
我使用来自 primefaces 的名为 dock 的导航工具。当我单击其中一个项目时,我需要重定向到另一个页面。 问题是我需要找到 url 属性的替代方法,这是因为如果我使用它,页面会被重定向,并且 action 属性不会调用应该调用的方法。
这就是我的导航栏的样子:
<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 技巧或类似的东西我可以用来在点击时重定向吗?
I use a navigation tool called dock, from primefaces. I need to redirect to another page when i click on one of the items.
The problem is that i need to find an alternative to the url attribute, this is because if i use it, the page gets redirected and the action attribute don't makes a call to the method is supposed to call.
This is how my nav bar looks like:
<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>
This is the backing bean that is called to do the logout. It works good the only problem is that i don't get redirected.
@ManagedBean
@RequestScoped
public class SecurityController {
@EJB
private IAuthentificationEJB authentificationEJB;
public String logOut() {
authentificationEJB.releaseUserState();
return "main.xhtml";
}
...
As you see i tried to return an String form the backing bean method, but doesn't work.
Could you help me find the way to redirect when i click on the p:menuItem?
Do you know maybe some javascript trick or something similar i can use to get redirected when i click?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
Use