In this example we are extracting information from three Tables: employees, department, and access. Both tables department and access are lookup tables. Their data values are set and shouldn't be changed. These tables will be placed in two seperate Joins and each of those Joins will have their canWrite property set to false. The first Join containing fields for table department is a special use case. Table employees has a field named dept. It holds a value of type INT and references a record in the lookup table department directly. While table access is also a lookup table, its values are obtained differently since there is a link table between it and the employees table. The link table is named emp_access. This is a typical database design whereby we have a one-to-many relationship. Where an employee can belong to only one department, an employee can be granted access to several options in the access table: Printer, Servers, Desktop, VMs, Web-site, and Accounts.
While on the surface the DataTables interface seems straight forward, setting up the server side JSP page requires extra work to make it all come together. Where possible, we entered lots of comments so that you can follow the train of thought of the author.
When using the forms to create a new record or editing an existing one, this example displays a select drop down list for the Department field. With a select you can only choose one option. The Access field appears as several checkbox options. In this case, you can select multiple options as noted previously.
When the JSON string is sent from JED on the server side to the client side, the field department is sent as an object, while the field access is sent as an array of objects:
So that the forms have all the options to display for both department and access, in the JSP page we provide the necessary data and place it in an object named "options" in the JSON string.
@see Join Tutorial 2 for more information
|Loading data from server|