Question

I have inherited a Java Swing data maintenance app.

There is a user administration module which has the main user attributes on the main JPanel. In a subsidiary JTabbedPane there are master detail relationships maintained. e.g. the groups that user is a member of and the organisations that a user can be associated with. I need to be able to cross validate such that the organisation pane will only be accessible if the user is a member of a particular group.

What is best way to achieve this without getting the Swing UI code and the data access and management code tied together?

I can see the need for more of this data driven component management so a generic way of accomplishing this is what I am looking for ideally.

Was it helpful?

Solution

Use dependency injection and "services". One such service is "canUserAccessOrgPane()"

The UI gets the bean which implements the service injected without any knowledge where it comes from.

The bean has no idea in which parts of the code it is used.

The config of the DI framework will connect the two.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top