Skip to content

Commit

Permalink
#486 clear the clientId cache before rendering a new row
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanrauh committed Aug 13, 2016
1 parent 7fdb859 commit 3d8e4e1
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -218,7 +219,7 @@ private void generateBody(FacesContext context, DataTable dataTable, ResponseWri
rw.writeText(value, null);
}

column.encodeChildren(context);
renderChildrenOfColumn(column, context);
rw.endElement("td");
}
rw.endElement("tr");
Expand All @@ -227,7 +228,27 @@ private void generateBody(FacesContext context, DataTable dataTable, ResponseWri
rw.endElement("tbody");
dataTable.setRowIndex(-1);
}

private void renderChildrenOfColumn(UIComponent column, FacesContext context) throws IOException {
resetClientIdCacheRecursively(column);
column.encodeChildren(context);
}

private void resetClientIdCacheRecursively(UIComponent c) {
String id=c.getId();
if (null != id) {
c.setId(id); // this strange operation clears the cache of the clientId
}
Iterator<UIComponent> children = c.getFacetsAndChildren();
if (children != null) {
while (children.hasNext()) {
UIComponent kid = children.next();
resetClientIdCacheRecursively(kid);
}
}
}


private void generateHeader(FacesContext context, DataTable dataTable, ResponseWriter rw) throws IOException {
rw.startElement("thead", dataTable);
rw.startElement("tr", dataTable);
Expand Down

0 comments on commit 3d8e4e1

Please sign in to comment.