KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > dlog4j > tags > ParamTag


1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU Library General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  */

16 package dlog4j.tags;
17
18 import java.sql.SQLException JavaDoc;
19
20 import javax.servlet.jsp.JspException JavaDoc;
21
22 import net.sf.hibernate.HibernateException;
23 import net.sf.hibernate.Session;
24 import dlog4j.ParamManager;
25 import dlog4j.SiteManager;
26 import dlog4j.formbean.ParamForm;
27 import dlog4j.formbean.SiteForm;
28
29 /**
30  * @author Liudong
31  * 系统参数信息标签库
32  */

33 public class ParamTag extends DlogBaseTag {
34
35     String JavaDoc name ;
36     String JavaDoc value;
37
38     /* (non-Javadoc)
39      * @see javax.servlet.jsp.tagext.Tag#doStartTag()
40      */

41     public int doStartTag() throws JspException JavaDoc{
42         Session ssn = null;
43         try{
44             ssn = getSession();
45             SiteForm site = SiteManager.getCurrentSite(pageContext.getRequest());
46             ParamForm param = ParamManager.getParam(ssn,site,name);
47             if(param==null){
48                 param = new ParamForm();
49                 param.setName(name);
50                 param.setValue(value);
51             }
52             pageContext.setAttribute(id, param);
53         } catch (SQLException JavaDoc e) {
54             throw new JspException JavaDoc(e);
55         } catch (HibernateException e) {
56             throw new JspException JavaDoc(e);
57         }finally{
58             try{
59                 closeSession(ssn);
60             }catch(Exception JavaDoc e){}
61         }
62         return SKIP_BODY;
63     }
64
65     /**
66      * @return
67      */

68     public String JavaDoc getName() {
69         return name;
70     }
71
72     /**
73      * @param string
74      */

75     public void setName(String JavaDoc string) {
76         name = string;
77     }
78
79     /**
80      * @return
81      */

82     public String JavaDoc getValue() {
83         return value;
84     }
85
86     /**
87      * @param string
88      */

89     public void setValue(String JavaDoc string) {
90         value = string;
91     }
92
93     /**
94      * @param string
95      */

96     public void setValue(int string) {
97         value = String.valueOf(string);
98     }
99     /**
100      * @param string
101      */

102     public void setValue(Integer JavaDoc string) {
103         value = String.valueOf(string.intValue());
104     }
105
106 }
107
Popular Tags