1 16 17 package org.apache.taglibs.standard.examples.taglib; 18 19 import javax.servlet.jsp.JspException ; 20 import javax.servlet.jsp.JspTagException ; 21 import javax.servlet.jsp.jstl.core.ConditionalTagSupport; 22 23 import org.apache.taglibs.standard.examples.beans.Customer; 24 25 31 public class UsCustomerTag extends ConditionalTagSupport { 32 33 36 37 private Customer customer; 38 39 42 public UsCustomerTag() { 43 super(); 44 init(); 45 } 46 47 private void init() { 48 customer = null; 49 } 50 51 54 public void release() { 55 super.release(); 56 init(); 57 } 58 59 62 protected boolean condition() throws JspTagException { 63 try { 64 if (customer == null) { 65 throw new NullAttributeException("usCustomer", "test"); 66 } else { 67 return (customer.getAddress().getCountry().equalsIgnoreCase("USA")); 69 } 70 } catch (JspException ex) { 71 throw new JspTagException (ex.toString()); 72 } 73 } 74 75 78 82 public Customer getCustomer() { 83 return customer; 84 } 85 86 90 public void setCustomer(Customer customer) { 91 this.customer = customer; 92 } 93 } 94 | Popular Tags |