1 package net.sf.imca.taglibs;
2
3 import javax.servlet.jsp.JspException;
4 import javax.servlet.jsp.JspTagException;
5
6 import net.sf.imca.model.AssociationBO;
7 import net.sf.imca.model.entities.AssociationEntity;
8 import net.sf.imca.services.CommitteeService;
9
10
11 public class Fleets extends javax.servlet.jsp.tagext.TagSupport {
12
13
14
15
16
17 private static final long serialVersionUID = 8944804977828774091L;
18
19 private boolean isOfficial = true;
20
21 int count = 0;
22
23
24 AssociationBO[] asssociations;
25
26 public int doStartTag() throws JspException {
27
28 CommitteeService service = new CommitteeService();
29
30 asssociations = service.getAssociations(isOfficial);
31 count = 0;
32
33 if ( asssociations.length > 0 ) {
34 setPageAttributes();
35 return EVAL_BODY_INCLUDE;
36 } else {
37 return SKIP_BODY;
38 }
39 }
40
41 public int doAfterBody() throws JspTagException {
42
43
44 count++;
45 if (count < asssociations.length) {
46 setPageAttributes();
47 return EVAL_BODY_AGAIN;
48 } else {
49 return SKIP_BODY;
50 }
51 }
52
53 private void setPageAttributes() {
54
55 pageContext.setAttribute("countryCode", asssociations[count].getEntity().getIsoCountryCode());
56 pageContext.setAttribute("name", asssociations[count].getName());
57
58 }
59
60 public boolean getIsOfficial() {
61 return isOfficial;
62 }
63
64 public void setIsOfficial(boolean isOfficial) {
65 this.isOfficial = isOfficial;
66 }
67
68 }