View Javadoc

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.PersonBO;
7   import net.sf.imca.model.entities.PersonEntity;
8   import net.sf.imca.services.EditDataService;
9   import net.sf.imca.services.JoinImcaService;
10  import net.sf.imca.web.backingbeans.Utils;
11  import net.sf.imca.web.backingbeans.WebUser;
12  
13  public class Rider extends javax.servlet.jsp.tagext.TagSupport {
14      
15  
16      /**
17       * Generated serialVersionUID
18       */
19      private static final long serialVersionUID = 8944804977828774091L;
20  
21      private String id = "";
22      
23      public int doStartTag() throws JspException {
24          
25          JoinImcaService joinService = new JoinImcaService();
26          if (! joinService.getActiveMember(Utils.getWebUser().getPerson()) ){
27              return SKIP_BODY;
28          }
29          
30          String ParameterId = this.pageContext.getRequest().getParameter("id");
31          if (ParameterId == null) {
32              return SKIP_BODY;
33          }
34          if (ParameterId.equals("")) {
35              return SKIP_BODY;
36          }
37          Long longId = new Long(ParameterId);
38          
39          EditDataService service = new EditDataService();
40          
41          PersonEntity entity = (PersonEntity)service.findEntity(PersonEntity.class, longId.longValue());
42          
43          if ( entity != null) {
44              PersonBO person = new PersonBO(entity);
45              setPageAttributes(person);
46              return EVAL_BODY_INCLUDE;
47          } else {
48              return SKIP_BODY;
49          }
50      }
51      
52      private void setPageAttributes(PersonBO person ) {
53  
54          pageContext.setAttribute("xmlId", person.getXmlId()); 
55          pageContext.setAttribute("name", person.getName()); 
56          pageContext.setAttribute("url", person.getEntity().getUrl()); 
57          pageContext.setAttribute("street1", person.getEntity().getAddress().getStreet1());
58          pageContext.setAttribute("street2", person.getEntity().getAddress().getStreet2());
59          pageContext.setAttribute("city", person.getEntity().getAddress().getCity());
60          pageContext.setAttribute("postcode", person.getEntity().getAddress().getPostCode());
61          pageContext.setAttribute("country", person.getCountry());
62          pageContext.setAttribute("addressHtml", person.getAddressHtml());
63          pageContext.setAttribute("smallPictureUrl", person.getSmallPictureUrl());
64          
65          String email = person.getEntity().getEmail();
66          int atPos = email.indexOf("@");
67          if (atPos > 0) {
68              pageContext.setAttribute("email_username", email.substring(0, email
69                      .indexOf("@")));
70              pageContext.setAttribute("email_domain", email.substring(email
71                      .indexOf("@") + 1));
72          } else {
73              pageContext.setAttribute("email_username", "");
74              pageContext.setAttribute("email_domain", "");
75          }
76          
77          pageContext.setAttribute("tel", person.getEntity().getTel());
78          pageContext.setAttribute("mobile", person.getEntity().getMobile());
79          pageContext.setAttribute("club", person.getEntity().getClub());
80          
81          person.getEntity().getAddress().getCountryCode();
82          pageContext.setAttribute("countryCode", person.getEntity().getAddress().getCountryCode()); 
83        
84      }
85  
86  }