Problem with new WebListBox and DataSource

Trying to integrate the new WebListBox DataSource function in my project with Xojo 2020R2. But when i build the app i got this error:

Type mismatch error.  Expected interface WebDataSource, but got class contrKunden.contrKunden
listKunden.DataSource = Self 

The same works in the WebListbox Datasource Example … but where is my mistake?

Hi Martin,

welcome to the forum!

Posting the code where you set the datasource of the listbox would help. A quick check would be to make sure the class you created and using as a datasource implements the WebDataSource interface. That’s what the compiler seems to be telling you :blush:

Hi Bruno,

thanks … you are right: The MySQLCommunityServer is missing the WebDataSource Interface…the Web example works with SQLiteDatabase…!

:wink:

1 Like

Hi guys,

I am trying to use the WebDatasource interface to load a query obtained with the MySQLCommunityServer class but I get the same error as Martin.
Could you confirm if this data source (MySQL) can be used with WebDatasource Interface (Web 2.0), please?.

Thank you very much.
Sergio

The developer is responsible for getting the data from the database and returning it as WebListboxColumnData(). SQLiteDatabase does not implement the WebDataSource interface.

See the example project located at Example Projects/Web/Controls/Listbox/WebListbox Datasource Example.xojo_binary_project

Tim, I just used that example to incorporate the WebDatasource interface into my project.
In my webapp I have created a module called ‘BBDD’ that has the ‘BDSource’ property of the type MySQLCommunityServer.

In the listbox, I have incorporated the methods: BuildQuery, ColumnData, RowCount, RowData and SortedPrimaryKeys.In all of them I have replaced the property ‘db’ (of the type SQLiteDatabase of the example) by my property ‘BDSource’.

So far everything is perfect but the problem is in the final step. I have to feed the listbox with the data. In the example this code is used:

Me.DataSource = Self

And right in compiling the example is where I get in error:

Type mismatch error. Expected interface WebDataSource, but got class ExperimentPage.ExperimentPage, lbExperimentos.DataSource = Self

What do I have to put instead of using ‘Self’?

Thank you very much.
Sergio

You need to indicate that the ExperimentsPage implements the WebDataSource interface. To do this, click the ExperimentsPage in the Navigator and look for “Interfaces” and a “Choose” button in the Inspector on the right.

Click the “Choose” button to select the interfaces the page implements. Here, you’ll need to select WebDataSource to tell the compiler that the WebPage implements the required methods.

1 Like

Wow, I didn’t realize that little detail, :sweat_smile:. Great, clicking that option already works perfectly. Using this strategy everything is more orderly now.

Thanks for your help Tim, the truth is that this part is not at all described in Xojo’s help and you get a little lost.

Perfect. Great!!

Sergio