KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > olstore > form > UpdateOrderStatusForm


1 /**
2  * Copyright (c) 2004 Red Hat, Inc. All rights reserved.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or any later version.
8  *
9  * This library 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 GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17  * USA
18  *
19  * Component of: Red Hat Application Server
20  *
21  * Initial Developers: Aizaz Ahmed
22  * Vivek Lakshmanan
23  * Andrew Overholt
24  * Matthew Wringe
25  *
26  */

27 package olstore.form;
28
29 import java.util.ArrayList;
30
31 import olstore.dto.OrderEntry;
32 //import org.apache.struts.action.ActionForm;
33
//import olstore.util.WebUtils;
34

35 public class UpdateOrderStatusForm extends DemoBaseForm {
36     
37     private String submitType= null;
38     private ArrayList orders = new ArrayList() ;
39     private String numOrders = "0" ;
40     
41     
42     /**
43      * This autoincrements the size of the vector, so will not return null
44      * . This is necessary as the struts auto-populater expects
45      * non-null to be retured, and we don't know how many it will
46      * request.
47      * TODO: CAN LIKELY NOW CHANGE THIS TO NOT HAVE TO RETURN
48      * A CUMBERSOME ARRAY
49      */

50     public OrderEntry getOrderEntry (int index) {
51         if ( index >= orders.size() ) {
52             int size = orders.size();
53             for ( int i =0; i < (index-size) + 1 ; i++ ) {
54                 orders.add ( new OrderEntry() );
55             }
56         }
57         return (OrderEntry) orders.get ( index );
58     }
59     
60     public void setOrderEntry ( int index, OrderEntry order ) {
61         orders.set ( index, order );
62     }
63     
64     public void reset(){
65         orders.clear() ;
66         submitType=null ;
67         numOrders = "0" ;
68     }
69     
70     public String getSubmitType(){
71         return submitType;
72         
73     }
74     
75     public void setSubmitType(String submitType){
76         this.submitType = submitType;
77         
78     }
79     
80     public String getNumOrders(){
81         if(orders.size()==0){
82             return numOrders;
83         }else{
84             numOrders = Integer.toString(orders.size());
85             return numOrders;
86         }
87         
88         
89     }
90     
91     
92     public void setNumOrders(String numOrders){
93         this.numOrders = numOrders ;
94     }
95     
96     /**
97      * Returns a reference to the internal Properties, use wisely
98      */

99     public ArrayList getOrders( ) {
100         //if(orders.size() < Integer.parseInt(numOrders))
101
// getOrderEntry(Integer.parseInt(numOrders) - 1);
102
return orders;
103     }
104     
105     public void setOrders ( ArrayList orders ) {
106         this.orders = orders;
107     }
108     
109     
110 }
111
Popular Tags