从支持bean重新加载页面 [英] Reload page from backing bean

查看:89
本文介绍了从支持bean重新加载页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的代码中,我在左框架中展开treeNode,该树节点是通过右框架中存在的导航链接选择的.它可以工作,但是每次我单击右框架上的链接时,都必须手动刷新右框架.我试图使用javascript代码从支持bean重新加载页面,但是它不起作用.谁能帮我弄清楚为什么它没有得到执行.

In my code, I'm expanding treeNode in left frame that is selected through navigation links present in right frame. It works but everytime I click the link on right frame, I have to refresh the right frame manually. I tried to reload the page from backing bean using javascript code but it's not working. Can anyone please help me to figure out why it's not getting executed.

预先感谢您的帮助.

下面是我正在使用的代码.

Below is the code I'm using.

public void expandTreeView( TreeNode selectedNode )
{
    if ( selectedNode != null )
    {
        selectedNode.getParent().setExpanded( true );

    }
    RequestContext rc = RequestContext.getCurrentInstance();
    rc.execute("window.location.reload(true)");

}

推荐答案

您需要将JS函数与remoteCommand结合使用,它看起来像这样:

You need to combine a JS Function with remoteCommand, it will look like this :

myHTML.xhtml

myHTML.xhtml

<p:commandLink id="commandLink" onclick="myFunction(nodeSelected)"  >
...
</p:commandLink>   

还添加JS函数

<script type="text/javascript">
   function myFunction(x) {                                
       ...                                
    }    
</script>

,最后将其与p:remoteCommand结合使用,它允许您从JS函数调用managedBean方法

and finally combine it with a p:remoteCommand it allows you to call a managedBean method from your JS function

您可以查看 Primefaces remoteCommand示例或直接看一下因此,发布通过a调用ap:remoteCommand JavaScript函数通过不完整"处理程序将该函数本地的消息传递给另一个函数

You can see Primefaces remoteCommand Example or simply look to this SO post Invoking a p:remoteCommand via a JavaScript function passing a message local to that function to another function through the "oncomplete" handler

希望对您有帮助.

这篇关于从支持bean重新加载页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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