primefaces ajax within ui:repeat

UI Components for JSF
Post Reply
DRMouse
Posts: 3
Joined: 12 Dec 2011, 21:49

12 Dec 2011, 22:30

I have a var named 'o' in my ui:repeat tag which my primefaces ajax tag is within.

The problem is the following code does not work, alert shows an empty message and the value in the dom inspected with firebug also shows an empty alert message.
<pou:ajax event="click" .. oncomplete="alert('#{o.id}')" />

I tried with immediate evaluation too, e.g. ${o.id}

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

13 Dec 2011, 00:51

Click URL, read the question and the answer, and let us know if this fixes your issue.

http://stackoverflow.com/questions/8077 ... y-added-te

Also, I saw a few other posts when you search google for the following:

forum.primefaces.org ui:repeat
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

DRMouse
Posts: 3
Joined: 12 Dec 2011, 21:49

13 Dec 2011, 19:56

None of these worked, the solution was to keep track of the current object in the backing bean and then get it from there.

To keep track of the current object I both pass the current object (using a setter) to the backing bean immediately after the ui:repeat tag, and also by setting it to the value my data model returns (using 'getRowData()' ) inside any appropriate listener methods specified within the ui:repeat tags.

getRowData() only returns the correct row after a listener is called (and not while iterating over it with ui:repeat - a bug I suppose?) so both methods are necessary.

These workarounds are sort of annoying but at least it works ! :-)

Edit: it's still not working, the getter in my backing bean is only being called once! even though the ajax tag is within the ui:repeat, so should be calling it on each iteration. It's applying the value returned from the call made in the first iteration to the ajax tags on every other iteration.

Edit:

Solved it by putting the javascript inside a <script> tag inside a panelgroup which I added to the list of components for ajax to update. It seems the attributes to specify client callbacks (oncomplete etc) were designed to just be static strings of the function names.

A link for those interested about how ui:repeat is broken:
http://stackoverflow.com/questions/8280 ... orm-submit

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 58 guests