When working with tabless tabpanels, it would be very useful to be able to get the name of the form containing the tab panel, and in the case of forms nested in forms nested in forms, etc., the name of at least the ‘topmost’ form.
In the second case, the user could get the name of a particular level of parent by specifiying the number of levels ‘up’ to return; a value o f -1 would return the root-level parent.
I’m curious. How might you use that? I use getSelectedTabFormName() to figure out what form is being shown in a tab. I suppose that’s looking down the chain rather than up.
Hi Bob. The general issue is having a form that is displayed as a tabless tabpanel (perhaps multiple levels down) that has functionality that must be different depending on its parent form. We run up against this time and time again since we started using (and loving) Servoy.
Here’s just one example from a job-tracking application we’re working on…
We have a ‘notes’ file. The user can create general client notes, production notes, billing notes, etc. We have tabless tab panels for the main four kinds of notes. These are in another tabless tab panel that gets included in many different forms–client, jobs, quotes, billing, etc. The actual notes displayed need to be different depending on the ‘root’ form in which the nested tab panels appear.
In keeping with good OOP principles, all the methods that affect the notes forms (including the SQL queries that select the notes to be displayed) are local to the notes forms, themselves. When the user clicks buttons or checkboxes on those forms, the onAction events need to act differently depending on root enclosing form–leading to the problem: How can a nested nested tab panel ‘know’ what its root-enclosing form is?
Of course we can get the desired behavior by setting globals when the user navigates to a root-level form, like Clients, but the code would be so much leaner, cleaner, and clearer if a nested tabpanel method could determine for itself what its ‘root’ level enclosing form is.
Thanks for the nice explanation. Unfortunateley, Servoy isn’t object oriented in the way you would like to reference tab panels within other tab panels. I can see the value in your idea of being able to have a method for any form that is based on what tab panel is displaying it at any time.
However, in the case you mentioned, I don’t see why you couldn’t come at it from the other direction. For any given tab panel, you can always tell what form is displayed within it by using getSelectedTabFormName().
In your example, there is your root form which includes your tab panel which then includes notes tab panel that you want to customize. Your root form can call a global on show method that could select the right tabs in your tab panels and set any otehr needed properties.
I do something similar to what you are talking about with the splitpanes bean. I have a pane component that displays a list of records in the found set. In another pane, I display one of three completely different tab panels depending on the type of record selected. Those tab panels then have tab panels that may or may not be used in other places. This is a top down approach, but it works.