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.i18n; 18 19 import java.io.IOException; 20 21 import java.util.ResourceBundle; 22 23 import javax.servlet.jsp.JspException; 24 import javax.servlet.jsp.PageContext; 25 import javax.servlet.jsp.tagext.BodyTag; 26 import javax.servlet.jsp.tagext.BodyTagSupport; 27 28 29 /** 30 * This class implements body tag that allows you to use a resource bundle 31 * to internationalize content in a web page. If a value is found in the 32 * resource bundle for the required "key" attribute, then the enclosed JSP 33 * is evaluated, otherwise, it is skipped. 34 * <P> 35 * The ifdef and ifndef tags allow the JSP author to conditionally evaluate 36 * sections of a JSP based on whether or not a value is provided for the 37 * given key. 38 * <P> 39 * <H2>Examples</H2> 40 * <PRE> 41 * <i18n:bundle baseName="test"/> 42 * <i18n:ifndef key="test"> 43 * misc html and jsp 44 * </i18n:ifndef> 45 * etc... 46 * </PRE> 47 * <P> 48 * 49 * @author <a HREF="mailto:tdawson@wamnet.com">Tim Dawson</a> 50 * 51 */ 52 public class IfndefTag extends ConditionalTagSupport 53 { 54 55 protected static final String _tagname = "i18n:ifndef"; 56 57 /** 58 * locates the bundle and tests whether the key has a value 59 */ 60 public boolean shouldEvaluate() throws JspException 61 { 62 String value = this.getValue(); 63 if ( value == null || value.length() == 0 ) { 64 return true; 65 } else { 66 return false; 67 } 68 } 69 70 } 71