a4j:repeat-动态附加新元素 [英] a4j:repeat - Dynamically appending a new element
问题描述
我正在尝试实现(作为较大系统的一部分)用户可以发布消息的功能.当用户单击发布按钮时,我正在使用RichFaces和a4j使用ajax检索生成的发布.
I'm trying to implement (as part of a larger system) a feature where a user is able to post a message. When the user clicks the post button, I'm using RichFaces and a4j to retrieve the generated post using ajax.
我宁愿在回复返回后也不会自动显示该帖子.相反,我想在一个隐藏的div中添加一个输出面板.当用户单击发布"按钮时,将填充该输出面板,但显然对用户隐藏了该面板.
I'd rather not have the post show up automatically as soon as the response is returned. Rather, I'd like to add an output panel inside a hidden div. When the user clicks on the post button, that output panel will be populated but obviously hidden from the user.
之后我想做的就是使用jQuery将新元素从隐藏的div移到正确的位置.
What I would like to do afterward is move the new element from the hidden div to it's correct position using jQuery.
无论如何,这里的问题是,当对它执行操作时,我正在使用a4j:repeat的ajaxKeys属性来更新单行.例如,如果某人将该行的等级定为5,我只想重新呈现该行(通过在服务器端设置正确的密钥).
Anyway, the issue here is I'm using the ajaxKeys property of a4j:repeat to update a single row when an action is taken against it. For example, if somebody gives the row a rating of 5, I want to rerender only that row (by setting the correct key on the server-side).
如果我使用此方法,则将ajax创建的元素移动到其他帖子之外时,一开始会很好地工作,如果用户对该行进行操作,我不相信a4j:repeat将能够工作并考虑到它本身不会生成.
If I use this method, whilst moving the ajax-created element to be besides the other posts will work fine initially, if a user takes an action against that row, I don't believe a4j:repeat will be able to work with it given that it didn't generate it itself.
这是正确的吗?如果是这样,有没有人可以建议的解决方法?
Is this correct? If so, is there any workarounds anyone can suggest?
Facebook能够实现类似的目标.您可以创建或删除帖子以及对帖子发表评论,并且仅更新该对象.我开始认为a4j:repeat可能不是解决此问题的最佳方法.有想法吗?
Facebook are able to achieve a similar thing. You can create or remove a post as well as comment on a post and only have that object updated. I'm starting to think that a4j:repeat may not be the best way to approach this issue. Thoughts?
推荐答案
我前段时间也遇到过类似的问题.我尝试过尝试,但无法使其正常工作.
I've had a similar problem some time ago. I tried tried and was not able to make it work.
最终,我决定使用javascript和Seam Remoting,这使我可以更好地控制正在发生的事情.我设法使它与该方法一起工作.
Eventually I decided to use javascript and Seam Remoting which allowed me to have more control about what was happening. I managed to make it work with that approach.
这篇关于a4j:repeat-动态附加新元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!