Hi,all..
I'm implementing multi-select rowdatas using checkox, just like browse.xhtml in seam-dvd does. I put the persistence logic in Query, it works and save some @In operations. but i'am wondering whether it is a suitable to do that. Or anyone has a better solution?thx.
<rich:dataTable id="holeList" var="hole" value="#{holeList.resultList}" rendered="#{not empty holeList.resultList}"> <h:column> <f:facet name="header">CheckBox</f:facet> <h:selectBooleanCheckbox value="#{holeSelections[hole]}" /> </h:column> .......
@Name("holeList") public class HoleList extends EntityQuery { @In FacesMessages facesMessages; @Out(scope=ScopeType.EVENT, required = false) Map<Hole, Boolean> holeSelections; @Factory("holeSelections") public void init(){ holeSelections = new HashMap<Hole, Boolean>(); } .......... public void deleteSelected(){ EntityManager em = this.getEntityManager(); List<Hole> resultList = this.getResultList(); for (Hole item : resultList) { Boolean selected = holeSelections.get(item); if (selected != null && selected) { holeSelections.put(item, false); em.remove(item); } } this.refresh(); facesMessages.add("delAction delete called"); } }
Hi
I've done the same thing myself, except I didn't outject it but kept it in the backing bean.
No need to iterate over the result list is there ? You have all the selected Hole's in the holeSelections.keySet() don't you?
Cheers,
micke