View Javadoc

1   package org.paneris.jammyjoes.mvp;
2   
3   import java.util.LinkedList;
4   import java.util.List;
5   
6   import org.melati.poem.NoSuchRowPoemException;
7   import org.melati.poem.Selectable;
8   
9   public class ProductSelectionFromContext implements Selection {
10  
11    Selectable _selectable;
12    Context _context;
13    
14    public ProductSelectionFromContext(Selectable selectable, Context context) {
15      _selectable = selectable;
16      _context = context;
17    }
18  
19    public void visitEach(Command command) {
20      List selected = new LinkedList();
21      for (int i = 0; i < 8; i++) {
22        Integer id =  (Integer)_context.get(new IntegerConverter(), i + "");
23        if (id != null) {
24          try {
25            selected.add(_selectable.getObject(id));
26          } catch (NoSuchRowPoemException e) {
27          }
28        }
29      }
30      new VisitableCollectionAdaptor(selected).visitEach(command);
31    }
32  
33  }