1 Reply Latest reply on Sep 2, 2008 1:01 PM by Mikael Andersson

    Is this a good approach

    Tom Brown Newbie

      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");
           }
      }