Display a resultset in an .ftl file

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

Display a resultset in an .ftl file

Rick F.
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 | Threaded
Open this post in threaded view
|

Re: Display a resultset in an .ftl file

Rodrigo Lima-2
User delegator to data layer.
Not use in .ftl files.

2007/8/6, Richard Fleming <[hidden email]>:
> 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 | Threaded
Open this post in threaded view
|

Re: Display a resultset in an .ftl file

Rick F.
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 <[hidden email]> 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 | Threaded
Open this post in threaded view
|

Re: Display a resultset in an .ftl file

jonwimp
In reply to this post by Rodrigo Lima-2
Hi Rick,

Just FYI, a ResultSet is ALREADY a... well... result set generated by a delegator. So, I'm sure
you did use a delegator before hitting the .ftl.

The freemarker list tag takes in sequences. I've tested this to work with Collection(s). Not sure
about ListIterator or Iterator or even ResultSet.

Does it throw an error when you put a ResultSet to a list tag?

Jonathon

Rodrigo Souza wrote:

> User delegator to data layer.
> Not use in .ftl files.
>
> 2007/8/6, Richard Fleming <[hidden email]>:
>> 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 | Threaded
Open this post in threaded view
|

Re: Display a resultset in an .ftl file

David E Jones
In reply to this post by Rick F.

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 <[hidden email]> 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 | Threaded
Open this post in threaded view
|

Re: Display a resultset in an .ftl file

Rick F.
In reply to this post by jonwimp
Johathon,

I used a sqlprocessor object to grab a connection to the default delegator. I could then type in my own sql and add the @@ operator that I need to use.

I tried to just <#list resultset as parts> but got a strange error. Maybe I should just convert the resultset to a collection?

Rick

Jonathon -- Improov <[hidden email]> wrote: Hi Rick,

Just FYI, a ResultSet is ALREADY a... well... result set generated by a delegator. So, I'm sure
you did use a delegator before hitting the .ftl.

The freemarker list tag takes in sequences. I've tested this to work with Collection(s). Not sure
about ListIterator or Iterator or even ResultSet.

Does it throw an error when you put a ResultSet to a list tag?

Jonathon

Rodrigo Souza 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 | Threaded
Open this post in threaded view
|

Re: Display a resultset in an .ftl file

jonwimp
In reply to this post by Rick F.
Rick,

Consider using BeansWrapper? As I said, I've tested <#list> to work with Collection(s), not sure
about ResultSet(s).

See freemarker manual on BeansWrapper.

Jonathon

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 <[hidden email]> 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
>>
>>
>>
>
>
>
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.476 / Virus Database: 269.11.8/940 - Release Date: 8/6/2007 4:53 PM

Reply | Threaded
Open this post in threaded view
|

Re: Display a resultset in an .ftl file

jonwimp
In reply to this post by David E Jones
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 <[hidden email]> 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 | Threaded
Open this post in threaded view
|

Re: Display a resultset in an .ftl file

Rick F.
In reply to this post by David E Jones
David,

Thanks for the reply. I'd love to use the entity engine. But because the @@ operator for tsearch's isn't part of the jdbc driver for postgres, I think I'm stuck. Is there a way within the entity engine to create a custom sql statement  and then  add it as an entity-condition tag or whatever?

If not, I'll follow your other advice.

Thanks again
Rick

David E Jones <[hidden email]> 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>
>
>
>
> Where rs1 is a java.sql.resultset object.
>
> Do you have any ideas?
> Rick
>
> Rick
>
> Rodrigo Souza  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 | Threaded
Open this post in threaded view
|

Re: Display a resultset in an .ftl file

David E Jones

The point would be to step back and define what sort of data you'd like to get from the database and find another way for form the query.

-David


Richard Fleming wrote:

> David,
>
> Thanks for the reply. I'd love to use the entity engine. But because the @@ operator for tsearch's isn't part of the jdbc driver for postgres, I think I'm stuck. Is there a way within the entity engine to create a custom sql statement  and then  add it as an entity-condition tag or whatever?
>
> If not, I'll follow your other advice.
>
> Thanks again
> Rick
>
> David E Jones <[hidden email]> 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>
>>
>>
>>
>> Where rs1 is a java.sql.resultset object.
>>
>> Do you have any ideas?
>> Rick
>>
>> Rick
>>
>> Rodrigo Souza  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 | Threaded
Open this post in threaded view
|

Re: Display a resultset in an .ftl file

jonwimp
In reply to this post by Rick F.
Rick,

Doesn't sound too hard to put @@ into EntityOperator. Would you like to try it? I can at most help
by pointing out all the lines of codes that you need to fiddle with.

Jonathon

Richard Fleming wrote:

> David,
>
> Thanks for the reply. I'd love to use the entity engine. But because the @@ operator for tsearch's isn't part of the jdbc driver for postgres, I think I'm stuck. Is there a way within the entity engine to create a custom sql statement  and then  add it as an entity-condition tag or whatever?
>
> If not, I'll follow your other advice.
>
> Thanks again
> Rick
>
> David E Jones <[hidden email]> 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>
>>
>>
>>
>> Where rs1 is a java.sql.resultset object.
>>
>> Do you have any ideas?
>> Rick
>>
>> Rick
>>
>> Rodrigo Souza  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
>>>
>>>
>>>
>>
>
>
>
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.476 / Virus Database: 269.11.8/940 - Release Date: 8/6/2007 4:53 PM

Reply | Threaded
Open this post in threaded view
|

Re: Display a resultset in an .ftl file

Rick F.
In reply to this post by David E Jones
David -

Maybe you can help me...

I need to query the products table and return 20 or so  possible product ids from the following customer input -  "I need a maytag belt set for my maytag washer" The columns involved in the query are productid, internal_name, brand_name, description, long_description. The database has 1mil+ productid's and the the results need to display in less than 5 seconds.

my solution was to create a full text search of a new column in the products database utilizing the fts or tsearch2 plugin to postgres. The performance is great and returns the results in milliseconds The problem is the operator for the sql statement is @@ which the entity engine doesn't recognize.

Do you know of another way to perform this.?

Thanks
Rick
David E Jones <[hidden email]> wrote:
The point would be to step back and define what sort of data you'd like to get from the database and find another way for form the query.

-David


Richard Fleming wrote:

> David,
>
> Thanks for the reply. I'd love to use the entity engine. But because the @@ operator for tsearch's isn't part of the jdbc driver for postgres, I think I'm stuck. Is there a way within the entity engine to create a custom sql statement  and then  add it as an entity-condition tag or whatever?
>
> If not, I'll follow your other advice.
>
> Thanks again
> Rick
>
> 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>
>>
>>
>>
>> Where rs1 is a java.sql.resultset object.
>>
>> Do you have any ideas?
>> Rick
>>
>> Rick
>>
>> Rodrigo Souza  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 | Threaded
Open this post in threaded view
|

Re: Display a resultset in an .ftl file

David E Jones

Have you tried the performance of the ProductSearch stuff, or more specifically the keyword search part of it, to see if it is adequate?

This does sound like a special case where direct JDBC is the way to go. That just means you'll have some development to do as you can't use the tricks in the entity engine. And yes, that will require some technical effort to get the pieces tied together and there is no best practice or magic way to do it, so you'll just to buckle down and build whatever is needed.

You might try the EntityWhereString as a last resort before directly using JDBC. That takes a free form string that goes into the where clause.

-David


Richard Fleming wrote:

> David -
>
> Maybe you can help me...
>
> I need to query the products table and return 20 or so  possible product ids from the following customer input -  "I need a maytag belt set for my maytag washer" The columns involved in the query are productid, internal_name, brand_name, description, long_description. The database has 1mil+ productid's and the the results need to display in less than 5 seconds.
>
> my solution was to create a full text search of a new column in the products database utilizing the fts or tsearch2 plugin to postgres. The performance is great and returns the results in milliseconds The problem is the operator for the sql statement is @@ which the entity engine doesn't recognize.
>
> Do you know of another way to perform this.?
>
> Thanks
> Rick
> David E Jones <[hidden email]> wrote:
> The point would be to step back and define what sort of data you'd like to get from the database and find another way for form the query.
>
> -David
>
>
> Richard Fleming wrote:
>> David,
>>
>> Thanks for the reply. I'd love to use the entity engine. But because the @@ operator for tsearch's isn't part of the jdbc driver for postgres, I think I'm stuck. Is there a way within the entity engine to create a custom sql statement  and then  add it as an entity-condition tag or whatever?
>>
>> If not, I'll follow your other advice.
>>
>> Thanks again
>> Rick
>>
>> 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>
>>>
>>>
>>>
>>> Where rs1 is a java.sql.resultset object.
>>>
>>> Do you have any ideas?
>>> Rick
>>>
>>> Rick
>>>
>>> Rodrigo Souza  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 | Threaded
Open this post in threaded view
|

Re: Display a resultset in an .ftl file

Rick F.
Thanks David-

I'll try the EntityWhereString first... I hope it works. I'd like to begin to fill the CMS system with textual data from service calls, blogs etc. Full text searches are going to be must for me.

Rick

David E Jones <[hidden email]> wrote:
Have you tried the performance of the ProductSearch stuff, or more specifically the keyword search part of it, to see if it is adequate?

This does sound like a special case where direct JDBC is the way to go. That just means you'll have some development to do as you can't use the tricks in the entity engine. And yes, that will require some technical effort to get the pieces tied together and there is no best practice or magic way to do it, so you'll just to buckle down and build whatever is needed.

You might try the EntityWhereString as a last resort before directly using JDBC. That takes a free form string that goes into the where clause.

-David


Richard Fleming wrote:

> David -
>
> Maybe you can help me...
>
> I need to query the products table and return 20 or so  possible product ids from the following customer input -  "I need a maytag belt set for my maytag washer" The columns involved in the query are productid, internal_name, brand_name, description, long_description. The database has 1mil+ productid's and the the results need to display in less than 5 seconds.
>
> my solution was to create a full text search of a new column in the products database utilizing the fts or tsearch2 plugin to postgres. The performance is great and returns the results in milliseconds The problem is the operator for the sql statement is @@ which the entity engine doesn't recognize.
>
> Do you know of another way to perform this.?
>
> Thanks
> Rick
> David E Jones  wrote:
> The point would be to step back and define what sort of data you'd like to get from the database and find another way for form the query.
>
> -David
>
>
> Richard Fleming wrote:
>> David,
>>
>> Thanks for the reply. I'd love to use the entity engine. But because the @@ operator for tsearch's isn't part of the jdbc driver for postgres, I think I'm stuck. Is there a way within the entity engine to create a custom sql statement  and then  add it as an entity-condition tag or whatever?
>>
>> If not, I'll follow your other advice.
>>
>> Thanks again
>> Rick
>>
>> 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>
>>>
>>>
>>>
>>> Where rs1 is a java.sql.resultset object.
>>>
>>> Do you have any ideas?
>>> Rick
>>>
>>> Rick
>>>
>>> Rodrigo Souza  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 | Threaded
Open this post in threaded view
|

Re: Display a resultset in an .ftl file

Rick F.
In reply to this post by jonwimp
Jonathon,

I'd be willing to try it. Thanks, if it can be added to the core, it'll be worth the effort.

Rick

Jonathon -- Improov <[hidden email]> wrote: Rick,

Doesn't sound too hard to put @@ into EntityOperator. Would you like to try it? I can at most help
by pointing out all the lines of codes that you need to fiddle with.

Jonathon

Richard Fleming wrote:

> David,
>
> Thanks for the reply. I'd love to use the entity engine. But because the @@ operator for tsearch's isn't part of the jdbc driver for postgres, I think I'm stuck. Is there a way within the entity engine to create a custom sql statement  and then  add it as an entity-condition tag or whatever?
>
> If not, I'll follow your other advice.
>
> Thanks again
> Rick
>
> 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>
>>
>>
>>
>> Where rs1 is a java.sql.resultset object.
>>
>> Do you have any ideas?
>> Rick
>>
>> Rick
>>
>> Rodrigo Souza  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
>>>
>>>
>>>
>>
>
>
>
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.476 / Virus Database: 269.11.8/940 - Release Date: 8/6/2007 4:53 PM


Reply | Threaded
Open this post in threaded view
|

Re: Display a resultset in an .ftl file

jonwimp
Rick,

I would recommend that you try it, since it really is quite trivial.

David's suggestion regarding the use of EntityWhereString should only be an interim solution.

For starters, take a look at EntityOperator.java. You'll see that adding the "@@" operator is
quite trivial.

Jonathon

Richard Fleming wrote:

> Jonathon,
>
> I'd be willing to try it. Thanks, if it can be added to the core, it'll be worth the effort.
>
> Rick
>
> Jonathon -- Improov <[hidden email]> wrote: Rick,
>
> Doesn't sound too hard to put @@ into EntityOperator. Would you like to try it? I can at most help
> by pointing out all the lines of codes that you need to fiddle with.
>
> Jonathon
>
> Richard Fleming wrote:
>> David,
>>
>> Thanks for the reply. I'd love to use the entity engine. But because the @@ operator for tsearch's isn't part of the jdbc driver for postgres, I think I'm stuck. Is there a way within the entity engine to create a custom sql statement  and then  add it as an entity-condition tag or whatever?
>>
>> If not, I'll follow your other advice.
>>
>> Thanks again
>> Rick
>>
>> 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>
>>>
>>>
>>>
>>> Where rs1 is a java.sql.resultset object.
>>>
>>> Do you have any ideas?
>>> Rick
>>>
>>> Rick
>>>
>>> Rodrigo Souza  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
>>>>
>>>>
>>>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> No virus found in this incoming message.
>> Checked by AVG Free Edition.
>> Version: 7.5.476 / Virus Database: 269.11.8/940 - Release Date: 8/6/2007 4:53 PM
>
>
>
>
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.476 / Virus Database: 269.11.8/940 - Release Date: 8/6/2007 4:53 PM