Velocity - call Servoy method from html area

Hi
I have used Velocity to render a small calendar inside a webclient app. The calendar is contained inside and html_area and works correctly as expected however there does not seem to be a way to make a function call from Velocity to Servoy. This can be done on render but not after the fact. Has anyone come up with a method where by you can call a function from the browser back to servoy on demand and more importantly from Velocity in this case ?

Best
Gordon

I’m confused, you say your using Velocity inside a web client app… then you say you want Velocity to callback to Servoy.
But once the calendar is rendered, ‘after the fact’, as you say, it is rendered in the browser, so Velocity has nothing to do with it.
You can use the WebClientUtils to get a callback URL that you can pass to Velocity as-is and use it in your calendar scripts.

Essentially I want to click on a link in the calendar and trigger a script in the Servoy form ?? I am sure this is simple I am just not seeing the how right now :( I did try and stick this into the html

26

which appears on the status bar but does not actually do anything apparently

Best
Gordon

More specifically, Patrick is saying you’re looking for web client utils “generateCallbackScript()” which you can use to inject a callback to a servoy method in the html output of html areas.

Some good sample code on the forum. To get you started:

/**
 * Auto-hide/show fast find data entry
 *
 * @param {Boolean} firstShow form is shown first time after load
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"5D86C07E-1F37-4E4E-A7D8-48A56C71F347"}
 */
function FORM_on_show(firstShow, event) {
	if (firstShow && false) {
		var elem = plugins.WebClientUtils.getElementMarkupId(elements.btn_find) // element attaching callback to
		
		var script = plugins.WebClientUtils.generateCallbackScript(ACTION_find) //ACTION_find servoy method to run
		
		//rollover of fast find auto-pops up form
		plugins.WebClientUtils.executeClientSideJS("$('#" + elem + "').on('mouseover','span',function(){" + script + "});");
		
		//rollout of fast find hides form
		plugins.WebClientUtils.executeClientSideJS("$('#" + elem + "').on('mouseout','span',function(){alert('goodbye');});");
	}

Thanks David/Patrick for the replies, there was in fact a spectacularly simple answer that I had overlooked. Essentially I used a template calendar rather than wasting my time growing a new one. I cut/pasted the code into a velocity template rendering the days for the given month - all works brilliantly fast as expected. When I came to attach methods to the href functions they failed

ie $!number.format(‘#’,$!record.row)

Which should work as we all know !! The issue was the original file started

etc…

Remove the !DOCTYPE and the problem went away. Now Servoy triggers the scripts as expected :)

All the best and thanks for your inputs …

Gordon