Hi,
I am having difficulty getting my "foreach" loop to work with the jetspeed
version of
velocity...
We are using jetspeed1.3a1...
My template contains this;
<ul>
#foreach( $idx in $allIndexes )
<li><a href=$results.doc($idx).get("path")>$results.doc($idx).get("path")
(score=$results.score($idx))
#end
</ul>
My portlet does this;
if (query!=null) {
Hits results = doSearch(query);
int[] indexes = new int[results.length()];
for (int i=0; i<results.length(); i++) {
indexes[i]=i;
}
content.put("allIndexes",indexes);
context.put("results",results);
context.put("ls_q",query);
}
The results and ls_q entries get used ok and appear in my webpage - but the
allIndexes seems to fail.
I get this exception in the velocity log;
Thu May 10 11:45:52 GMT+01:00 2001 [error]
org.apache.velocity.runtime.exception.ReferenceException: #foreach:
$allIndexes is not a valid reference. [line 14,column 19]
at
org.apache.velocity.runtime.directive.Foreach.init(Foreach.java:137)
at
org.apache.velocity.runtime.parser.node.ASTDirective.init(ASTDirective.java:
117)
at
org.apache.velocity.runtime.parser.node.SimpleNode.init(SimpleNode.java:173)
at org.apache.velocity.Template.merge(Template.java:276)
at
com.rabobank.rbp.portlets.LuceneSearchPortlet.getContent(LuceneSearchPortlet
.java:54)
Can anyone give me any clues about what I have done wrong?
I tried naming allIndexes differently, eg foo. I tried putting a collection
or vector instead into the context...
It would be useful to know which version of velocity is in use - so I could
get the source.
Thanks,
Chris
================================================================================================
This electronic message (email) and any attachments to it are subject to copyright and
are sent for the personal attention of the addressee. Although you may be the named
recipient, it may become apparent that this email and its contents are not intended
for you and an addressing error has been made. This email may include information that
is legally privileged and exempt from disclosure. If you have received this email in
error, please advise us immediately and delete this email and any attachments from
your computer system.Rabobank International is the trading name of Co�peratieve
Centrale Raiffeisen-Boerenleenbank B.A. which is incorporated in the Netherlands.
Registered with the Registrar of Companies for England & Wales No. BR002630 and
regulated by the SFA for the conduct of investment business in the UK.
The presence of this footnote also confirms that this email has been automatically
checked by Rabobank International for the presence of computer viruses prior to it
being sent, however, no guarantee is given or implied that this email is virus free
upon delivery.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]