Hi Robert again ;),
complication connected with creating new record in detailed table there
is known issue. This is a consequence of the latest update of Beans
Binding library. We don't want to deal with ObservableCollections in our
master/detail template (it is not straightforward when using JPA).
Hence, we force the update of the detail table by un-selection and
re-selection of the corresponding row in the master table. This worked
with the previous versions of the library because they worked as if they
had 'sourceUnreadableValue' set to 'null' for all bindings. Now, when
the selection is cleared then nothing happens because
'sourceUnreadableValue' is not set for 'detailTable.elements' binding.
The fix is to set 'sourceUnreadableValue' of this binding to 'null'. It
has been already solved in trunk, but not for NetBeans 6.0 because it's
too late :o(. If you want to fix that in form/application generated by
NetBeans 6.0, follow these steps:
1. Select detailTable
2. Switch to Binding category in Properties window
3. Select elements property
4. Invoke property customizer (Press ... button)
5. Switch to Advanced tab.
6. Check 'Unreadable Source Value' (<none> should be selected in combo
next to this check-box).
7. Press OK.
FOR NOTE:
All the templates which are generated during building process of JDA
project, should demonstrate the way how to use JPA and beans binding. We
don't want to overload users with very complicated code. and therefore
please don't confirm this as a real - world application. It's really
just a sample.
Thanks for understanding ;o)
Regards
Janie
RobertPage napsal(a):
> Hi All,
>
> Another long subject line!
>
> I'm still trying to work with master and detail tables in a desktop
> database application.
> Thanks to Jana Maleckova's pointer about the foreign key needing to be
> declared, and sample
> table example, the New Project Wizard will create for me a simple form based
> on the two tables.
>
> I can enter a master record with no problem [1]. When I click the master
> table's New button, a new row appears in the master table. It's even
> selected [2]. I can enter data, save it, refresh it.
>
> The problem comes when I try to enter a detail row.
>
> I select a row in the master table, and click the detail table's New
> button. The new row isn't visible.
> You can't put data in it. You're stuck unless you select a different row in
> the master table, and then select the row you actually wanted. The detail
> table is drawn and the new row is visible and available.
>
> I've looked at the code that the wizard generates to handle new detail
> rows. The new row is created, persisted, added and selected. For some
> reason,
>
> detailTable.scrollRectToVisible(detailTable.getCellRect(row, 0, true));
>
> isn't making the row appear. I even tried some explicit repainting, without
> success.
> Is it just something I'm doing wrong? [3]
>
> To create the same tables and invoke the wizard:
> (Release RC1 on Windows XP Pro and Windows 2000)
> I'm using the tables from Jana's example, but I changed the table names
> from TEST1 and TEST2.
> These are created in a Java DB database.
>
> CREATE TABLE AUTHOR
> (
> AUTHOR_ID INT NOT NULL,
> FIRSTNAME VARCHAR(200) NOT NULL,
> SURNAME VARCHAR(200) NOT NULL,
> PRIMARY KEY (AUTHOR_ID)
> );
>
> CREATE TABLE BOOK
> (
> ALBUM_ID INT NOT NULL,
> ALBUMNAME VARCHAR(200) NOT NULL,
> AUTHOR_INH INT,
> FOREIGN KEY (AUTHOR_INH) REFERENCES AUTHOR (AUTHOR_ID),
> PRIMARY KEY (ALBUM_ID)
> );
>
> Then run the New Project > Java Desktop Application > Database Application
> wizard. Make AUTHOR your master table. Book will be your details table. Run
> the resulting application. Enter a new author with the ID 1. Save the
> author. Try to enter a new book. If you can't, try entering another author
> and use the trick of switching back and forth.
>
> Thanks for reading this far,
> Robert
>
>
>
>
> [1] It took a while for the form to train me. Always exit the field to make
> the data "real". Never use the Enter key for navigation. Always use the Tab
> key, but don't expect it to go to the next column in the same row unless
> there's only one row.
>
> [2] Ideally, the focus would also go to the place where you're about to
> enter data. Showing the row selected but not giving it focus is just a
> tease.
>
> [3] Again? But there are some redraw issues here. If the application
> languishes in the background, say while you're posting a longwinded
> description to NetCAT, when you bring it to the foreground sometimes
> the frame only partly redraws. You have a lot of grey space where tables and
> buttons should be. The tooltips still pop up for invisible buttons.
>
http://www.nabble.com/file/p13815728/HalfAnApp.jpg
>