KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ofbiz > webapp > taglib > EntityFieldTag


1 /*
2  * $Id: EntityFieldTag.java 5462 2005-08-05 18:35:48Z jonesde $
3  *
4  * Copyright (c) 2001-2003 The Open For Business Project - www.ofbiz.org
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
21  * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
22  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  *
24  */

25 package org.ofbiz.webapp.taglib;
26
27 import java.io.IOException JavaDoc;
28 import javax.servlet.jsp.JspException JavaDoc;
29 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
30
31 import org.ofbiz.base.util.Debug;
32 import org.ofbiz.base.util.UtilJ2eeCompat;
33 import org.ofbiz.webapp.pseudotag.EntityField;
34 import org.ofbiz.entity.GenericEntityException;
35
36 /**
37  * EntityFieldTag - Tag to Print Localized Entity Fields.
38  *
39  * @author <a HREF="mailto:jaz@ofbiz.org">Andy Zeneski</a>
40  * @author <a HREF="mailto:jonesde@ofbiz.org">David E. Jones</a>
41  * @version $Rev: 5462 $
42  * @since 2.0
43  */

44 public class EntityFieldTag extends TagSupport JavaDoc {
45     
46     public static final String JavaDoc module = EntityFieldTag.class.getName();
47
48     protected String JavaDoc field = null;
49     protected String JavaDoc type = null;
50     protected String JavaDoc attribute = null;
51     protected Object JavaDoc defaultObj = "";
52     protected String JavaDoc prefix = null;
53     protected String JavaDoc suffix = null;
54
55     public String JavaDoc getAttribute() {
56         return attribute;
57     }
58
59     public void setAttribute(String JavaDoc attribute) {
60         this.attribute = attribute;
61     }
62
63     public String JavaDoc getField() {
64         return field;
65     }
66
67     public void setField(String JavaDoc field) {
68         this.field = field;
69     }
70
71     public String JavaDoc getType() {
72         return type;
73     }
74
75     public void setType(String JavaDoc type) {
76         this.type = type;
77     }
78
79     public String JavaDoc getPrefix() {
80         return prefix;
81     }
82
83     public void setPrefix(String JavaDoc prefix) {
84         this.prefix = prefix;
85     }
86
87     public String JavaDoc getSuffix() {
88         return suffix;
89     }
90
91     public void setSuffix(String JavaDoc suffix) {
92         this.suffix = suffix;
93     }
94
95     public Object JavaDoc getDefault() {
96         return defaultObj;
97     }
98
99     public void setDefault(Object JavaDoc defaultObj) {
100         this.defaultObj = defaultObj;
101     }
102
103     public int doStartTag() throws JspException JavaDoc {
104         try {
105             EntityField.run(attribute, field, prefix, suffix, defaultObj.toString(), type, pageContext);
106         } catch (IOException JavaDoc e) {
107             if (UtilJ2eeCompat.useNestedJspException(pageContext.getServletContext())) {
108                 throw new JspException JavaDoc(e.getMessage(), e);
109             } else {
110                 Debug.logError(e, "Server does not support nested exceptions, here is the exception", module);
111                 throw new JspException JavaDoc(e.toString());
112             }
113         } catch (GenericEntityException e) {
114             if (UtilJ2eeCompat.useNestedJspException(pageContext.getServletContext())) {
115                 throw new JspException JavaDoc("Entity Engine error: " + e.getMessage(), e);
116             } else {
117                 Debug.logError(e, "Server does not support nested exceptions, here is the exception", module);
118                 throw new JspException JavaDoc("Entity Engine error: " + e.toString());
119             }
120         }
121
122         return (SKIP_BODY);
123     }
124 }
125
Popular Tags