KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > taglibs > standard > examples > taglib > UsCustomerTag


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.taglibs.standard.examples.taglib;
18
19 import javax.servlet.jsp.JspException JavaDoc;
20 import javax.servlet.jsp.JspTagException JavaDoc;
21 import javax.servlet.jsp.jstl.core.ConditionalTagSupport;
22
23 import org.apache.taglibs.standard.examples.beans.Customer;
24
25 /**
26  * <p>Tag handler for &lt;usCustomer&gt;
27  *
28  * @author Pierre Delisle
29  * @version $Revision: 1.3 $ $Date: 2004/02/28 01:01:41 $
30  */

31 public class UsCustomerTag extends ConditionalTagSupport {
32     
33     //*********************************************************************
34
// Instance Variables
35

36     /** Holds value of property customer. */
37     private Customer customer;
38     
39     //*********************************************************************
40
// Constructor and lusCustomerecycle management
41

42     public UsCustomerTag() {
43         super();
44         init();
45     }
46     
47     private void init() {
48         customer = null;
49     }
50     
51     //*********************************************************************
52
// TagSupport methods
53

54     public void release() {
55         super.release();
56         init();
57     }
58     
59     //*********************************************************************
60
// ConditionalTagSupport methods
61

62     protected boolean condition() throws JspTagException JavaDoc {
63         try {
64             if (customer == null) {
65                 throw new NullAttributeException("usCustomer", "test");
66             } else {
67                 //System.out.println("country: " + customer.getAddress().getCountry());
68
return (customer.getAddress().getCountry().equalsIgnoreCase("USA"));
69             }
70         } catch (JspException JavaDoc ex) {
71             throw new JspTagException JavaDoc(ex.toString());
72         }
73     }
74     
75     //*********************************************************************
76
// Accessors
77

78     /**
79      * Getter for property customer.
80      * @return Value of property customer.
81      */

82     public Customer getCustomer() {
83         return customer;
84     }
85     
86     /**
87      * Setter for property customer.
88      * @param customer New value of property customer.
89      */

90     public void setCustomer(Customer customer) {
91         this.customer = customer;
92     }
93 }
94
Popular Tags