Reputation: 625
Question (short version)
I have an issue with richfaces(4.3.2-final).
I'm trying to rerender a row/cells inside a rich:extendedDataTable. I can't get it to work.
The only thing that works is to rerender the whole table.
All examples/tutorials i can find are for version 3.3. Those solutions dont work for me.
I hope you can help me with a solution or a 4.2+ example/tutorial.
Long version of the question
Not selected row cells:
<a4j:outputPanel layout="block" rendered="#{inactive}">
<h:outputText
value="#{cc.attrs.rowItem.getValue(cc.attrs.id)}"
styleClass="outputField"
style="#{cc.attrs.style}">
</h:outputText>
</a4j:outputPanel>
Selected Row cells:
<a4j:outputPanel layout="block" rendered="#{active and field.echoed}">
<h:inputText
value="#{field.value}"
id="#{cc.attrs.id}ID"
disabled="#{field.disabled}"
readonly="#{field.readonly}"
rendered="true"
title="#{field.title}"/>
....
</a4j:outputPanel>
On selection of other rows:
<a4j:ajax event="selectionchange"
listener="#{crudBean.actionForm.selectionListener}"
render="messages,saveButton,deleteButton,multiOccurenceTable"
/>
HTML code, not selected row cell:
<td class="rf-edt-td-j_idt230">
<div class="rf-edt-c rf-edt-c-j_idt230">
<div class="rf-edt-c-cnt">
<div id="multiOccurenceTable:0:soort:soort">
<div id="multiOccurenceTable:0:soort:j_idt140">
<span class=" outputField" style="">VO</span>
</div>
</div>
</div>
</div>
</td>
Selected row cell HTML:
<td class="rf-edt-td-j_idt230">
<div class="rf-edt-c rf-edt-c-j_idt230">
<div class="rf-edt-c-cnt">
<div id="multiOccurenceTable:1:soort:soort">
<div id="multiOccurenceTable:1:soort:j_idt240">
<input id="multiOccurenceTable:1:soort:soortID" name="multiOccurenceTable:1:soort:soortID" value="VO" type="text">
</div>
</div>
</div>
</div>
</td>
My attempts: The on selectionchange rerender is now put on the table:"multiOccurenceTable". This works, on every selection change the whole table gets rerendered.
For performance i try to update the table on row or cell level. I can't get get this to work. I tried simple and more complex solutions, none worked. What am i doing wrong? (most examples/tutorials are for richfaces 3.3 on the internet which could be a reason)
Try 1, manually updating the rows/cells:
all 3 rows: nothing happened when i pressed the 'save' button
<a4j:commandLink actionListener="#{crudBean.actionForm.save}"
render="multiOccurenceTable:0,multiOccurenceTable:1,multiOccurenceTable:2"
reRender="multiOccurenceTable:0,multiOccurenceTable:1,multiOccurenceTable:2">Save
</a4j:commandLink>
One cell: nothing happened when i pressed the 'save1' button
<a4j:commandLink actionListener="#{crudBean.actionForm.save}"
render="multiOccurenceTable:@rows(crudBean.actionForm.rowsToUpdate):soort"
reRender="multiOccurenceTable:@rows(crudBean.actionForm.rowsToUpdate):soort">Save1
</a4j:commandLink>
I've also tried with ajaxKeys with no succes according to this tutorial rich 3.x and this example (rich 3.3)
If you got any possible solutions, please let me know.
My error is fixed. The error was not the rendering. but that the condition for rendering was set outside the component that was rendered. This resulted in rerendering the component with not updated values, which led to no change on the screen.
Lessons learned: If you have render conditions make sure the condition values are inside the rerendered component.
Upvotes: 1
Views: 722
Reputation: 316
I'm not familiar enough with richfaces 4 to know the details of the extendedDatatable. A quick search led me to believe that it is not possible to automagically render a row since a row isn't a component.
So you seems to be stuck having to render the individual cells.
Rendering works based on the clientId's of the components. You can find the exact ID's in your html code. Because it works on those clientId's the component you want to render already needs to be rendered.
In other words, you need to wrap your components with a panel that has an id and is rendered per default:
<h:outputPanel layout="block" id="soortPanel">
<h:outputText
value="#{cc.attrs.rowItem.getValue(cc.attrs.id)}"
rendered="#{inactive}">
</h:outputText>
<h:inputText
value="#{field.value}"
rendered="#{active}"/>
</h:outputPanel>
The outputpanel should get an id like: multiOccurenceTable:1:soortPanel and you should be able to render that id.
Upvotes: 2