1 package com.fc.taglibs.castor;
2
3 import java.io.*;
4 import java.util.ArrayList;
5 import javax.naming.*;
6 import javax.servlet.jsp.*;
7 import javax.servlet.jsp.tagext.*;
8 import org.apache.taglibs.standard.lang.support.*;
9
10
11 import org.exolab.castor.jdo.OQLQuery;
12
13
14 public class CastorOqlBindTag extends BodyTagSupport
15 {
16
17 /***
18 * The value to bind to the query
19 */
20 private String value;
21
22 /***
23 * The castor objects we will need.
24 */
25 private OQLQuery query = null;
26
27
28 /***
29 * Sets the value to bind to the query
30 */
31 public void setValue(String _value)
32 {
33 this.value = _value;
34 }
35
36
37
38
39 /***
40 * Do the start tag bit
41 */
42 public int doStartTag() throws JspException
43 {
44
45 try
46 {
47 /***
48 * Get the OQL query
49 */
50 CastorOqlTag parent = (CastorOqlTag)findAncestorWithClass(this, CastorOqlTag.class);
51 if (parent!=null)
52 query = parent.getOql();
53 else
54 throw new JspTagException("CastorOQLBindTag must be used within CastorOqlTag.");
55
56 /***
57 * Bind the parameter
58 */
59 Object param = null;
60 if (this.value != null)
61 {
62 param = (Object)ExpressionEvaluatorManager.evaluate("param",this.value, Object.class, this, pageContext);
63 }
64 System.out.println("Value of param: " + param);
65 query.bind( param );
66
67
68 }
69 catch(java.lang.IllegalArgumentException e)
70 {
71 String msg = "IllegalArgumentException thrown in CastorOqlBindTag.doStartTag(): " + e.getMessage();
72 System.err.println(msg);
73 throw new JspException(msg);
74 }
75 catch(java.lang.NullPointerException e)
76 {
77 String msg = "NullPointerException thrown in CastorOqlBindTag.doStartTag(). Check that the number of parameters in the query matches the number of bind tags, and that the query paramters start at $1 and ascend with no gaps.";
78 System.err.println(msg);
79 throw new JspException(msg);
80 }
81 return EVAL_PAGE;
82 }
83
84 }
This page was automatically generated by Maven