Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
www.odtug.com
Vesterli
A wizard-built user interface To create a user interface with the absolute minimum of effort, you choose your View project in the application and choose File > New > Client Tier > ADF Swing > Form (not Empty Form). This will start the ADF Swing Form wizard as shown in Figure 1.
Nothing is fixed
If youve built a single-table application on DEPT using the ADF Swing Form Wizard, youll get something like FormDeptView1.java and PanelDeptView1.java in the application navigator. JDeveloper contains has a so-called structure pane (by default in the lower half of the left column of the screen) showing the structure of the currently selected object see figure 2. Note the two tabs Source and Design at the bottom of the pane these allow you to select to see the structure of your Java code or the structure of your user interface.
www.odtug.com
Vesterli
www.odtug.com
Vesterli
What to do where
In Oracle Forms, there was not always a clear distinction between data and presentation. In some places, these were separate (LOVs and their underlying Record Groups), but in other places they were mixed together (POST-QUERY triggers to populate lookup items). In an ADF Swing application, this distinction is explicit: You have a data model layer (in the Model project) and the actual user interface (in the View project), and you need to place your code in the right place. Data validation should be done in the Entity Objects. To add validation, double-click on an entity object and choose Validators. Then either right-click on an attribute or on the Entity node to add an entity (row) level validation. See Figure 4. This allows you to define your rules in one place so that they take effect no matter which view object access data.
www.odtug.com
Vesterli
Everything is code
When you look at the code that JDeveloper has produced, you will notice that there is both a Design and a Source tab at the bottom of the window. This different from Forms:
www.odtug.com
Vesterli
In Forms, an application contained code and a layout, stored in the FMB file in some proprietary format. At runtime, the Forms Runtime would interpret the FMB/FMX file and produce the output.
In Java, an application only consists of code. At runtime, the code is executed, and every item in the application is an object created by code. If youve built a single-table application on DEPT using the ADF Swing Form Wizard, youll have something like FormDeptView1.java and PanelDeptView1.java. If you choose the Source tab in the Structure pane, you can see a graphical overview of the source code JDeveloper has built for you. See Figure 6.
This is why you should use dialog boxes like the Constraints pane to control your forms layout Other parts are clearly legible, at least once you get the hang of how to read Java. For example, the first part of the code that build a dialog box to prompt the user to save a pending transaction:
if (panelBinding.isTransactionDirty()) { JButton commitButton = new JButton("Commit"); commitButton.setMnemonic('C'); JButton rollBackButton = new JButton("Rollback"); rollBackButton.setMnemonic('R'); Object[] options = { commitButton, rollBackButton }; final JOptionPane optionPane = new JOptionPane("How do you want to close the transaction?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null, options, options[0]);
www.odtug.com
Vesterli
This is a lot more power than was available in Forms. In Forms, the Forms Runtime itself was a black box, and if you wanted anything that the Forms Runtime didn't offer, you were out of luck (until the advent of Pluggable Java Components, anyway). In Java, your user interface is built as the application runs. This means that you can change everything you want.
Seeing is believing
If you wish to try your hand building ADF Swing applications, you can simply step through the wizards as described above. OTN has a number of JDeveloper ADF tutorials and demos there is only a little on ADF Swing, but the material on ADF middle tier components is useful as well. You can also find a couple of demos showing the development of a simple EMP/DEPT ADF Swing application on www.vesterli.com.
www.odtug.com