Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
Hi ,
I have developped a JAVA code on bean shell form binder to display the list of username available in my jwdb database in a grid column . My code work well in Eclipse :see below code
--
package JogetCode;
import java.util.*;
import java.sql.*;
public class JavaCodeForJoget {
/**
* @param args
* @throws ClassNotFoundException
* @throws IllegalAccessException
* @throws InstantiationException
*/
public static void main(String[] args) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3307/jwdb?characterEncoding=UTF-8", "root", "");
if(!conn.isClosed()){
String sql = "SELECT * FROM dir_user";
PreparedStatement stmt = conn.prepareStatement(sql);
ResultSet rs = stmt.executeQuery();
while (rs.next())
}
} catch (SQLException e)
}
}
---
I have adapted this code to my joget form :
See below for code :
import org.joget.apps.form.model.*;
import org.joget.apps.form.service.*;
import java.sql.*;
import org.apache.commons.collections.SequencedHashMap;
import java.util.*;
public FormRowSet test() {
FormRowSet f = new FormRowSet();
f.setMultiRow(true);
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql://localhost:3307/jwdb?characterEncoding=UTF-8", "root", "");
if(!con.isClosed()){
String sql = "SELECT * FROM dir_user";
PreparedStatement stmt = con.prepareStatement(sql);
ResultSet rs = stmt.executeQuery();
while (rs.next())
}
return f;
}
return test();
--
my display is :
FormUtilprojectleader
gridColumn1
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
I dont see the username but only delete row button . The number of user in my db is 15 . I can see 15 lines in the grid but the nale is not being displayed.
Thank you all for your help .
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 Comments
KARUPPANNAN Meven
i wanted to say "the name is not being displayed " ^^
Walter
How do you design your grid? Did you use the correct column ID?
Try to read up Load & Store Form Grid Data Using Bean Shell Form Binder
KARUPPANNAN Meven
Hi walter , is this ok ? Or do i need to add options ?
KARUPPANNAN Meven
I have add two columns in options and i modify my code as :
r1.put("column1", rs.getString(1));
r1.put("column2", rs.getString(2));
i am getting this error :
KARUPPANNAN Meven
The problem has been solved . I have adapted my code to a drop down list box (and not a grip) and all users are being showed correctly . regards , Meven .
michal hornak
Correct Grid design should look like this:
beanshell script part: