public class JoSQLJSPQueryTag
extends BodyTagSupport
Example:
<%@ page import="java.util.Arrays" %> <%@ page import="java.io.File" %> <%@ tablib prefix="josql" uri="josqltaglib" %> <josql:query inputList='<%= Arrays.asList (new File ("/home/me/").listFiles ()) %>' results="queryResults"> SELECT * FROM java.io.File WHERE name = '.bashrc' </josql:query>
The body of the tag is taken as the statement to execute.
Note: this class deliberately does NOT extend Query
since doing so would then
prevent the query from being released via the release()
method.
The following attributes are supported:
true
.QueryResults
).Constructor and Description |
---|
JoSQLJSPQueryTag() |
Modifier and Type | Method and Description |
---|---|
int |
doAfterBody()
When called will parse the tag body into a JoSQL statement.
|
int |
doEndTag()
Execute the statement parsed in
doAfterBody() . |
void |
release()
Release the objects we have references to and then call: super.release ().
|
void |
setInputList(Object l)
Set the input list, i.e.
|
void |
setResults(String r)
Set the name of the attribute that should hold the results.
|
public void setResults(String r)
r
- The name.public void setInputList(Object l)
doEndTag()
method
is called.l
- The name or list of objects to execute the statement against.public int doAfterBody() throws JspException
Tag#SKIP_BODY
is returned.JspException
- If the tag body cannot be parsed into a JoSQL statement.public int doEndTag() throws JspException
doAfterBody()
.
The list of objects to execute the statement against is first retrieved
using the value specified in setInputList(Object)
. The list must
not be null and must be a list otherwise an exception is thrown.
Once executed the results are set as an attribute specified by:
setResults(String)
.
Tag#EVAL_PAGE
always.JspException
- If the list is null, not a list or the statement cannot
be executed against the list of objects.public void release()