I'm finishing up on a model for executing JDBC retrievals from a JSP,
using a scriptlet like 

<% 
  FruitSalesForm fruitSalesForm = (FruitSalesForm)
session.getAttribute("fruitSalesForm");
  fruitSalesForm.setPageContext(pageContext); 
%>

to execute pooled JDBC connetions, and transfer the results into
page-scope collections,  for use by the iterate or option tags. 

To get there, I 

Setup straight "data beans" to represent the rows of a table (or a form
option). 

Subclassed a "QueryFormBean" from ActionFormBean to encapsulate the
query string, execute the query given a GenericConnection, and to track
the last relative position in the result set.

Subclassed QueryFormBean to return an array of data beans from the
object's ResultSet (a RowSet would be better). This array is ultimately
inserted directly into the page context, for use by an iterate or
option tag.

Subclassed a "ActionDataForm" from ActionForm, and added methods to
expose key JSP and Struts resources via the page context, and a method
for obtaining a GenericConnection from the servlet. 

Implemented the ActionDataForm with the subclassed QueryFormBean as a
property. Overrode setPageContext to execute the QueryFormBean, and
insert the databean array into the page context. 

I'm working on adding metadata and other convenience methods now. I'll
post the working example soon. Just wondering what similar solutions
others might have found to handling JDBC queries within Struts.


Reply via email to