I need to do a list that obtain information from a DB. So my question is:
There is a way to Build a list where filters and columns come from a DB query using the joget community version ?. if the answer is yes. How can I do the connection with the BD? and where I put this?.
Please I need your help because I'm new using joget Workflow and I want to learn more about this.
Using the community version, I don't think so. At least not right out of the box. They do seem to offer this in the Enterprise Edition.
You could write a Datalist Binder Plugin, but it would require a little bit of work and knowledge of the source. You can download the source and use the existing FormDataBinder as an example.
You're probably not looking at a 1 hour job here - it will take some time to get this to work.
You'd have to create a new Java project, write your plugin code and compile it. It will compile into a nice JAR file which you will import into the Joget Console application.
The first thing to do would be to try developing one of the example plugins. (Be sure you copy the pom.xml exactly). Once you get that compiled, import it into your Joget application (Click 'System Settings' at the top of the Admin Console application, then 'Manage Plugins' and upload your plugin.) Look at the logs to make sure there are no errors with your plugin or import.
Once you get that working, you'll want to use that FormDataBinder code (in the Joget source) as a template and use it in a copy of your example plugin project (that you got to work above.)
I don't have any experience with Grid yet so I would have pointed you to the Select Box source first. I imagine that it's similar. There's got to be code in the Joget source somewhere you can use to figure out how to pass the data back. (I just haven't searched through myself to find it.) If you figure it out, please document it so we can all know how to do it in the future.
Ok. look this. I have 9 users in my dir_user table and I put the next code in the Configure Bean Shell Form Binder
import org.joget.apps.form.model.*;
import org.joget.apps.form.service.*;
import java.sql.*;
import java.util.*;
import org.apache.commons.collections.SequencedHashMap;
Connection con = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/jwdb?characterEncoding=UTF-8", "root", "");
FormRowSet f = new FormRowSet();
f.setMultiRow(true);
if(!con.isClosed()){
PreparedStatement stmt = con.prepareStatement("SELECT * FROM dir_user");
ResultSet rs = stmt.executeQuery();
while (rs.next()){
FormRow r1 = new FormRow();
r1.put("gridColumn1", rs.getString(1));
r1.put("gridColumn2", rs.getString(2));
r1.put("gridColumn3", rs.getString(3));
f.add(r1);
}
}
return f;
The image below show the code result.
as you can see there are 9 rows, the same quantity than users (dir_user table), but it doesn't show me the columns names with the information.
Can someone tell me where I'm wrong?. I think the nex code
r1.put("gridColumn2", rs.getString(2));
isn't correct but i don't have idea of another way.
14 Comments
dark devil
I have a question.
How can I set the process name or another process properties in a text field.
I hope you helpme.
thanks.
Pete
What's the bigger problem you are trying to solve here?
dark devil
Ok. Processes have properties like id,name,etc. now I want to put that properties in a text field or text area.
for example...to get the current username you can write into a text field the nex: value=#currentUser.username#
how can i do the same to get process properties.
thanks Pete for answer.
Pete
You probably want to use a Hash variable. Set the value of your field equal to #assignment.processName#
dark devil
it doesn't works.
can you post a visual example to guide me.
I'm on the lookout.
thanks again
Pete
Add a new text field with the hash variable as the value.
It will look something like this in the Form Builder.
Save the form.
When you go through your process, the form field will be updated with whatever the value in the hash variable is.
dark devil
Thanks Pete.
Now could you help me in a question.
I need to do a list that obtain information from a DB. So my question is:
There is a way to Build a list where filters and columns come from a DB query using the joget community version ?. if the answer is yes. How can I do the connection with the BD? and where I put this?.
Please I need your help because I'm new using joget Workflow and I want to learn more about this.
Pete
Using the community version, I don't think so. At least not right out of the box. They do seem to offer this in the Enterprise Edition.
You could write a Datalist Binder Plugin, but it would require a little bit of work and knowledge of the source. You can download the source and use the existing FormDataBinder as an example.
dark devil
I have already used FormDataBinder and also I have te Source. So... where I would put the code that I write?. can you help me?
Thanks Pete.
Pete
You're probably not looking at a 1 hour job here - it will take some time to get this to work.
You'd have to create a new Java project, write your plugin code and compile it. It will compile into a nice JAR file which you will import into the Joget Console application.
The first thing to do would be to try developing one of the example plugins. (Be sure you copy the pom.xml exactly). Once you get that compiled, import it into your Joget application (Click 'System Settings' at the top of the Admin Console application, then 'Manage Plugins' and upload your plugin.) Look at the logs to make sure there are no errors with your plugin or import.
Once you get that working, you'll want to use that FormDataBinder code (in the Joget source) as a template and use it in a copy of your example plugin project (that you got to work above.)
Many directions/resources to do this are here.
dark devil
Ok Pete. I know that this isn't easy but I will try to do this. thanks for the information and a I hope you help me later in other things that I need.
thanks again Pete.
dark devil
Hi Pete.
I need your help
Now arised a detail. do you know how can I fill a grid with the dir_user table using bean shell form binder. in the same joget version (v3 community).
Y have tried with the sorce for the Select Box but it doesn't work.
Pete
I don't have any experience with Grid yet so I would have pointed you to the Select Box source first. I imagine that it's similar. There's got to be code in the Joget source somewhere you can use to figure out how to pass the data back. (I just haven't searched through myself to find it.) If you figure it out, please document it so we can all know how to do it in the future.
dark devil
Thanks Pete.
Ok. look this. I have 9 users in my dir_user table and I put the next code in the Configure Bean Shell Form Binder
The image below show the code result.
as you can see there are 9 rows, the same quantity than users (dir_user table), but it doesn't show me the columns names with the information.
Can someone tell me where I'm wrong?. I think the nex code
r1.put("gridColumn2", rs.getString(2));
isn't correct but i don't have idea of another way.