myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "R. Müller" <>
Subject best approach for SelectItems inside a datatables
Date Mon, 05 Dec 2005 08:38:20 GMT
hi group,

it is common usecase for web-application to be able to select items 
(rows) of datatable and choosing desired action from a choice.

to solve this issue, i personally using often the following construct :
(the 'adapter' backing bean serves all necessary data)

<t:dataTable id="myTableData" styleClass="myTableStyle"
	binding="#{adapter.uiData}" headerClass="tableHeader"
	columnClasses="col0,col1, [...]" var="item"
	value="#{adapter.itemList}" 						preserveDataModel="false"
	rowId="#{}" rowIndexVar="idx"
	sortColumn="#{adapter.sort}" //
	<f:facet name="header">
		columnName="id" arrow="false">						<f:facet name="ascending">
			<t:graphicImage value="arrow_down.png" />			</f:facet>
		<f:facet name="descending">
			<t:graphicImage value="arrow_up.png" />				</f:facet>
		<h:outputText value="#{bundle['']}" />
		id="rowSelector" forceId="true" forceIdIndex="false"
		layout="spread" value="select">
	<f:selectItems value="#{adapter.selectItemList}"/>
	<t:radio for="rowSelector" index="#{idx}"></t:radio>
	<h:outputText value="[#{}]" />

But this approach has a big disadvantage : the method 'selectItemList' 
is called in every rendered row  even though the list themself isn't 
change. So if method has to build up a list-object, it takes long time 
to render especially large table.

By the way, there is another thing i want to mentioned here : the 
SelectItem-class, which you have to use, when using 
selection-components. IMHO this has to be a interface, since we are all 
aware of the multiple inheritance issue with java.
Its often the case that the objects, you going display inside the table 
already have their inheritance tree. And it is difficult and timewasting 
to implement method for just serving SelectItem-lists.
Particularly there is 'nothing' to do to implement this interface.

so far, comments appreciate, thank you in advance


View raw message