a4j:repeat - Dynamically appending a new element

自闭症网瘾萝莉.ら 提交于 2019-12-24 13:52:17

问题


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.

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.

What I would like to do afterward is move the new element from the hidden div to it's correct position using jQuery.

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).

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 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?


回答1:


I've had a similar problem some time ago. I tried tried and was not able to make it work.

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.



来源:https://stackoverflow.com/questions/4753274/a4jrepeat-dynamically-appending-a-new-element

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!