JSF2的RichFaces 4.1.0阿贾克斯部分树的渲染 [英] JSF2 Richfaces 4.1.0 Ajax partial rendering of tree

查看:133
本文介绍了JSF2的RichFaces 4.1.0阿贾克斯部分树的渲染的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个大的树结构(近6000节点和不断增长的),我在我的web应用程序作为一个RichFaces的丰富显示:树

当一个节点被选择的处理功能的支持bean运行的一些逻辑和工作的一些魔法。

有一件事情发生的是,树重新呈现与树中的每一个选择一个Ajax调用。这意味着,超过2MB每次被发送到服务器选择更改。

正如你可能已经猜到我这里的问题是,这是非常缓慢的。我想这样做只是有选择重新渲染,而不是整个树,因为这将有希望只是张贴了几个KB到服务器的树节点。

这是JSF2.0中使用RichFaces的4.1.0所以我GOOGLE了像疯了解决方案,并通过在RichFaces的现场的文档清理,但还没有找到一个解决方案,我的第一个真正的项目。

我的code是这样的:

 < H:格式ID =主>
< A4J:outputPanel ajaxRendered =真正的>
<丰富:面板ID =TreePanel中标题=树>
<丰富的:树ID =theTreeVAR =树值=#{treeBean.rootNodes}selectionType =AJAXtoggleType =客户端selectionChangeListener =#{treeBean.selectionChanged}>
<丰富:treeNode的>
< H:的outputText的styleClass =#{tree.selected的SelectedNode':'?'}值=#{tree.title}/>
< /富:treeNode的>
< /富:树>
< /富:面板>
< / A4J:outputPanel>
< /小时:形式GT;
 

解决方案

大的反应,因为你是你的输出面板上设置AjaxRendered =真。这基本上是告诉RichFaces的更新整个面板和每一个AJAX请求是否与您的树中的所有内容。你可能想删除。

I have a big tree structure (almost 6000 nodes and growing) that I display in my webapp as a Richfaces rich:tree.

When a node is selected a handler-function in the backing-bean runs some logic and works some magic.

One thing that happens is that the tree is re-rendered with an Ajax-call on every selection in the tree. This means that over 2MB is POSTed to the server every time the selection changes.

As you might guess my problem here is that this is very slow. What I would like to do is only have the tree-node that was selected re-rendered and not the entire tree since this would hopefully just POST a couple of KB to the server.

This is my first real project in JSF2.0 using RichFaces 4.1.0 so I've googled like crazy for a solution and scavenged through the documentation on the RichFaces-site but have yet to find a solution.

My code looks like this:

<h:form id="main">
<a4j:outputPanel ajaxRendered="true">
<rich:panel id="treePanel" header="Tree">
<rich:tree id="theTree" var="tree" value="#{treeBean.rootNodes}" selectionType="ajax" toggleType="client" selectionChangeListener="#{treeBean.selectionChanged}">
<rich:treeNode>
<h:outputText styleClass="#{tree.selected?'selectedNode':''}" value="#{tree.title}" />
</rich:treeNode>
</rich:tree>
</rich:panel>
</a4j:outputPanel>
</h:form>

解决方案

The large response is because you are setting AjaxRendered = "true" on your output panel. This is basically telling richfaces to update the whole panel and all its contents on every ajax request whether or not related to your tree. You might want to remove that.

这篇关于JSF2的RichFaces 4.1.0阿贾克斯部分树的渲染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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