Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: nectar/template/blocks/UserLinksBlockView.java


1   /*
2       Copyright (C) 2003  Kai Schutte
3    
4       This program is free software; you can redistribute it and/or modify
5       it under the terms of the GNU General Public License as published by
6       the Free Software Foundation; either version 2 of the License, or
7       (at your option) any later version.
8    
9       This program is distributed in the hope that it will be useful,
10      but WITHOUT ANY WARRANTY; without even the implied warranty of
11      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12      GNU General Public License for more details.
13   
14      You should have received a copy of the GNU General Public License
15      along with this program; if not, write to the Free Software
16      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17   
18   * UserLinksBlockView.java
19   *
20   * Created on March 30, 2003, 4:18 PM
21   */
22  
23  package nectar.template.blocks;
24  
25  import nectar.view.PersonView;
26  import org.apache.struts.action.ActionForm;
27  import javax.servlet.http.HttpServletRequest;
28  import javax.servlet.http.HttpSession;
29  import nectar.ServicesUtil;
30  import nectar.record.PersonRecord;
31  import nectar.data.DataException;
32  /**
33   *
34   * @author  Kai Schutte skander@skander.com
35   */
36  public class UserLinksBlockView extends BlockView {
37      PersonView user = null;
38      /** Creates a new instance of UserLinksBlockView */
39      public UserLinksBlockView() {
40      }
41      
42      public void init() throws DataException {
43          HttpSession session = request.getSession(false);
44          if (session != null) {
45              Object userID = session.getAttribute("User");
46              PersonRecord userRecord = null;
47              if (userID != null) {
48                  userRecord = ServicesUtil.getRecordService().getPerson(project, (Long)userID);
49              }
50              if (userRecord != null)
51                  this.user = new PersonView(userRecord);
52          }
53      }
54      
55      public boolean isLoggedIn() { if (user == null) return false; return true; }
56      public void setLoggedIn(boolean b) { }
57      public PersonView getView() { return user; }
58      public void setView(PersonView s){ user = s; }
59  }