/**
 * 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
 *
 */
package olstore.form;

import java.util.ArrayList;

import olstore.dto.OrderEntry;
//import org.apache.struts.action.ActionForm;
//import olstore.util.WebUtils;

public class UpdateOrderStatusForm extends DemoBaseForm {
    
    private String submitType= null;
    private ArrayList orders = new ArrayList() ;
    private String numOrders = "0" ;
    
    
    /**
     * This autoincrements the size of the vector, so will not return null
     * . This is necessary as the struts auto-populater expects
     * non-null to be retured, and we don't know how many it will
     * request.
     * TODO: CAN LIKELY NOW CHANGE THIS TO NOT HAVE TO RETURN
     * A CUMBERSOME ARRAY
     */
    public OrderEntry getOrderEntry (int index) {
        if ( index >= orders.size() ) {
            int size = orders.size();
            for ( int i =0; i < (index-size) + 1 ; i++ ) {
                orders.add ( new OrderEntry() );
            }
        }
        return (OrderEntry) orders.get ( index );
    }
    
    public void setOrderEntry ( int index, OrderEntry order ) {
        orders.set ( index, order );
    }
    
    public void reset(){
        orders.clear() ;
        submitType=null ;	
        numOrders = "0" ;
    }
    
    public String getSubmitType(){
        return submitType;
        
    }
    
    public void setSubmitType(String submitType){
        this.submitType = submitType;
        
    }
    
    public String getNumOrders(){
        if(orders.size()==0){
            return numOrders;
        }else{
            numOrders = Integer.toString(orders.size());
            return numOrders;	
        }
        
        
    } 
    
    
    public void setNumOrders(String numOrders){
        this.numOrders = numOrders  ;
    }
    
    /**
     * Returns a reference to the internal Properties, use wisely
     */
    public ArrayList getOrders( ) {
        //if(orders.size() < Integer.parseInt(numOrders))
        //	getOrderEntry(Integer.parseInt(numOrders) - 1);
        return orders;
    }
    
    public void setOrders ( ArrayList orders ) {
        this.orders = orders;
    }
    
    
}
