Dynamic columns howto, my solution is to slow
mail.micke Sep 10, 2007 11:03 AMHi all
I'm wondering about your solutions of using dynamic columns with richfaces datatable, my implementation is to slow.
From my experience tomahawk columns isn't that great to work with, what do you think.
This is what I did.
- Cookie with info about if a column should be rendered or not, data accessed via the ColumnManager
- Using Seam enhanced EL on the rendered attribute of rich:column
I think this way of doing this is quite neat, if only it wasn't so slow.
All that usage of EL seems to take way to much CPU resources to process, when displaying a table with about 100 rows it takes about 6 seconds in the render response phase, while an exact copy without the conditional column rendering renders immediately.
The code inside the columnManager.doRenderColumn(..) looks up information in a cached Map (parsed from a cookie string), so it should be quick.
If you have time please have a look and see if what I did makes sense; is it crazy, can it be optimized or are there alternative better solutions.
<rich:dataTable id="posListingTable" value="#{sdb.positions}" var="item"> <f:facet name="header"> <rich:columnGroup> <rich:column rendered="#{columnManager.doRenderColumn(sdb.expType,'cpb')}"> CP Branch <a4j:commandLink reRender="posListingTable,reEnableColumnForm" value="x" action="#{columnManager.toggleRendering(sdb.expType,'cpb')}"/> </rich:column> <rich:column rendered="#{columnManager.doRenderColumn(sdb.expType,'cpty')}"> Cpty Code <h:commandLink value="x" action="#{columnManager.toggleRendering(sdb.expType,'cpty')}"/> </rich:column> <rich:column rendered="#{columnManager.doRenderColumn(sdb.expType,'cagrid')}"> Coll agr. id <h:commandLink value="x" action="#{columnManager.toggleRendering(sdb.expType,'cagrid')}"/> </rich:column> <rich:column rendered="#{columnManager.doRenderColumn(sdb.expType,'lpc')}"> Limex Pos Code <h:commandLink value="x" action="#{columnManager.toggleRendering(sdb.expType,'lpc')}"/> </rich:column> <rich:column rendered="#{columnManager.doRenderColumn(sdb.expType,'ihi')}"> IHI Key <h:commandLink value="x" action="#{columnManager.toggleRendering(sdb.expType,'ihi')}"/> </rich:column> <rich:column rendered="#{columnManager.doRenderColumn(sdb.expType,'md')}"> Maturity Date <h:commandLink value="x" action="#{columnManager.toggleRendering(sdb.expType,'md')}"/> </rich:column> <rich:column rendered="#{columnManager.doRenderColumn(sdb.expType,'pt')}"> Product Type <h:commandLink value="x" action="#{columnManager.toggleRendering(sdb.expType,'pt')}"/> </rich:column> <rich:column rendered="#{columnManager.doRenderColumn(sdb.expType,'pgi')}"> Position Group Id <h:commandLink value="x" action="#{columnManager.toggleRendering(sdb.expType,'pgi')}"/> </rich:column> <ui:include src="#{sdb.additionalHeadersViewId}"/> </rich:columnGroup> </f:facet> <rich:column rendered="#{columnManager.doRenderColumn(sdb.expType,'cpb')}"> #{item.positionData.placeCodeBookingCpty} </rich:column> <rich:column rendered="#{columnManager.doRenderColumn(sdb.expType,'cpty')}"> #{item.positionData.codeCpty} </rich:column> <rich:column rendered="#{columnManager.doRenderColumn(sdb.expType,'cagrid')}"> #{item.positionData.collateralAgreementId} </rich:column> <rich:column rendered="#{columnManager.doRenderColumn(sdb.expType,'lpc')}"> #{item.positionData.positionCodeLimex} </rich:column> <rich:column rendered="#{columnManager.doRenderColumn(sdb.expType,'ihi')}"> #{item.positionData.internalHierarchyKey} </rich:column> <rich:column rendered="#{columnManager.doRenderColumn(sdb.expType,'md')}"> <h:outputText value="#{item.positionData.maturityDate}"> <f:convertDateTime pattern="dd/MM/yyyy"/> </h:outputText> </rich:column> <rich:column rendered="#{columnManager.doRenderColumn(sdb.expType,'pt')}"> #{item.positionData.productTypeCode} </rich:column> <rich:column rendered="#{columnManager.doRenderColumn(sdb.expType,'pgi')}"> #{item.positionData.positionGroupId} </rich:column> <ui:include src="#{sdb.additionalColumnValuesViewId}"/> </rich:dataTable>
Cheers,
Mike