Maybe this can give you some ideas ...
package org.agritrace.action.production;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.agritrace.action.BaseEntityListController;
import org.agritrace.action.stakeholder.StakeholderHome;
import org.agritrace.model.production.Production;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Transactional;
@Name("productionListController")
public class ProductionListController extends BaseEntityListController<Production> {
private static final long serialVersionUID = 1L;
@In(create = true)
private ProductionHome productionHome;
@In
private StakeholderHome stakeholderHome;
private Production newProduction = new Production();
public List<Production> getEntityList() {
return stakeholderHome.getInstance().getProductions();
}
public List<Production> getResultList() {
ArrayList<Production> list = new ArrayList<Production>(getEntityList());
list.add(newProduction);
return list;
}
@Transactional
public String update() {
if (!newProduction.isEmpty()) {
stakeholderHome.getInstance().getProductions().add(newProduction);
newProduction.setStakeholder(stakeholderHome.getInstance());
}
processDiscontinuities(getEntityList());
String outcome = stakeholderHome.update();
stakeholderHome.refresh();
newProduction = new Production();
return outcome;
}
@Transactional
public String remove() {
String outcome = null;
List<Production> productionList = stakeholderHome.getInstance().getProductions();
for (Iterator<Production> i = productionList.iterator(); i.hasNext();) {
Production production = i.next();
if (production.isSelected()) {
i.remove();
productionHome.setInstance(production);
productionHome.remove();
}
}
return outcome;
}
}
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j"
template="/intranet/stakeholder/StakeholderTabs.xhtml">
<ui:define name="ProductionList">
<div id="stakeholderProductions">
<h:form id="listForm">
<rich:dataTable id="entityList"
value="#{productionListController.resultList}"
var="production"
onRowMouseOver="this.style.backgroundColor='#{a4jSkin.additionalBackgroundColor}'"
onRowMouseOut="this.style.backgroundColor=''"
rowClasses="rvgRowOne,rvgRowTwo"
columnClasses="tblSmallCols,tblCols,tblCols,tblSmallCols">
<a4j:support event="onRowDblClick" action="#{productionListController.onRowDblClick(production)}" reRender="entityList,commonFramesDiv" limitToList="false" ajaxsingle="true" />
<!--
<rich:column width="50px" >
<f:facet name="header">id</f:facet>
<h:outputText value="#{production.id}"/>
</rich:column>
-->
<rich:column styleClass="#{production.selected ? 'selected' : 'normal'}">
<f:facet name="header">#{messages['org.agritrace.ProductionType']}<span class="required">*</span></f:facet>
<s:decorate template="/layout/editTd.xhtml">
<h:selectOneMenu id="productionTypeSelect" value="#{production.type}" required="true"
converter="#{org.agritrace.productionTypeConverter}"
label="#{messages['org.agritrace.ProductionType']}" >
<s:selectItems value="#{productionTypeList.resultList}" var="productionType"
label="#{messages[productionType.resourceKey]}"
noSelectionLabel="#{messages['org.agritrace.PleaseSelect']}" hideNoSelectionLabel="true" />
</h:selectOneMenu>
</s:decorate>
</rich:column>
<rich:column styleClass="#{production.selected ? 'selected' : 'normal'}">
<f:facet name="header">#{messages['org.agritrace.Species']}<span class="required">*</span></f:facet>
<s:decorate template="/layout/editTd.xhtml">
<h:selectOneMenu id="speciesSelect" value="#{production.species}" required="true"
converter="org.agritrace.speciesConverter"
label="#{messages['org.agritrace.productionSpecies']}">
<s:selectItems value="#{speciesList.resultList}" var="species"
label="#{messages[species.resourceKey]}"
noSelectionLabel="#{production.isEmpty()?messages['org.agritrace.PleaseSelect']:null}" />
</h:selectOneMenu>
</s:decorate>
</rich:column>
</rich:dataTable>
<br />
<ui:include src="/intranet/common/list/ActionButtons.xhtml" >
<ui:param name="controller" value="#{productionListController}" />
</ui:include>
</h:form>
</div>
<br/>
<s:div id="commonFramesDiv">
<ui:include src="/intranet/common/commonFrames/TabPanel.xhtml" />
</s:div>
</ui:define>
</ui:composition>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich" >
<div class="actionButtons">
<h:commandButton id="update" value="#{messages['org.agritrace.Save']}" action="#{controller.update}" />
<h:commandButton id="delete" value="#{messages['org.agritrace.Delete']}" action="#{controller.remove}" />
</div>
</ui:composition>
<?xml version="1.0" encoding="UTF-8"?>
<page xmlns="http://jboss.com/products/seam/pages"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.0.xsd"
no-conversation-view-id="/intranet/ProductionList.seam"
login-required="false">
<begin-conversation flush-mode="MANUAL" join="true"/>
<action execute="#{stakeholderHome.wire}" />
<action execute="#{productionListController.wire}" />
<param name="stakeholderId" value="#{stakeholderHome.stakeholderId}" />
</page>