Progress evidence

Hi all,

I’m working with Servoy 5.2.11 in windows 7.
I’m using the JProgressBar bean with the “indeterminate” option.
All works fine… The problem comes, for example, when I have to wait the results of a sql execution: In this case the bar is freezed until the sql doesn’t finish.

My question is: Does exist a way to avoid this problem with this bean? If not: Does exist any other component that can bypass this behavior?

Thanks in advance

Marco

Throw up a progress bar then do the rest of the method via the headless client plugin. Use the callback method to turn off the progress bar.

Also check out the Busy Plugin

david:
Throw up a progress bar then do the rest of the method via the headless client plugin. Use the callback method to turn off the progress bar.

Also check out the Busy Plugin

Hi!

I almost have the same scenario, but instead of a sql return, I have a web service call. It also freezes until the web service doesn’t finish.

Could anyone give me some advice?

Thanks!

rogel:

david:
Throw up a progress bar then do the rest of the method via the headless client plugin. Use the callback method to turn off the progress bar.

Also check out the Busy Plugin

Given this syntax for creating headlessclient…

// Creates a headless client that will open the given solution.
var headlessClient = plugins.headlessclient.createClient("someSolution", "user", "pass", null);
if (headlessClient != null && headlessClient.isValid()) { 
	 var x = new Object();
	 x.name = 'remote1';
	 x.number = 10;
headlessClient.queueMethod(null, "remoteMethod", [x], callback);
}
  1. “someSolution” should be a different solution?
  2. is the username and password solution based?
  3. can i pass arguments to the callback method?

I tried to create “someSolution” but when I debug in developer the createClient method, it goes to the solutionopen of my mainSolution. :( anything i missed?

please help.

thanks!

  1. In developer, the “entry point” for headlessclient plugin isn’t actually call the Servoy solution you specify, but the activated solution. Which triggers the onOpen method of that solution if there is one.

When deployed, the entry point for headlessclient plugin is the solution you specify.

To test headlessclient properly in developer you need to activate the module that you are calling.

See: viewtopic.php?f=15&t=16011

  1. Some sample code for you showing the methods and data flow. Image manipulation on the server in Sutra CMS. Taken from:

https://www.servoyforge.net/projects/su … __image.js

// 1) headless client plugin call
var params 	= {origLocation : origLocation, 
			           newLocation 	: newLocation,
			           width		: metaRows.width.data_value,
			           height		: metaRows.height.data_value,
			           assetID		: asset.id_asset_instance,
			           directory	: forms.WEB_0F_site.directory}
var jsclient = plugins.headlessclient.createClient("_dsa_mosaic_WEB_cms", null, null, null)
jsclient.queueMethod("WEB_0F_asset__image", "IMAGE_resize", [params], IMAGE_resize_callback)


// 2) method run by headless client
function IMAGE_resize(params) {
	var origLocation 	= params.origLocation
	var newLocation		= params.newLocation
	var newWidth		= params.width
	var newHeight		= params.height
	var directory		= params.directory
	
	var assetFS = databaseManager.getFoundSet("sutra_cms","web_asset_instance")
	assetFS.find()
	assetFS.id_asset_instance = params.assetID
	var count = assetFS.search()
	var asset = assetFS.getSelectedRecord()
	
	
	//root directory for this site
	var baseDirectory = forms.WEB_0F_install.ACTION_get_install() +
						'/application_server/server/webapps/ROOT/sutraCMS/sites/' +
						directory + '/'		
							
	var file = plugins.file.convertToJSFile(origLocation)
	var imageTemp =  plugins.images.getImage(file.getBytes())
	
	if (newLocation) {
		var newName = newLocation.split('/')
		newName = newName[newName.length - 1]
		
		var newDir = newLocation.substr(baseDirectory.length)
		newDir = newDir.substr(0,newDir.length - newName.length - 1)
		
		var ext = newName.split('.')
		var fileExt = ext[ext.length-1].toLowerCase()
	}
	
	
	// set image details object
	var fileOBJ = {}
	fileOBJ.image_name	= newName || file.getName().replace(/ /g, "_")
	fileOBJ.image_type	= file.getContentType()
	fileOBJ.image_extension	= fileExt
	fileOBJ.width		= newWidth || imageTemp.getWidth()
	fileOBJ.height		= newHeight || imageTemp.getHeight()
	fileOBJ.directory	= newDir || "images"	//TODO: this will need to be more customizable
	fileOBJ.rec_created = new Date()
	fileOBJ.size		= plugins.file.getFileSize(file)
	if (fileOBJ.width > 200 || fileOBJ.height > 200) {
		fileOBJ.thumbnail	= imageTemp.resize((200*fileOBJ.width) / fileOBJ.height, 200)
	}
	else {
		fileOBJ.thumbnail	= imageTemp
	}
	
	//resize image if new sizes passed in
	if (newWidth || newHeight) {
		file = imageTemp.resize(newWidth || imageTemp.getWidth(), newHeight || imageTemp.getHeight()).getData()
		fileOBJ.size = file.length
	}
	//convert to byte array for initial import
	else {
		file = file.getBytes()
	}
		
	// save file
	var success = plugins.file.writeFile(plugins.file.convertToJSFile(newLocation),file)
	
	if ( !success ) {
		return "File save error"
	}
	
	//save down new information
	asset.asset_size = fileOBJ.size
	asset.asset_directory = fileOBJ.directory
	
	databaseManager.saveData()
	
	// return asset instance ID so can select in callback
	return params.assetID
}


// 3) headless client callback method
function IMAGE_resize_callback(callback) {
	//select last record
	forms.WEB_0F_asset_1F_2L_asset_instance.foundset.selectRecord(callback.data)
	plugins.dialogs.showInfoDialog("Image",  "Image resized")
}

david:

  1. In developer, the “entry point” for headlessclient plugin isn’t actually call the Servoy solution you specify, but the activated solution. Which triggers the onOpen method of that solution if there is one.

When deployed, the entry point for headlessclient plugin is the solution you specify.

To test headlessclient properly in developer you need to activate the module that you are calling.

See: viewtopic.php?f=15&t=16011

Thanks David!

I do have a Cancel button in my form. How can I signal the headless client method to stop once it has commenced?

rogel:
Thanks David!

I do have a Cancel button in my form. How can I signal the headless client method to stop once it has commenced?

Generally, you either run methods or you don’t. Doesn’t change with headless client plugin methods. You could however string a bunch of headless client plugin methods together by triggering another one in the callback method of the prior one. This would give you the opportunity to get user input before proceeding with the next call.

david:

rogel:
Thanks David!

I do have a Cancel button in my form. How can I signal the headless client method to stop once it has commenced?

Generally, you either run methods or you don’t. Doesn’t change with headless client plugin methods. You could however string a bunch of headless client plugin methods together by triggering another one in the callback method of the prior one. This would give you the opportunity to get user input before proceeding with the next call.

is there any other alternative for the headless client plugin so my progress bar still runs while my process runs in the background/server since i believe headless client plugin consumes 1 license.

Hi!

Anyone would like to share an alternative for this?

Thanks!

Hi rogel,

I don’t know much about headless client licenses yet, but there is an old document (http://www.servoy.com/docs/servoy_headless_client.pdf) that suggests you can programmatically disconnect, thus freeing the license after the process is finished. It states, “Each headless client consumes a normal Servoy Client license when started - and that client is ‘released’ (becomes available again) after the JSP session has expired (or has been programatically terminated).”

Also, I have been talking to the “guys” that know their “stuff” on servoyforge about the progress bars in Servoy and wanted to share what they had to say: Feature #507: Add updatable progress bar - Busy Plugin - ServoyForge.

Finally, if you decide to use RESTful web services, there may be some additional useful information here (FWIW): http://wiki.servoy.com/display/public/DOCS/RESTful+Web+Services.