...
Our first example is to create a form with a dropdown control that is dynamically populated with the above list of customers from the database. When the user selects a customer by name, the value of the dropdown control should be set to the customer number.
The steps are as follows:
...
Next, we will add a drop down that displays the list of orders for a particular customer. When the user selects a customer name from the first drop down, we will display the list of orders for that customer from the database. This is essentially repeating the steps above except that the database query is triggered by a user action (selecting a customer from the drop down) and depends on the selected customer.
Define a query
...
Create a business rule
- Click the icon in the toolbar at the top of the Form Designer.
- Click to create a new rule, then click the Edit icon, Rule Code then click Edit Code to open the rule editor.
- Set the Name to 'Show orders'.
- In the Rule text area: copy and paste the following:
...
Now, we will display order details for any given order. For example, for order number 10397 above, the order details resultset is shown below.
Since order details is a complex structure (product name, quantity, price etc.) we will use 's built-in XML features to generate controls and populate them from the database. When an order is selected, the order line items will be displayed as shown below:
Define a query
...
Now, we connect the generated controls to the database query defined above. See Doc URl Wizards for help on the steps below.
- Click on the Doc Action button Form Properties icon in the toolbar at the top of the form.
- In the dialog box that appears click on 'Select the Document Actions tab and the Send Data sub-tab.
- Select Manually set document URIs'.
- A new dialog box will appear. Click the Next button.
- You should see the Document name change to 'orderDetailsByOrder', which is the data source we are interested in.
- Set the URL to: http://localhost:8082/database/BIRT/orderDetailsByOrder?onum={so} (for standalone bundle with Cloud, replace <server:port> with app.frevvo.com.)
- Set the Read method to GET.
- Click the Finish buttonSubmit.
This step indicates to that the 'orderDetailsByOrder' document is linked to the above URL via the READ method GET. will issue an HTTP GET request to the above URL and if an XML document conforming to the schema above is returned, will automatically initialize controls in the form using that document.
The URL itself is a dynamic URL and has a parameter indicated by {so}. Remember that we have a control in the form named 'so' (defined in this step. When the value of the control named 'so' changes (which will happen when the user selects a particular order), will automatically issue an HTTP GET to the above URL using the new order number and will dynamically update the order details including creating new line items, removing old ones etc. without refreshing the form as shown in the picture below.
Example 4: Create a new order
...
Create a business rule
- Click the icon in the toolbar at the top of the Form Designer.
- Click to create a new rule, then click the Edit icon, Rule Code then click Edit Code to open the rule editor.
- Set the Name to 'Copy customer number and generate an order number'.
- In the Rule text area: copy and paste the following:
...
Now, we connect the generated controls to the database query defined above. See Doc URI Wizards for help on the steps below.
- Click on the Doc Action button Form Properties icon in the toolbar at the top of the form.
- In the dialog box that appears click on 'Select the Document Actions tab and the Send Data sub-tab.
- Select Manually set document URIs'.
- A new dialog box will appear. Click the Next button.
- You should see the Document name change to 'createOrder', which is the data source we are interested in.
- Set the URL to: http://localhost:8082/database/BIRT/createOrder (for standalone bundle with Cloud, replace <server:port> with app.frevvo.com.)
- Leave the Read method empty.
- Set the Write method to POST.
- Click the Finish buttonSubmit.
This step indicates to that the 'createOrder' document is linked to the above URL via the WRITE method POST. When the form is submitted, will issue an HTTP POST request to the above URL sending the createOrder XML document in the payload. The database connector will map this to the <create> operation of the createOrder query that we defined above, will use the data in the XML document to resolve the query (replace {cnum} and {onum} with values from the XML) and perform the INSERT.
...