You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2017/06/15 13:23:13 UTC
incubator-juneau git commit: Improve ordering of columns in bean
tables in HtmlSerializer.
Repository: incubator-juneau
Updated Branches:
refs/heads/master 609f80226 -> 0d10af30f
Improve ordering of columns in bean tables in HtmlSerializer.
Currently, the ordering is messed up if the first row has null values.
Project: http://git-wip-us.apache.org/repos/asf/incubator-juneau/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-juneau/commit/0d10af30
Tree: http://git-wip-us.apache.org/repos/asf/incubator-juneau/tree/0d10af30
Diff: http://git-wip-us.apache.org/repos/asf/incubator-juneau/diff/0d10af30
Branch: refs/heads/master
Commit: 0d10af30f0b8ca36cfe718e00838d5944af37a45
Parents: 609f802
Author: JamesBognar <ja...@apache.org>
Authored: Thu Jun 15 09:23:11 2017 -0400
Committer: JamesBognar <ja...@apache.org>
Committed: Thu Jun 15 09:23:11 2017 -0400
----------------------------------------------------------------------
.../java/org/apache/juneau/html/HtmlSerializer.java | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/0d10af30/juneau-core/src/main/java/org/apache/juneau/html/HtmlSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/html/HtmlSerializer.java b/juneau-core/src/main/java/org/apache/juneau/html/HtmlSerializer.java
index 8d9d087..f227456 100644
--- a/juneau-core/src/main/java/org/apache/juneau/html/HtmlSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/html/HtmlSerializer.java
@@ -645,19 +645,25 @@ public class HtmlSerializer extends XmlSerializer {
}
th = set.toArray(new Object[set.size()]);
} else {
- Set<Object> set = new LinkedHashSet<Object>();
+ Map<String,Boolean> m = new LinkedHashMap<String,Boolean>();
for (Object o : c) {
if (! session.canIgnoreValue(cm, null, o)) {
if (! cm.isInstance(o))
return null;
BeanMap<?> bm = (o instanceof BeanMap ? (BeanMap)o : session.toBeanMap(o));
for (Map.Entry<String,Object> e : bm.entrySet()) {
+ String key = e.getKey();
if (e.getValue() != null)
- set.add(e.getKey());
+ m.put(key, true);
+ else if (! m.containsKey(key))
+ m.put(key, false);
}
}
}
- th = set.toArray(new Object[set.size()]);
+ for (Iterator<Boolean> i = m.values().iterator(); i.hasNext();)
+ if (! i.next())
+ i.remove();
+ th = m.keySet().toArray(new Object[m.size()]);
}
prevC.add(cm);
boolean isSortable = true;