B4J Question Orchestration, class, code module, layout question...

Robert Maguire

Member
Licensed User
Longtime User
Hi Folks,

I've gotten myself into an argument with myself that I'm struggling to find the answer to.

I'm developing a B4J application that has an extensive UI based on a single form containing:
  • A Border pane containing:
    • An Anchor Pane containing an Accordion on the left side
    • An Anchor Pane in the center
  • The Accordion contains a number of Title Panes that display brief details of records in different tables in a SQLite database. One Title Pane for each different table.
    • You click on a record in the Title Pane and it loads a layout containing all the record details for the item chosend
    • You can then edit, delete (or insert) a new record.
Screen shot attached.

The application is carved up as:
  • a Main module for the application orchestration and controlling the Accordion.
  • a Code module for each of the Center Panes that allow record editing.
  • a Code module for handling Records and database access for each type of record in the database.
I'm using code modules not classes because I do not need to have instances of the center panes. One click edits that record and that record only.

The problem is this...I want to ensure that the user is prompted to save the record (if changed) whenever they:
  • Click on a different record in the Title Pane (Accordion); OR
  • Close the application; OR
  • Click on the 'Update' menu (of the form); OR
  • Click on the 'Update' option of a Context menu defined for the Center Pane
Where I'm struggling is where and how to place the the code parts, i.e.
  • The Record code module handles the DB access but should not display Message Dialogues
  • I don't want to duplicate code that displays the
    • Confirmation dialogue (and if Yes)
    • Asks the Record module to Validate the data entered;
      • If Invalid data displays a dialogue with the invalid data and aborts the update
      • If valid data
        • Asks the Record modules to update the database and displays success or not
This sequence is currently coded in the Main module but can be invoked from the four events previously mentioned, HOWEVER... I don't believe that it is good form for the Pane module or the Record module to be calling code in the Main module (it makes the modules less re-usable).

Am I over-thinking this or how/where should code be called that is re-used in different parts of the overall application.
 

Attachments

  • ScreenShot.jpg
    ScreenShot.jpg
    108.7 KB · Views: 275

Robert Maguire

Member
Licensed User
Longtime User
I didn't attach a copy of the project before because my database contains real data. Obviously a copy of the project is better than my description so I have pared down the database and hacked all the names so that it no longer contains real data.

I have attached a copy of the project to illustrate the problem. Obviously the project is far from complete but any assistance is greatly received. Please note it contains a few libraries and things that I have not yet implemented (and may remove).

I'd also like to know if my approach to coding this is way off track or could be vastly improved.

Thanks in advance
 

Attachments

  • Quiver.zip
    264.3 KB · Views: 227
Upvote 0
Top