You could try it as follows :
define two classes at bottom of <xsp:page>:
<xsp:logic>
public class MyPart {
private String id;
private String name;
public MyPart(String id) {
this.id = id;
}
public String getId() {
return this.id;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
}
public class MyReusableResultset {
private LinkedList myresults;
public MyReusableResultset() {
this.myresults = new LinkedList();
}
public void addMyPart(MyPart mypart) {
this.myresults.add(mypart);
}
public Iterator getMyResultsIterator() {
return this.myresults.iterator();
}
}
</xsp:logic>
Then
use following code ::
<xsp:logic>
MyReusableResultset myrs = new MyReusableResultset();
</xsp:logic>
<esql:connection>
<esql:driver>??</esql:driver>
<esql:dburl>??</esql:dburl>
<esql:username>??</esql:username>
<esql:password>??</esql:password>
<esql:execute-query>
<esql:query>SELECT part_id, part_nom FROM partenaire</esql:query>
<esql:use-limit-clause>auto</esql:use-limit-clause>
<esql:max-rows>50</esql:max-rows>
<esql:skip-rows>20</esql:skip-rows>
<esql:results>
<esql:row-results>
<xsp:logic>
MyPart newpart = new MyPart(<esql:get-string
column="part_id"/>);
newpart.setName(<esql:get-string column="part_nom"/>);
myrs.addMyPart(newpart);
</xsp:logic>
</esql:row-results>
</esql:results>
<esql:no-results>
<Message>Sorry, no results!</Message>
</esql:no-results>
</esql:execute-query>
</esql:connection>
Now you can reuse it elsewhere :
like for instance to create table :
<form:table>
<form:row header="true">
<form:column>PartNo</form:column>
<form:column>Name</form:column>
</form:row>
<xsp:logic>
for (Iterator i = myrs.getMyResultsIterator(); i.hasNext();) {
<form:row>
<form:column>
<xsp:expr>((MyPart)i.next()).getId()</xsp:expr>
</form:column>
<form:column>
<xsp:expr>((MyPart)i.next()).getName()</xsp:expr>
</form:column>
</form:row>
}
</xsp:logic>
</form:table>
-----Original Message-----
From: Adrian Petru Dimulescu [mailto:[EMAIL PROTECTED]
Sent: 18mm2004 16:45
To: [EMAIL PROTECTED]
Subject: Re: reusing a result set with esql
> I would like to reuse a result set in an XSP page when doing an esql
> query (I want to be able to reiterate throgh the returned rows). Is
> there a way to do that ?
Hello again, let me reformulate this question, I guess it's not very
explicit (hope it's not that plainly stupid):
I have a simple esql sequence in an XSP file:
<esql:connection>
<esql:pool>kercash-warehouse</esql:pool>
<esql:execute-query>
<esql:query>SELECT part_id, part_nom FROM partenaire</esql:query>
<esql:results>
<esql:row-results>
... do something
</esql:row-results>
</esql:results>
<esql:no-results><p>Sorry, no results!</p></esql:no-results>
<esql:error-results>An error occurred</esql:error-results>
</esql:execute-query>
</esql:connection>
I wish I were able, after a first iteration through the result set with
<esql:results>, to re-iterate the same resultset without having to
reexecute the query. Is that possible anybody tried it ?
Thanks for your ideas!
Adrian.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]