Ariel
Ariel

Reputation: 57

(XPages)Can use Javascript to connect ODBC data to show on XPages?

I have some data stored in ODBC, and those data look like this:

enter image description here

Does anyone use calculated fields or other functions to display ODBC data in XPages?

I need to display the data stored in ODBC in XPages, and then write other data to save back to ODBC.


Originally used ASP to write this function, the writing method is as follows:

Set conn = Server.CreateObject("ADODB.Connection")
conn.open b8_dsn

SQL = "SELECT PONUM as PONUM,COMP_NAME as Company,CASENAME AS Case_name,PRICE as Price" 
SQL = SQL & " FROM CB4_AUCTION"
Set rs = conn.Execute(SQL)

Upvotes: 0

Views: 233

Answers (1)

stwissel
stwissel

Reputation: 20384

Your best course of action is to encapsulate the ODBC (actually more JDBC) data into a managed bean. Design one property of the bean to be like

  public List<SomeData> getRows();

and you can use beanName.rows directly in a repeat control as data source. Design the SomeData as Java bean (which is fancy for: having getSomeValue(), setSomeValue(...) pairs of methods, so you can directly bind them to a form using beanInstanceName.someValue (where beanInstanceName is the variable name of your repeat control)

You can read about bean data binding here:
https://wissel.net/blog/2011/01/binding-controls-to-managed-beans.html

And how to save yourself some headache by creating and testing your bean outside of XPages first here:
https://wissel.net/blog/2013/06/managed-beans-xpages-and-testability.html

You want to use the extension library, which comes with ODBC/JDBC stuff and check related questions:

Let us know what worked for you!

Upvotes: 1

Related Questions