Hi Rick,

> If you can't find anything there I'd recommend creating an implementation of
> the Iterator or List interfaces to wrap the ResultSet object, like we have
> with the EntityListIterator in OFBiz.

David's suggestion is the way to go if you absolutely must use your own "SQL processor". The EntityListIterator is tightly coupled with an SQLProcessor, so you can't just pump your ResultSet into it. You could try to create a new implementation say MyEntityListIterator that would follow EntityListIterator very closely.

I don't think it's possible to use BeansWrapper to wrap your ResultSet. You probably will need to wrap your ResultSet in an Iterator.

Note that Freemarker manual suggests using List or Collection, rather than Iterator. With Iterator, you can only use your Iterator variables in a <#list> tag just once! The 2nd time you use it will throw an error.

I suspect Freemarker doesn't take in ListIterator. You can try.

Jonathon

David E Jones wrote:

This is more of a question about JDBC and FTL, ie somewhat independent of OFBiz.

The freemarker.org site or searching on google might have some helpful tips on using a ResultSet object with FTL. I'm not aware of anything, but haven't looked. If you can't find anything there I'd recommend creating an implementation of the Iterator or List interfaces to wrap the ResultSet object, like we have with the EntityListIterator in OFBiz.

You could also write some code in a bsh script or whatever to go through the ResultSet and put the data in a List of Maps that is easy to traverse in FTL.

Actually, what I would do is step back and review the business level requirement and find an easier way to do the query so that you can use the nice easy tools and patterns already established...

-David


Richard Fleming wrote:
Rodrigo,
Thanks for the reply.. but I can't use the delegator object. I have to use a jdbc connection so that I can query the database with a non standard operator (@@). The delegator doesn't support calling this operator. My life would be much easier if it did. So I create a database connection using the sqlprocessor and return a java.sql.resultset which I add to the context. I'm reading through the Freemarker docs but it would help to see an example in ofbiz which utilizes a resultset.

<#list rs1 as parts>

</#list>

Where rs1 is a java.sql.resultset object.

Do you have any ideas?
Rick

Rick

Rodrigo Souza <[EMAIL PROTECTED]> wrote: User delegator to data layer.
Not use in .ftl files.

2007/8/6, Richard Fleming :
Hello all-

I've put together a bsh script that puts a java.sql.resultset into the context. How do I create a list tag in my freemarker file to display the resultset?

Thanks
Rick








Reply via email to