KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Id: InputValueTag.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.InputValue;
34
35 /**
36  * InputValueTag - Outputs a string for an input box from either an entity field or
37  * a request parameter. Decides which to use by checking to see if the entityattr exist and
38  * using the specified field if it does. If the Boolean object referred to by the tryentityattr
39  * attribute is false, always tries to use the request parameter and ignores the entity field.
40  *
41  * @author <a HREF="mailto:jonesde@ofbiz.org">David E. Jones</a>
42  * @version $Rev: 5462 $
43  * @since 2.0
44  */

45 public class InputValueTag extends TagSupport JavaDoc {
46     
47     public static final String JavaDoc module = InputValueTag.class.getName();
48
49     private String JavaDoc field = null;
50     private String JavaDoc param = null;
51     private String JavaDoc entityAttr = null;
52     private String JavaDoc tryEntityAttr = null;
53     private String JavaDoc defaultStr = "";
54     private String JavaDoc fullattrsStr = null;
55
56     public String JavaDoc getField() {
57         return field;
58     }
59
60     public void setField(String JavaDoc field) {
61         this.field = field;
62     }
63
64     public String JavaDoc getParam() {
65         return param;
66     }
67
68     public void setParam(String JavaDoc param) {
69         this.param = param;
70     }
71
72     public String JavaDoc getEntityAttr() {
73         return entityAttr;
74     }
75
76     public void setEntityAttr(String JavaDoc entityAttr) {
77         this.entityAttr = entityAttr;
78     }
79
80     public String JavaDoc getTryEntityAttr() {
81         return tryEntityAttr;
82     }
83
84     public void setTryEntityAttr(String JavaDoc tryEntityAttr) {
85         this.tryEntityAttr = tryEntityAttr;
86     }
87
88     public String JavaDoc getDefault() {
89         return defaultStr;
90     }
91
92     public void setDefault(String JavaDoc defaultStr) {
93         this.defaultStr = defaultStr;
94     }
95
96     public String JavaDoc getFullattrs() {
97         return fullattrsStr;
98     }
99
100     public void setFullattrs(String JavaDoc fullattrsStr) {
101         this.fullattrsStr = fullattrsStr;
102     }
103
104     public int doStartTag() throws JspException JavaDoc {
105         try {
106             InputValue.run(field, param, entityAttr, tryEntityAttr, defaultStr, fullattrsStr, pageContext);
107         } catch (IOException JavaDoc e) {
108             if (UtilJ2eeCompat.useNestedJspException(pageContext.getServletContext())) {
109                 throw new JspException JavaDoc(e.getMessage(), e);
110             } else {
111                 Debug.logError(e, "Server does not support nested exceptions, here is the exception", module);
112                 throw new JspException JavaDoc(e.toString());
113             }
114         }
115
116         return (SKIP_BODY);
117     }
118 }
119
120
Popular Tags