JavaComponent question with Servoy 5.2

In 3.5.12, I am using this code (from Troy Elliot) to control the position of my smart client scrollbar:

	application.updateUI(200)
	var HowManyRows = forms.ProjectsSpendingForecast.foundset.getSize()
	var javaComponent = new Packages.java.lang.ref.SoftReference(forms.ProjectsSpendingForecast).get()
	var scrollPosition = (globals.ForecastCurrentIndex)*17
	javaComponent.getFormUI().getComponents()[0].getComponents()[0].getVerticalScrollBar().setValue(scrollPosition)

In 5.2, I get this error:

Bad practice: FormController cant be wrapped to javascript (for example not usable as argument in Scheduler plugin)

java.lang.IllegalArgumentException: Bad practice: FormController cant be wrapped to javascript (for example not usable as argument in Scheduler plugin)

Help? This is an important feature in my solution that I cannot lose due to conversion. Thanks in advance.

Hi Ellen,

that was quite a hack! :wink:
I did a little plugin for you (works in 5.2+) that does the same in a much cleaner way…
See attached.

The jar is signed, all you have to do is:

  • put in your /plugins folder in Servoy 5.2 and restart)
  • check the ‘scroller’ plugin, there are 2 ‘obvious’ methods with samples/tooltips.

Enjoy!

scroller.jar (7.15 KB)

Patrick! Lifesaver, you are. Thanks soooooo much. I’ll give it a whirl tomorrow.

Hi Ellen,

I did a more powerful implementation of that one which is called Scroller Plus: you can even add listeners to scrollbars and use it to synchronize scrollbars.
Check it out, it’s Open Source, on ServoyForge of course:
http://www.servoyforge.net/projects/scroller

Checked it out, very cool.

Patrick – Thanks so much, I need to synchronize scrollbars for a splitpane too. Do you have any sample code for how to make this work – both the scroll position setting and the listeners?

Hi Ellen,

it’s all on ServoyForge, explained in the wiki:
http://www.servoyforge.net/projects/scroller/wiki

You can see it in action with SplitPane in a sample solution that you can also download here:
http://www.servoyforge.net/projects/scroller/files

I updated it so that this is now compatible with Servoy 5.1.x and 5.2+