KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nextime > ion > frontoffice > taglib > SelectObjectsParamTag


1 /*
2  * ĻON content management system.
3  * Copyright (C) 2002 Guillaume Bort(gbort@msn.com). All rights reserved.
4  *
5  * Copyright (c) 2000 The Apache Software Foundation. All rights reserved.
6  * Copyright 2000-2002 (C) Intalio Inc. All Rights Reserved.
7  *
8  * ĻON is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * ĻON core framework, ĻON content server, ĻON backoffice, ĻON frontoffice
14  * and ĻON admin application are parts of ĻON and are distributed under
15  * same terms of licence.
16  *
17  *
18  * ĻON includes software developed by the Apache Software Foundation (http://www.apache.org/)
19  * and software developed by the Exolab Project (http://www.exolab.org).
20  *
21  * ĻON is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU General Public License for more details.
25  */

26
27 package org.nextime.ion.frontoffice.taglib;
28
29 import javax.servlet.jsp.JspException JavaDoc;
30 import javax.servlet.jsp.JspTagException JavaDoc;
31 import javax.servlet.jsp.tagext.BodyTagSupport JavaDoc;
32 import javax.servlet.jsp.tagext.Tag JavaDoc;
33
34 import org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager;
35
36 public class SelectObjectsParamTag extends BodyTagSupport JavaDoc {
37
38     private String JavaDoc _value;
39     private String JavaDoc _name;
40
41     public SelectObjectsParamTag() {
42         super();
43         init();
44     }
45
46     public int doStartTag() throws JspException JavaDoc {
47         evaluateExpressions();
48         return super.doStartTag();
49     }
50
51     public int doEndTag() throws JspException JavaDoc {
52         Tag JavaDoc t = findAncestorWithClass(this, SelectObjectsTag.class);
53         if (t == null)
54             throw new JspTagException JavaDoc("Le tag param doit etre dans un tag selectObjects");
55
56         if (_name == null && _name.equals(""))
57             return EVAL_PAGE;
58
59         SelectObjectsTag parent = (SelectObjectsTag) t;
60         String JavaDoc value = _value;
61         if (value == null) {
62             if (bodyContent == null || bodyContent.getString() == null)
63                 value = "";
64             else
65                 value = bodyContent.getString().trim();
66         }
67         parent.addParameter(_name, value);
68         return EVAL_PAGE;
69     }
70
71     public void release() {
72         super.release();
73         init();
74     }
75
76     public void setValue(String JavaDoc value) {
77         _value = value;
78     }
79
80     public void setName(String JavaDoc name) {
81         _name = name;
82     }
83
84     private void init() {
85         _value = null;
86         _name = null;
87     }
88
89     private void evaluateExpressions() throws JspException JavaDoc {
90         if (_value != null && !"".equals(_value)) {
91             _value =
92                 ExpressionEvaluatorManager.evaluate(
93                     "value",
94                     _value,
95                     Object JavaDoc.class,
96                     this,
97                     pageContext)
98                     + "";
99         }
100     }
101
102 }
Popular Tags