0 Replies Latest reply on Jun 19, 2008 8:24 PM by Julien Chouinard

    Delete List without EJBs

    Julien Chouinard Newbie

              I’m trying to do something like in the addAllToCart in « dvdstore » example, but without EJBs. It’s a list with check box and a command button to delete checked items. I’ve done a factory that generate the list and place it in the user session, and I’m retrieving it with Context.getSessionContext(). The thing is that the list stays empty. Anyone can help?

           @Factory(value="deleteProjectList", scope=ScopeType.SESSION)
           public Map<Project, Boolean> getDeleteProjectList()
                if (deleteProjectList == null) 
                     log.info("Setting delete List in session scope");
                     deleteProjectList = new HashMap<Project, Boolean>();
                return deleteProjectList;

           public void deleteAllCheck()
                deleteProjectList = (Map<Project,Boolean>) Contexts.getSessionContext().get("deleteProjectList");
                if (deleteProjectList != null)
                     log.info("Delete list : " + deleteProjectList.size());
                     for(Project project : getResultList())
                          Boolean selected = deleteProjectList.get(project);
                          if(selected != null && selected)
                               deleteProjectList.put(project, false);
                               log.info("Delete " + project.getName());
                } else
                     log.info("null deleteList");

      <rich:column >
      <f:facet name="header"><h:outputText value="Delete"></h:outputText></f:facet>
      <h:selectBooleanCheckbox value="#deleteProjectList[project]}">

      <s:button value="#{messages['Delete']}" action="#{projectList.deleteAllCheck}"></s:button>