<%-- 
/**
  * Copyright (c) 2004 Red Hat, Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or any later version.
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  * USA
  *
  * Component of: Red Hat Application Server
  * 
  * Initial Developers: Aizaz Ahmed
  *                     Vivek Lakshmanan
  *                     Andrew Overholt
  *                     Matthew Wringe
  *
  */
--%>
<%-- This page provides a detailed view for Users. It expects the user
object UserLocal to be defined as userToDisplay. This is clumsy ... if necessary
it should be modified so that the user is loaded into the session and the
name of the user is passed to this page --%>

<%@ page contentType="text/html"
	 import="olstore.entity.*"
         import="java.util.Collection"
         import="java.util.Iterator"
	 import="olstore.framework.EJBHomeFactory"%>

<div class="FriendSetView">
<%
    EJBHomeFactory factory = EJBHomeFactory.getInstance();
    UserLocalHome userHome = (UserLocalHome) factory.getLocalHome (EJBHomeFactory.USER);
    UserLocal user = userHome.findByUsername ( "aahmed" );
%>  <h3 class="UserTitle"><%= user.getUsername() %></h3><%

%>

<p> Listing all the users Friends </p>
<%
    try {
	Collection friends = user.getFriends();
        Iterator it = friends.iterator();
        while ( it.hasNext() ) {
           UserLocal friend = ((FriendLocal)it.next()).getUser();
	   %> <p>friend : <%= friend.getUsername() %> <p> <%
        }
    }  catch ( Exception e ) {
        out.println ( "Could not list all Friends: " + e.getMessage() );
    }

%>

</div>
