-
1. Re: seam-excel not working with a map?
nickarls Nov 17, 2008 9:06 PM (in response to wachtda.scsi.gmx.ch)Hmm, looks like the documentation is ahead of the code. Not sure which one should be edited ;-) Daniel (Roth), any comments? Could UIWorksheet.unwrapIterator use a Map.entrySet or something like that?
-
2. Re: seam-excel not working with a map?
danielc.roth Nov 17, 2008 9:44 PM (in response to wachtda.scsi.gmx.ch)Map should be removed from the documentation. The reason is that if we have a map as
input
to a table, what values should we use? map.values(), map.keySet() or map.entrySet()?The correct way would be to do something like:
public List<DeviceInteger> mkExcelExport() { List<DeviceInteger> ret = new LinkedList<DeviceInteger>(); calcAvailabilityMonth(); ret.addAll(c_DevicesAvavailabilityMonth); return ret; } public class DeviceInteger { private Device device; private integer integer; // getter, setters, constructor }
-
3. Re: seam-excel not working with a map?
nickarls Nov 17, 2008 10:38 PM (in response to wachtda.scsi.gmx.ch)Actually, I think it's sort of doable, I tried adding to UIWorksheet.unwrapIterator a
else if (value instanceof Map) { return ((Map) value).entrySet().iterator(); }
and added a test method that returned
public Map<String, String> getFoo() { Map foo = new HashMap<String, String>(); foo.put("a", "1"); foo.put("b", "2"); foo.put("c", "3"); return foo; }
and xhtml
<e:workbook xmlns:e="http://jboss.com/products/seam/excel" xmlns:f="http://java.sun.com/jsf/core"> <e:worksheet value="#{excelTest.foo}" var="data"> <e:column> <e:cell value="#{data.value}"/> </e:column> </e:worksheet> </e:workbook>
and I actually got an excel but it looked like
2 3 1
which is quite natural, since Maps don't guarantee iteration order. Which renders the Map usecase, well, useless in most cases. Or?
-
4. Re: seam-excel not working with a map?
wachtda.scsi.gmx.ch Nov 18, 2008 8:59 AM (in response to wachtda.scsi.gmx.ch)Thank you for taking your time on this!
For me, it would be very useful if the worksheet would have the same behavior like a dataTable...
(It's the same useCase, I have a Collection which I'd like to display in rows and columns:For example to iterate a map:
<h:dataTable id="test" var="map" value="#{myHashMap}"> <h:column> <f:facet name="header"> <h:outputText value="My Header 1" /> </f:facet> #{map.key.name} </h:column> <h:column> <f:facet name="header"> <h:outputText value="My Header 2" /> </f:facet> #{map.value.serialNumber} </h:column> </h:dataTable>
In case of the iteration order of a map, I always use the LinkedHashmap or Treemap to have a ordered Map,
so this should be possible?!Greetings
Daniel -
5. Re: seam-excel not working with a map?
nickarls Nov 18, 2008 11:29 AM (in response to wachtda.scsi.gmx.ch)I committed the Map-fix.