[英]Use Ajax to update only ui:repeat instead of all form
I have some problem with the rendering of some data in my application. 我在应用程序中呈现某些数据时遇到问题。 To make it simple, I have ah:form that contains a table with a ui:repeat in the tbody. 为简单起见,我有ah:form,其中包含一个表,其中表中带有ui:repeat。 Let's make an exemple (I did not put all code, because it would be far too long) : 让我们举一个例子(我没有放所有代码,因为它太长了):
<h:form id="sequence-assemblage-form">
<ui:fragment>
<table id="table-fils">
<thead>
...
</thead>
<tbody>
<ui:repeat id="fil">
<tr>
many <td> one after another
<ui:fragment>
<td>
<h:panelGroup id="actionsEditing" rendered="">
<h:inputHidden id="filHarnaisId" value="#{fil.id}"/>
<h:commandLink styleClass="icon-20 icon-save" id="save">
<f:ajax execute="@form" render="" listener="doesAnAction"/>
<f:ajax execute="@form" render="@form" listener="doesAnotherAction"/>
<f:ajax execute="@form" render=":integrite-form :message-integrite-panel" onevent="verifierIntegrite"/>
</h:commandLink>
<h:commandLink styleClass="icon-20 icon-rollback" id="rollback" action="">
<f:ajax execute="@this" render="@form" />
</h:commandLink>
</h:panelGroup>
</td>
</ui:fragment>
</tr>
</ui:repeat>
</tbody>
</table>
</ui:fragment>
</h:form>
My problem is that every time I save, it render the form completly, which cause performance problems when my table contains many rows (you know, when a page took like 10 seconds of more to load everytime you save?). 我的问题是,每次保存时,它都会完全渲染表单,这在我的表包含很多行时会导致性能问题(您知道,每次保存页面需要花费10秒以上的时间吗?)。 Is there a way to do so it will only render the row I am currently editing? 有没有办法做到这一点,它将只呈现我当前正在编辑的行?
I do not know if the problem is with the f:ajax execute
or f:ajax render
but I need to figure out where the problem is and find a solution for performance. 我不知道问题出在f:ajax execute
还是f:ajax render
但是我需要弄清楚问题出在哪里,并找到性能解决方案。
Have a nice day Thanks ! 祝你有美好的一天谢谢!
EDIT : I have noticed while trying to find a solution that one of the listeners change a value in my bean and that this value is required to render a script important to trigger the save (see below) 编辑:我在尝试找到一个解决方案时注意到,其中一个侦听器更改了我的bean中的一个值,并且此值对于呈现重要的脚本以触发保存至关重要(请参阅下文)
<h:outputScript rendered="#{fil.modifie}">
showNoticeChangementDialog();
</h:outputScript>
These lines of code are right before the end of my ui:repeat
which means that by updating only the ui:repeat
, it should be triggering the dialog if my value has been modified ? 这行代码是我结束前右ui:repeat
这意味着通过仅更新了ui:repeat
,应触发的对话框,如果我的价值已被修改?
I tried to change both the render
and execute
with the id of my ui:repeat
but it was not working. 我试图更改render
并使用ui:repeat
的ID execute
,但无法正常工作。
I managed to find a workaround with the help of a colleague and this particular answer . 我设法在同事的帮助下找到了解决方法,并找到了这个特别的答案 。
Had to wrap the content of every <td>
within a h:panelGroup
and give them a unique id. 必须将每个<td>
的内容包装在h:panelGroup
并为其赋予唯一的ID。 I could then use the render
on every element to make sure they have been updated. 然后,我可以在每个元素上使用render
,以确保它们已被更新。
It looks like this : <f:ajax render="id1 id2 id3 id4 ..."
看起来像这样: <f:ajax render="id1 id2 id3 id4 ..."
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.