View Javadoc

1   /*
2    * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/taglib/DbLinkPositionItemTag.java,v 1.15 2006/01/13 13:38:51 hkollmann Exp $
3    * $Revision: 1.15 $
4    * $Date: 2006/01/13 13:38:51 $
5    *
6    * DbForms - a Rapid Application Development Framework
7    * Copyright (C) 2001 Joachim Peer <joepeer@excite.com>
8    *
9    * This library is free software; you can redistribute it and/or
10   * modify it under the terms of the GNU Lesser General Public
11   * License as published by the Free Software Foundation; either
12   * version 2.1 of the License, or (at your option) any later version.
13   *
14   * This library is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17   * Lesser General Public License for more details.
18   *
19   * You should have received a copy of the GNU Lesser General Public
20   * License along with this library; if not, write to the Free Software
21   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
22   */
23  
24  package org.dbforms.taglib;
25  
26  import org.dbforms.config.*;
27  
28  import javax.servlet.jsp.*;
29  
30  
31  
32  /***
33   * to be embedded inside a linkURL-element, as shown in example below:
34   * &lt;linkURL href="customer.jsp" table="customer" /&gt; &lt;position
35   * fieldName="id" value="103" /&gt; &lt;position fieldName="cust_lang"
36   * value="2" /&gt; &lt;/link&gt;
37   */
38  public class DbLinkPositionItemTag extends AbstractDbBaseHandlerTag
39     implements javax.servlet.jsp.tagext.TryCatchFinally {
40     String value;
41  
42     /***
43      * DOCUMENT ME!
44      *
45      * @param string
46      */
47     public void setValue(String string) {
48        value = string;
49     }
50  
51  
52     /***
53      * DOCUMENT ME!
54      *
55      * @return
56      */
57     public String getValue() {
58        return value;
59     }
60  
61  
62     /***
63      * DOCUMENT ME!
64      */
65     public void doFinally() {
66        value = null;
67        super.doFinally();
68     }
69  
70  
71     /***
72      * Set up the tag with parent tag's table and link to the field.  Then add
73      * the data to the enclosing linkURL tag.
74      *
75      * @return DOCUMENT ME!
76      *
77      * @throws JspException thrown when error occurs in processing the body of
78      *         this method
79      */
80     public int doStartTag() throws JspException {
81        DbLinkURLTag parentTag = null;
82  
83        try {
84           parentTag = (DbLinkURLTag) this.getParent();
85        } catch (Exception e) {
86           throw new JspException("DbLinkPositionItem-element must be placed inside a DbLinkURL-element!");
87        }
88  
89        Table table = parentTag.getTable();
90        Field field = table.getFieldByName(getName());
91        parentTag.addPositionPart(field, getValue());
92  
93        return EVAL_BODY_INCLUDE;
94     }
95  }