How to get data from the Form
I create custom connector for write data into database . now i create one from :'emp_details' how can i get this form's data into connector . for write this form data into database
Let take Clear example :
one from : emp_detail fields on that form : name , address
connector i created code is as follow , so how can i pass forms field into this preparedstatement's query
/** * */ package org.mycompany.connector;
import org.bonitasoft.engine.connector.ConnectorException; import java.sql.*; public class OracleWriteImpl extends AbstractOracleWriteImpl {
// JDBC driver name and database URL
static final String JDBC_DRIVER = "oracle.jdbc.driver.OracleDriver";
final String DB_URL ="jdbc:oracle:thin:@200.200.1.224:1583:DNLCLONE";
private Connection conn;
private PreparedStatement pstmt;
@Override
protected void executeBusinessLogic() throws ConnectorException{
try {
String sql = "INSERT INTO XX_HOTEL(NAME,ADDRESS)VALUES (?,?)";
pstmt = conn.prepareStatement(sql);
* pstmt.setString(1, ??????????); // how to get form's input (field : name )
pstmt.setString(2, ??????????); // how to get form's input (field : address )*
pstmt.executeUpdate();
} catch (SQLException e) {
throw new ConnectorException(e);
}
}
@Override
public void connect() throws ConnectorException{
try {
Class.forName(JDBC_DRIVER);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
throw new ConnectorException(e);
}
try {
conn = DriverManager.getConnection(DB_URL,getUser(),getPass());
} catch (SQLException e) {
// TODO Auto-generated catch block
throw new ConnectorException(e);
}
}
@Override
public void disconnect() throws ConnectorException{
try {
pstmt.close();
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
throw new ConnectorException(e);
}
}
}
Hello,
The form and the connector are completely disconnected. Then, you have to follow this step : 1/ save your form information to a variable To do that, on each widget (which are not in read only), you can see an "output operation". Select a variable. It may be a process variable (i.e. a variable define at the process variable) or an activity variable (a variable define at the activity level, so this variable is not accessible outside the activty => that's mean your connector is define in the SAME activity). imagine you define a variable "myName" and a variable "myAddress". Mach the output of your widget "name" to "myName". Same with address
2/ on your connector, you should have some input variable (when you create your connector, define some input).
On the connector, you can access the input variable by getter (example, you should define a "name" and a "address" input variable). in your connector, Bonita will generate for you a getName() and a getAddress() method. use it in your connector
3/ attache the connector to your activity : then, Bonita will prompt you a wizard page where he ask the name and the address input. Match them to the variable "myName" and "myAddress"
That's is !
Then, your connector can be use in different way (it is generic) and independant from your form.
Comments
Bonjour Pierre-yves Monnet,
J'ai le même souci j'ai fait ce que vous avez dit mais toujours ça marche pas rien ne s'affiche sur ma base de données.
Besoin de votre aide.Merci
Voila mon post http://community.bonitasoft.com/answers/how-get-data-form-0