David Navas wrote:
> <[loading sql from a separate file]
> > Agreed, it is a good thing to have. Why not make it loadable from a URI?
>
> Great idea!
>
> > This allows for accessing the SQL statement from a local file, or from any
> > arbitrary resource on a network.
>
> Ayep.
Actually on second thought, this functionality is already provided by <jsp:include
page="relative URL">, and <jsp:include> allows SQL statements to be dynamically
generated if necessary. Simply nesting this tag within a <query> tag should allow
loading SQL statements from a separate file without any requiring the tag author to
provide the functionality herself.
> > As you said, allowing <loop> tags inside of <query> tags makes <query> tags
> > less reusable, especially if queries are cached to be used in different pages
> > or scopes. <loop>s make sense outside of a <query> and simplify the
> > application model; I vote for keeping the tags separate, and in general,
> > keeping tags as context neutral as possible.
>
> In which case, you need an attribute for the query-parameter to direct the
> parameter at a particular query. Additionally, we need to invent a semantic
> for "[re]execute query". Perhaps as an attribute of loop?
How about this sematic?:
<%-Query is cached on server for 60 sec and has application scope-%>
<query id="foo" timedCache="60">SELECT * FROM CUSTOMER</query>
<loop query="<%=foo%>"> <field field="customer"/> </loop>
If the JSP page is processed again, the <query id="foo" timedCache="60"> will check
if the resultset has been cached (by any JSP page in the application) within the
past 60 seconds, and [re]execute the query if necessary. The required "query"
attribute of <loop> can indicate which query to loop over via <query>'s unique id
(in this case, foo).
> > <loop startRow="specific row" maxRows="10"> would solve the problem. If
> > startRow and maxRows are variables, then "Show next 10 Records" functionality
> > can be implemented using session variables or URL rewriting which redirects to
> > the same JSP page. startRow and maxRows attributes looks useful, I vote for
> > them.
>
> Problem -- the "last" button should go to numRows-in-resultset minus the
> rows-to-display (maxRows, here). For forward-only resultsets, this can be
> problematic!
I would assume that queries on a database would cache the resultsets on the server
for efficiency purposes. Cached resultsets do not have to be forward-only. However,
a mechanism to determine the numRows-in-resultset from the context of custom tags
would be useful. This could be a possible implementation for the "show last 10
records" button:
<query id="foo">SELECT * FROM CUSTOMER </query>
<loop query="<%=foo%>" startRow="<%=foo.maxRows-10%> maxRows="10>...
--
Michael Hu, Paradox Team, Corel Corporation
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html