Velocity Plugin

Hi
Firstly thanks to all those who have contributed to the Velocity Plugin a great enhancement to Servoy.

I have a simple question that may be staring me in the face. In the example its possible to get the records from a foundset and pass these to the plugin. I have attempted to copy this and am getting no joy in either the demo solution or my own efforts. If anyone can see any issues with what I am doing please can you point it out as I have been fiddling with this for a couple of hours

Created a callback script which populates an object

function gmContext() {
	plugins.VelocityReport;
	var context = new Object();	
	context.firstRecord = foundset.getSelectedRecord();	
	
	var prod = databaseManager.getFoundSet('mydb','clients');  
	prod.loadAllRecords();
	prod.setSelectedIndex(1);

	context.prod = prod;
	
	return context;
}

and then passed it to a copy of the template example with in an attempt to insert it into this clip

[code

#foreach($record in $foundset)

#end
test$record.idclients$record.companyname
[/code]

Incidentally the foundset contains 200 records and the template does return the header as per Patricks example - so both are working !!

If any one has any points I would be very grateful

Thanks
Gordon

Hi Gordon,

Be aware that the variables in the context are available as $variables in the template.

I added some comments in your code to explain it better.

function gmContext() {
	plugins.VelocityReport; // <-- not sure what this will do ;)
	var context = new Object();

	// This will create and store the JSRecord object in $firstRecord
	context.firstRecord = foundset.getSelectedRecord();	
	
	var prod = databaseManager.getFoundSet('mydb','clients');  
	prod.loadAllRecords();
	prod.setSelectedIndex(1);

	// This will create and store the JSFoundset in $prod
	context.prod = prod;
	
	return context;
}

So you can’t address the foundset by $foundset. This variable is not available in your context (unless you add it of course).
Instead use the following template:

<table>#foreach($record in $prod)
<tr><td>test$record.idclients</td><td>$record.companyname</td></tr>
#end
</table>

Hope this helps.

Brilliant thanks !!