<%-- 
/**
  * 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
  *
  */
--%>
<%@ page contentType="text/html"
         import="olstore.util.WebUtils"
         import="olstore.entity.UserLocal"
         import="olstore.entity.UserLocalHome"
	 	 import="olstore.framework.EJBHomeFactory"
         import="java.util.Collection"
%>

    <% request.setAttribute ( "page_title", "Items I've marked as interesting" ); %>
    <jsp:include page="../nav/Header.jsp" />

    <!-- Content begins here -->
    <div id="form">

<%
    EJBHomeFactory factory=EJBHomeFactory.getInstance();
    UserLocalHome userHome = (UserLocalHome)factory.getLocalHome (EJBHomeFactory.USER);
    UserLocal user = userHome.findByUsername ( request.getRemoteUser() );

    String template = "ItemThumbView.jsp";

    String view = WebUtils.getValue ( "view", request );
    if ( ! WebUtils.isEmpty ( view ) ) {
        if ( view.equals( "List" ) ) {
            template = "ItemListView.jsp";
        } else if ( view.equals ( "Thumbnails" ) ) {
            template = "ItemThumbView.jsp";
        } else if ( view.equals ( "Detailed" ) ) {
            template = "ItemDetailedView.jsp";
        }
    } else {
        template = "ItemThumbView.jsp";
        view = "Thumbnails";
    }
%>
    <div class="formHeader"> Your favourite / purchased items </div>
    <form name="viewForm" action="MyItems.do" method="get">
        <select name="view" onChange="this.form.submit()" >
            <option value="List" <%= view.equals( "List" ) ? "selected" : "" %> >List
            <option value="Thumbnails" <%= view.equals( "Thumbnails" ) ? "selected" : "" %> >Thumbnails
            <option value="Detailed" <%= view.equals( "Detailed" ) ? "selected" : "" %> >Detailed
        </select>
    </form>

<%    
    Collection purchased = user.getPurchased ();
    
    if ( ! purchased.isEmpty() ) {
        request.setAttribute ( "collection", purchased );
        request.setAttribute ( "template", template );
%>
        <jsp:include page="ListCollection.jsp" />
<%
    } else {
%>
        <div class="error"> You have no favourite items selected </div>
<%
    }
%>
    
    <!-- This is necessary to force the parent to expand and include floating divs -->
    <br style="clear:both">
</div>
    <jsp:include page="../nav/Footer.jsp" />
