Commit e37f6eddcd89a3a74f0f260753f2610940683e4e
1 parent
c18b7274
Exists in
master
Melhora do processo de deleção de registros (AbstractListPageBean /
DelegateCrud)
Showing
2 changed files
with
25 additions
and
1 deletions
Show diff stats
impl/core/src/main/java/br/gov/frameworkdemoiselle/template/DelegateCrud.java
@@ -56,6 +56,14 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { | @@ -56,6 +56,14 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { | ||
56 | this.getDelegate().delete(id); | 56 | this.getDelegate().delete(id); |
57 | } | 57 | } |
58 | 58 | ||
59 | + @Transactional | ||
60 | + public void delete(final List<I> idList) { | ||
61 | + ListIterator<I> iter = idList.listIterator(); | ||
62 | + while (iter.hasNext()) { | ||
63 | + this.delete(iter.next()); | ||
64 | + } | ||
65 | + } | ||
66 | + | ||
59 | @Override | 67 | @Override |
60 | public List<T> findAll() { | 68 | public List<T> findAll() { |
61 | return getDelegate().findAll(); | 69 | return getDelegate().findAll(); |
@@ -91,5 +99,5 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { | @@ -91,5 +99,5 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { | ||
91 | public void update(final T bean) { | 99 | public void update(final T bean) { |
92 | getDelegate().update(bean); | 100 | getDelegate().update(bean); |
93 | } | 101 | } |
94 | - | 102 | + |
95 | } | 103 | } |
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/template/AbstractListPageBean.java
@@ -111,6 +111,22 @@ public abstract class AbstractListPageBean<T, I> extends AbstractPageBean implem | @@ -111,6 +111,22 @@ public abstract class AbstractListPageBean<T, I> extends AbstractPageBean implem | ||
111 | this.selection = selection; | 111 | this.selection = selection; |
112 | } | 112 | } |
113 | 113 | ||
114 | + public void clearSelection() { | ||
115 | + this.selection = new HashMap<I, Boolean>(); | ||
116 | + } | ||
117 | + | ||
118 | + public List<I> getSelectedList() { | ||
119 | + List<I> selectedList = new ArrayList<I>(); | ||
120 | + Iterator<I> iter = getSelection().keySet().iterator(); | ||
121 | + while (iter.hasNext()) { | ||
122 | + I id = iter.next(); | ||
123 | + if (getSelection().get(id)) { | ||
124 | + selectedList.add(id); | ||
125 | + } | ||
126 | + } | ||
127 | + return selectedList; | ||
128 | + } | ||
129 | + | ||
114 | public Pagination getPagination() { | 130 | public Pagination getPagination() { |
115 | return paginationContext.getPagination(getBeanClass(), true); | 131 | return paginationContext.getPagination(getBeanClass(), true); |
116 | } | 132 | } |